From 256b87812ef6ab1e24eb1e67eebd8837532a8ab8 Mon Sep 17 00:00:00 2001 From: Dalton Hubble Date: Tue, 2 Aug 2022 18:15:03 -0700 Subject: [PATCH] Remove Terraform template provider dependency * Use Terraform builtin templatefile functionality * Remove dependency on deprecated Terraform template provider Rel: * https://registry.terraform.io/providers/hashicorp/template/2.2.0 * https://github.com/poseidon/terraform-render-bootstrap/pull/293 --- CHANGES.md | 1 + aws/fedora-coreos/kubernetes/controllers.tf | 39 +++++----------- aws/fedora-coreos/kubernetes/versions.tf | 6 +-- .../kubernetes/workers/versions.tf | 4 +- .../kubernetes/workers/workers.tf | 22 +++------ aws/flatcar-linux/kubernetes/controllers.tf | 39 +++++----------- aws/flatcar-linux/kubernetes/versions.tf | 6 +-- .../kubernetes/workers/versions.tf | 4 +- .../kubernetes/workers/workers.tf | 22 +++------ azure/fedora-coreos/kubernetes/controllers.tf | 39 +++++----------- azure/fedora-coreos/kubernetes/versions.tf | 6 +-- .../kubernetes/workers/versions.tf | 4 +- .../kubernetes/workers/workers.tf | 21 +++------ azure/flatcar-linux/kubernetes/controllers.tf | 39 +++++----------- azure/flatcar-linux/kubernetes/versions.tf | 6 +-- .../kubernetes/workers/versions.tf | 4 +- .../kubernetes/workers/workers.tf | 22 +++------ .../fedora-coreos/kubernetes/profiles.tf | 45 +++++++------------ .../fedora-coreos/kubernetes/versions.tf | 5 +-- .../flatcar-linux/kubernetes/profiles.tf | 44 +++++++----------- .../flatcar-linux/kubernetes/versions.tf | 5 +-- .../fedora-coreos/kubernetes/controllers.tf | 41 +++++------------ .../fedora-coreos/kubernetes/versions.tf | 5 +-- .../fedora-coreos/kubernetes/workers.tf | 24 ++++------ .../flatcar-linux/kubernetes/controllers.tf | 41 +++++------------ .../flatcar-linux/kubernetes/versions.tf | 5 +-- .../flatcar-linux/kubernetes/workers.tf | 24 ++++------ .../fedora-coreos/kubernetes/controllers.tf | 39 +++++----------- .../fedora-coreos/kubernetes/versions.tf | 6 +-- .../kubernetes/workers/versions.tf | 4 +- .../kubernetes/workers/workers.tf | 22 +++------ .../flatcar-linux/kubernetes/controllers.tf | 39 +++++----------- .../flatcar-linux/kubernetes/image.tf | 2 +- .../flatcar-linux/kubernetes/versions.tf | 6 +-- .../flatcar-linux/kubernetes/workers/image.tf | 2 +- .../kubernetes/workers/versions.tf | 4 +- .../kubernetes/workers/workers.tf | 22 +++------ 37 files changed, 195 insertions(+), 474 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 925ae469..cc8eca62 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ Notable changes between versions. ## Latest * Update Calico from v3.23.1 to [v3.23.3](https://github.com/projectcalico/calico/releases/tag/v3.23.3) +* Remove use of deprecated Terraform [template](https://registry.terraform.io/providers/hashicorp/template) provider ## v1.24.3 diff --git a/aws/fedora-coreos/kubernetes/controllers.tf b/aws/fedora-coreos/kubernetes/controllers.tf index f7e6e626..1b9a463e 100644 --- a/aws/fedora-coreos/kubernetes/controllers.tf +++ b/aws/fedora-coreos/kubernetes/controllers.tf @@ -23,7 +23,7 @@ resource "aws_instance" "controllers" { instance_type = var.controller_type ami = var.arch == "arm64" ? data.aws_ami.fedora-coreos-arm[0].image_id : data.aws_ami.fedora-coreos.image_id - user_data = data.ct_config.controller-ignitions.*.rendered[count.index] + user_data = data.ct_config.controllers.*.rendered[count.index] # storage root_block_device { @@ -46,41 +46,22 @@ resource "aws_instance" "controllers" { } } -# Controller Ignition configs -data "ct_config" "controller-ignitions" { - count = var.controller_count - content = data.template_file.controller-configs.*.rendered[count.index] - strict = true - snippets = var.controller_snippets -} - -# Controller Fedora CoreOS configs -data "template_file" "controller-configs" { +# Fedora CoreOS controllers +data "ct_config" "controllers" { count = var.controller_count - - template = file("${path.module}/fcc/controller.yaml") - - vars = { + content = templatefile("${path.module}/fcc/controller.yaml", { # Cannot use cyclic dependencies on controllers or their DNS records etcd_name = "etcd${count.index}" etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" # etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,... - etcd_initial_cluster = join(",", data.template_file.etcds.*.rendered) + etcd_initial_cluster = join(",", [ + for i in range(var.controller_count) : "etcd${i}=https://${var.cluster_name}-etcd${i}.${var.dns_zone}:2380" + ]) kubeconfig = indent(10, module.bootstrap.kubeconfig-kubelet) ssh_authorized_key = var.ssh_authorized_key cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_domain_suffix = var.cluster_domain_suffix - } + }) + strict = true + snippets = var.controller_snippets } - -data "template_file" "etcds" { - count = var.controller_count - template = "etcd$${index}=https://$${cluster_name}-etcd$${index}.$${dns_zone}:2380" - - vars = { - index = count.index - cluster_name = var.cluster_name - dns_zone = var.dns_zone - } -} - diff --git a/aws/fedora-coreos/kubernetes/versions.tf b/aws/fedora-coreos/kubernetes/versions.tf index 64fb28aa..d0e7a259 100644 --- a/aws/fedora-coreos/kubernetes/versions.tf +++ b/aws/fedora-coreos/kubernetes/versions.tf @@ -3,10 +3,8 @@ terraform { required_version = ">= 0.13.0, < 2.0.0" required_providers { - aws = ">= 2.23, <= 5.0" - template = "~> 2.2" - null = ">= 2.1" - + aws = ">= 2.23, <= 5.0" + null = ">= 2.1" ct = { source = "poseidon/ct" version = "~> 0.9" diff --git a/aws/fedora-coreos/kubernetes/workers/versions.tf b/aws/fedora-coreos/kubernetes/workers/versions.tf index c6c95cdb..7dd74a5a 100644 --- a/aws/fedora-coreos/kubernetes/workers/versions.tf +++ b/aws/fedora-coreos/kubernetes/workers/versions.tf @@ -3,9 +3,7 @@ terraform { required_version = ">= 0.13.0, < 2.0.0" required_providers { - aws = ">= 2.23, <= 5.0" - template = "~> 2.2" - + aws = ">= 2.23, <= 5.0" ct = { source = "poseidon/ct" version = "~> 0.9" diff --git a/aws/fedora-coreos/kubernetes/workers/workers.tf b/aws/fedora-coreos/kubernetes/workers/workers.tf index 87e17def..ad78a300 100644 --- a/aws/fedora-coreos/kubernetes/workers/workers.tf +++ b/aws/fedora-coreos/kubernetes/workers/workers.tf @@ -47,7 +47,7 @@ resource "aws_launch_configuration" "worker" { spot_price = var.spot_price > 0 ? var.spot_price : null enable_monitoring = false - user_data = data.ct_config.worker-ignition.rendered + user_data = data.ct_config.worker.rendered # storage root_block_device { @@ -67,24 +67,16 @@ resource "aws_launch_configuration" "worker" { } } -# Worker Ignition config -data "ct_config" "worker-ignition" { - content = data.template_file.worker-config.rendered - strict = true - snippets = var.snippets -} - -# Worker Fedora CoreOS config -data "template_file" "worker-config" { - template = file("${path.module}/fcc/worker.yaml") - - vars = { +# Fedora CoreOS worker +data "ct_config" "worker" { + content = templatefile("${path.module}/fcc/worker.yaml", { kubeconfig = indent(10, var.kubeconfig) ssh_authorized_key = var.ssh_authorized_key cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_domain_suffix = var.cluster_domain_suffix node_labels = join(",", var.node_labels) node_taints = join(",", var.node_taints) - } + }) + strict = true + snippets = var.snippets } - diff --git a/aws/flatcar-linux/kubernetes/controllers.tf b/aws/flatcar-linux/kubernetes/controllers.tf index 1bb9f42b..2d6279ac 100644 --- a/aws/flatcar-linux/kubernetes/controllers.tf +++ b/aws/flatcar-linux/kubernetes/controllers.tf @@ -24,7 +24,7 @@ resource "aws_instance" "controllers" { instance_type = var.controller_type ami = local.ami_id - user_data = data.ct_config.controller-ignitions.*.rendered[count.index] + user_data = data.ct_config.controllers.*.rendered[count.index] # storage root_block_device { @@ -47,41 +47,22 @@ resource "aws_instance" "controllers" { } } -# Controller Ignition configs -data "ct_config" "controller-ignitions" { - count = var.controller_count - content = data.template_file.controller-configs.*.rendered[count.index] - strict = true - snippets = var.controller_snippets -} - -# Controller Container Linux configs -data "template_file" "controller-configs" { +# Flatcar Linux controllers +data "ct_config" "controllers" { count = var.controller_count - - template = file("${path.module}/cl/controller.yaml") - - vars = { + content = templatefile("${path.module}/cl/controller.yaml", { # Cannot use cyclic dependencies on controllers or their DNS records etcd_name = "etcd${count.index}" etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" # etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,... - etcd_initial_cluster = join(",", data.template_file.etcds.*.rendered) + etcd_initial_cluster = join(",", [ + for i in range(var.controller_count) : "etcd${i}=https://${var.cluster_name}-etcd${i}.${var.dns_zone}:2380" + ]) kubeconfig = indent(10, module.bootstrap.kubeconfig-kubelet) ssh_authorized_key = var.ssh_authorized_key cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_domain_suffix = var.cluster_domain_suffix - } + }) + strict = true + snippets = var.controller_snippets } - -data "template_file" "etcds" { - count = var.controller_count - template = "etcd$${index}=https://$${cluster_name}-etcd$${index}.$${dns_zone}:2380" - - vars = { - index = count.index - cluster_name = var.cluster_name - dns_zone = var.dns_zone - } -} - diff --git a/aws/flatcar-linux/kubernetes/versions.tf b/aws/flatcar-linux/kubernetes/versions.tf index 64fb28aa..d0e7a259 100644 --- a/aws/flatcar-linux/kubernetes/versions.tf +++ b/aws/flatcar-linux/kubernetes/versions.tf @@ -3,10 +3,8 @@ terraform { required_version = ">= 0.13.0, < 2.0.0" required_providers { - aws = ">= 2.23, <= 5.0" - template = "~> 2.2" - null = ">= 2.1" - + aws = ">= 2.23, <= 5.0" + null = ">= 2.1" ct = { source = "poseidon/ct" version = "~> 0.9" diff --git a/aws/flatcar-linux/kubernetes/workers/versions.tf b/aws/flatcar-linux/kubernetes/workers/versions.tf index c6c95cdb..7dd74a5a 100644 --- a/aws/flatcar-linux/kubernetes/workers/versions.tf +++ b/aws/flatcar-linux/kubernetes/workers/versions.tf @@ -3,9 +3,7 @@ terraform { required_version = ">= 0.13.0, < 2.0.0" required_providers { - aws = ">= 2.23, <= 5.0" - template = "~> 2.2" - + aws = ">= 2.23, <= 5.0" ct = { source = "poseidon/ct" version = "~> 0.9" diff --git a/aws/flatcar-linux/kubernetes/workers/workers.tf b/aws/flatcar-linux/kubernetes/workers/workers.tf index eb1b2bee..d1611ff8 100644 --- a/aws/flatcar-linux/kubernetes/workers/workers.tf +++ b/aws/flatcar-linux/kubernetes/workers/workers.tf @@ -47,7 +47,7 @@ resource "aws_launch_configuration" "worker" { spot_price = var.spot_price > 0 ? var.spot_price : null enable_monitoring = false - user_data = data.ct_config.worker-ignition.rendered + user_data = data.ct_config.worker.rendered # storage root_block_device { @@ -67,24 +67,16 @@ resource "aws_launch_configuration" "worker" { } } -# Worker Ignition config -data "ct_config" "worker-ignition" { - content = data.template_file.worker-config.rendered - strict = true - snippets = var.snippets -} - -# Worker Container Linux config -data "template_file" "worker-config" { - template = file("${path.module}/cl/worker.yaml") - - vars = { +# Flatcar Linux worker +data "ct_config" "worker" { + content = templatefile("${path.module}/cl/worker.yaml", { kubeconfig = indent(10, var.kubeconfig) ssh_authorized_key = var.ssh_authorized_key cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_domain_suffix = var.cluster_domain_suffix node_labels = join(",", var.node_labels) node_taints = join(",", var.node_taints) - } + }) + strict = true + snippets = var.snippets } - diff --git a/azure/fedora-coreos/kubernetes/controllers.tf b/azure/fedora-coreos/kubernetes/controllers.tf index 02853e33..b72f50d5 100644 --- a/azure/fedora-coreos/kubernetes/controllers.tf +++ b/azure/fedora-coreos/kubernetes/controllers.tf @@ -35,7 +35,7 @@ resource "azurerm_linux_virtual_machine" "controllers" { availability_set_id = azurerm_availability_set.controllers.id size = var.controller_type - custom_data = base64encode(data.ct_config.controller-ignitions.*.rendered[count.index]) + custom_data = base64encode(data.ct_config.controllers.*.rendered[count.index]) # storage source_image_id = var.os_image @@ -111,41 +111,22 @@ resource "azurerm_network_interface_backend_address_pool_association" "controlle backend_address_pool_id = azurerm_lb_backend_address_pool.controller.id } -# Controller Ignition configs -data "ct_config" "controller-ignitions" { - count = var.controller_count - content = data.template_file.controller-configs.*.rendered[count.index] - strict = true - snippets = var.controller_snippets -} - -# Controller Fedora CoreOS configs -data "template_file" "controller-configs" { +# Fedora CoreOS controllers +data "ct_config" "controllers" { count = var.controller_count - - template = file("${path.module}/fcc/controller.yaml") - - vars = { + content = templatefile("${path.module}/fcc/controller.yaml", { # Cannot use cyclic dependencies on controllers or their DNS records etcd_name = "etcd${count.index}" etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" # etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,... - etcd_initial_cluster = join(",", data.template_file.etcds.*.rendered) + etcd_initial_cluster = join(",", [ + for i in range(var.controller_count) : "etcd${i}=https://${var.cluster_name}-etcd${i}.${var.dns_zone}:2380" + ]) kubeconfig = indent(10, module.bootstrap.kubeconfig-kubelet) ssh_authorized_key = var.ssh_authorized_key cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_domain_suffix = var.cluster_domain_suffix - } + }) + strict = true + snippets = var.controller_snippets } - -data "template_file" "etcds" { - count = var.controller_count - template = "etcd$${index}=https://$${cluster_name}-etcd$${index}.$${dns_zone}:2380" - - vars = { - index = count.index - cluster_name = var.cluster_name - dns_zone = var.dns_zone - } -} - diff --git a/azure/fedora-coreos/kubernetes/versions.tf b/azure/fedora-coreos/kubernetes/versions.tf index 15d3040f..8e6044f1 100644 --- a/azure/fedora-coreos/kubernetes/versions.tf +++ b/azure/fedora-coreos/kubernetes/versions.tf @@ -3,10 +3,8 @@ terraform { required_version = ">= 0.13.0, < 2.0.0" required_providers { - azurerm = ">= 2.8, < 4.0" - template = "~> 2.2" - null = ">= 2.1" - + azurerm = ">= 2.8, < 4.0" + null = ">= 2.1" ct = { source = "poseidon/ct" version = "~> 0.9" diff --git a/azure/fedora-coreos/kubernetes/workers/versions.tf b/azure/fedora-coreos/kubernetes/workers/versions.tf index 5ef34d75..15b435b4 100644 --- a/azure/fedora-coreos/kubernetes/workers/versions.tf +++ b/azure/fedora-coreos/kubernetes/workers/versions.tf @@ -3,9 +3,7 @@ terraform { required_version = ">= 0.13.0, < 2.0.0" required_providers { - azurerm = ">= 2.8, < 4.0" - template = "~> 2.2" - + azurerm = ">= 2.8, < 4.0" ct = { source = "poseidon/ct" version = "~> 0.9" diff --git a/azure/fedora-coreos/kubernetes/workers/workers.tf b/azure/fedora-coreos/kubernetes/workers/workers.tf index defd462e..387a485c 100644 --- a/azure/fedora-coreos/kubernetes/workers/workers.tf +++ b/azure/fedora-coreos/kubernetes/workers/workers.tf @@ -9,7 +9,7 @@ resource "azurerm_linux_virtual_machine_scale_set" "workers" { # instance name prefix for instances in the set computer_name_prefix = "${var.name}-worker" single_placement_group = false - custom_data = base64encode(data.ct_config.worker-ignition.rendered) + custom_data = base64encode(data.ct_config.worker.rendered) # storage source_image_id = var.os_image @@ -70,24 +70,17 @@ resource "azurerm_monitor_autoscale_setting" "workers" { } } -# Worker Ignition configs -data "ct_config" "worker-ignition" { - content = data.template_file.worker-config.rendered - strict = true - snippets = var.snippets -} - -# Worker Fedora CoreOS configs -data "template_file" "worker-config" { - template = file("${path.module}/fcc/worker.yaml") - - vars = { +# Fedora CoreOS worker +data "ct_config" "worker" { + content = templatefile("${path.module}/fcc/worker.yaml", { kubeconfig = indent(10, var.kubeconfig) ssh_authorized_key = var.ssh_authorized_key cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_domain_suffix = var.cluster_domain_suffix node_labels = join(",", var.node_labels) node_taints = join(",", var.node_taints) - } + }) + strict = true + snippets = var.snippets } diff --git a/azure/flatcar-linux/kubernetes/controllers.tf b/azure/flatcar-linux/kubernetes/controllers.tf index 3a18628f..914218c4 100644 --- a/azure/flatcar-linux/kubernetes/controllers.tf +++ b/azure/flatcar-linux/kubernetes/controllers.tf @@ -41,7 +41,7 @@ resource "azurerm_linux_virtual_machine" "controllers" { availability_set_id = azurerm_availability_set.controllers.id size = var.controller_type - custom_data = base64encode(data.ct_config.controller-ignitions.*.rendered[count.index]) + custom_data = base64encode(data.ct_config.controllers.*.rendered[count.index]) # storage os_disk { @@ -130,41 +130,22 @@ resource "azurerm_network_interface_backend_address_pool_association" "controlle backend_address_pool_id = azurerm_lb_backend_address_pool.controller.id } -# Controller Ignition configs -data "ct_config" "controller-ignitions" { - count = var.controller_count - content = data.template_file.controller-configs.*.rendered[count.index] - strict = true - snippets = var.controller_snippets -} - -# Controller Container Linux configs -data "template_file" "controller-configs" { +# Flatcar Linux controllers +data "ct_config" "controllers" { count = var.controller_count - - template = file("${path.module}/cl/controller.yaml") - - vars = { + content = templatefile("${path.module}/cl/controller.yaml", { # Cannot use cyclic dependencies on controllers or their DNS records etcd_name = "etcd${count.index}" etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" # etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,... - etcd_initial_cluster = join(",", data.template_file.etcds.*.rendered) + etcd_initial_cluster = join(",", [ + for i in range(var.controller_count) : "etcd${i}=https://${var.cluster_name}-etcd${i}.${var.dns_zone}:2380" + ]) kubeconfig = indent(10, module.bootstrap.kubeconfig-kubelet) ssh_authorized_key = var.ssh_authorized_key cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_domain_suffix = var.cluster_domain_suffix - } + }) + strict = true + snippets = var.controller_snippets } - -data "template_file" "etcds" { - count = var.controller_count - template = "etcd$${index}=https://$${cluster_name}-etcd$${index}.$${dns_zone}:2380" - - vars = { - index = count.index - cluster_name = var.cluster_name - dns_zone = var.dns_zone - } -} - diff --git a/azure/flatcar-linux/kubernetes/versions.tf b/azure/flatcar-linux/kubernetes/versions.tf index 15d3040f..8e6044f1 100644 --- a/azure/flatcar-linux/kubernetes/versions.tf +++ b/azure/flatcar-linux/kubernetes/versions.tf @@ -3,10 +3,8 @@ terraform { required_version = ">= 0.13.0, < 2.0.0" required_providers { - azurerm = ">= 2.8, < 4.0" - template = "~> 2.2" - null = ">= 2.1" - + azurerm = ">= 2.8, < 4.0" + null = ">= 2.1" ct = { source = "poseidon/ct" version = "~> 0.9" diff --git a/azure/flatcar-linux/kubernetes/workers/versions.tf b/azure/flatcar-linux/kubernetes/workers/versions.tf index 5ef34d75..15b435b4 100644 --- a/azure/flatcar-linux/kubernetes/workers/versions.tf +++ b/azure/flatcar-linux/kubernetes/workers/versions.tf @@ -3,9 +3,7 @@ terraform { required_version = ">= 0.13.0, < 2.0.0" required_providers { - azurerm = ">= 2.8, < 4.0" - template = "~> 2.2" - + azurerm = ">= 2.8, < 4.0" ct = { source = "poseidon/ct" version = "~> 0.9" diff --git a/azure/flatcar-linux/kubernetes/workers/workers.tf b/azure/flatcar-linux/kubernetes/workers/workers.tf index a9a3891c..f12a0228 100644 --- a/azure/flatcar-linux/kubernetes/workers/workers.tf +++ b/azure/flatcar-linux/kubernetes/workers/workers.tf @@ -14,7 +14,7 @@ resource "azurerm_linux_virtual_machine_scale_set" "workers" { # instance name prefix for instances in the set computer_name_prefix = "${var.name}-worker" single_placement_group = false - custom_data = base64encode(data.ct_config.worker-ignition.rendered) + custom_data = base64encode(data.ct_config.worker.rendered) # storage os_disk { @@ -88,24 +88,16 @@ resource "azurerm_monitor_autoscale_setting" "workers" { } } -# Worker Ignition configs -data "ct_config" "worker-ignition" { - content = data.template_file.worker-config.rendered - strict = true - snippets = var.snippets -} - -# Worker Container Linux configs -data "template_file" "worker-config" { - template = file("${path.module}/cl/worker.yaml") - - vars = { +# Flatcar Linux worker +data "ct_config" "worker" { + content = templatefile("${path.module}/cl/worker.yaml", { kubeconfig = indent(10, var.kubeconfig) ssh_authorized_key = var.ssh_authorized_key cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_domain_suffix = var.cluster_domain_suffix node_labels = join(",", var.node_labels) node_taints = join(",", var.node_taints) - } + }) + strict = true + snippets = var.snippets } - diff --git a/bare-metal/fedora-coreos/kubernetes/profiles.tf b/bare-metal/fedora-coreos/kubernetes/profiles.tf index 5d960d80..8468840d 100644 --- a/bare-metal/fedora-coreos/kubernetes/profiles.tf +++ b/bare-metal/fedora-coreos/kubernetes/profiles.tf @@ -38,29 +38,22 @@ resource "matchbox_profile" "controllers" { initrd = local.initrd args = concat(local.args, var.kernel_args) - raw_ignition = data.ct_config.controller-ignitions.*.rendered[count.index] + raw_ignition = data.ct_config.controllers.*.rendered[count.index] } -data "ct_config" "controller-ignitions" { - count = length(var.controllers) - - content = data.template_file.controller-configs.*.rendered[count.index] - strict = true - snippets = lookup(var.snippets, var.controllers.*.name[count.index], []) -} - -data "template_file" "controller-configs" { - count = length(var.controllers) - - template = file("${path.module}/fcc/controller.yaml") - vars = { +# Fedora CoreOS controllers +data "ct_config" "controllers" { + count = var.controller_count + content = templatefile("${path.module}/fcc/controller.yaml", { domain_name = var.controllers.*.domain[count.index] etcd_name = var.controllers.*.name[count.index] etcd_initial_cluster = join(",", formatlist("%s=https://%s:2380", var.controllers.*.name, var.controllers.*.domain)) cluster_dns_service_ip = module.bootstrap.cluster_dns_service_ip cluster_domain_suffix = var.cluster_domain_suffix ssh_authorized_key = var.ssh_authorized_key - } + }) + strict = true + snippets = lookup(var.snippets, var.controllers.*.name[count.index], []) } // Fedora CoreOS worker profile @@ -72,28 +65,20 @@ resource "matchbox_profile" "workers" { initrd = local.initrd args = concat(local.args, var.kernel_args) - raw_ignition = data.ct_config.worker-ignitions.*.rendered[count.index] + raw_ignition = data.ct_config.workers.*.rendered[count.index] } -data "ct_config" "worker-ignitions" { +# Fedora CoreOS workers +data "ct_config" "workers" { count = length(var.workers) - - content = data.template_file.worker-configs.*.rendered[count.index] - strict = true - snippets = lookup(var.snippets, var.workers.*.name[count.index], []) -} - -data "template_file" "worker-configs" { - count = length(var.workers) - - template = file("${path.module}/fcc/worker.yaml") - vars = { + content = templatefile("${path.module}/fcc/worker.yaml", { domain_name = var.workers.*.domain[count.index] cluster_dns_service_ip = module.bootstrap.cluster_dns_service_ip cluster_domain_suffix = var.cluster_domain_suffix ssh_authorized_key = var.ssh_authorized_key node_labels = join(",", lookup(var.worker_node_labels, var.workers.*.name[count.index], [])) node_taints = join(",", lookup(var.worker_node_taints, var.workers.*.name[count.index], [])) - } + }) + strict = true + snippets = lookup(var.snippets, var.workers.*.name[count.index], []) } - diff --git a/bare-metal/fedora-coreos/kubernetes/versions.tf b/bare-metal/fedora-coreos/kubernetes/versions.tf index 23072fa4..4ab5a11e 100644 --- a/bare-metal/fedora-coreos/kubernetes/versions.tf +++ b/bare-metal/fedora-coreos/kubernetes/versions.tf @@ -3,14 +3,11 @@ terraform { required_version = ">= 0.13.0, < 2.0.0" required_providers { - template = "~> 2.2" - null = ">= 2.1" - + null = ">= 2.1" ct = { source = "poseidon/ct" version = "~> 0.9" } - matchbox = { source = "poseidon/matchbox" version = "~> 0.5.0" diff --git a/bare-metal/flatcar-linux/kubernetes/profiles.tf b/bare-metal/flatcar-linux/kubernetes/profiles.tf index e59e52af..93b245f6 100644 --- a/bare-metal/flatcar-linux/kubernetes/profiles.tf +++ b/bare-metal/flatcar-linux/kubernetes/profiles.tf @@ -83,56 +83,42 @@ data "template_file" "cached-install-configs" { resource "matchbox_profile" "controllers" { count = length(var.controllers) name = format("%s-controller-%s", var.cluster_name, var.controllers.*.name[count.index]) - raw_ignition = data.ct_config.controller-ignitions.*.rendered[count.index] + raw_ignition = data.ct_config.controllers.*.rendered[count.index] } -data "ct_config" "controller-ignitions" { - count = length(var.controllers) - content = data.template_file.controller-configs.*.rendered[count.index] - strict = true - snippets = lookup(var.snippets, var.controllers.*.name[count.index], []) -} - -data "template_file" "controller-configs" { - count = length(var.controllers) - - template = file("${path.module}/cl/controller.yaml") - - vars = { +# Flatcar Linux controllers +data "ct_config" "controllers" { + count = var.controller_count + content = templatefile("${path.module}/cl/controller.yaml", { domain_name = var.controllers.*.domain[count.index] etcd_name = var.controllers.*.name[count.index] etcd_initial_cluster = join(",", formatlist("%s=https://%s:2380", var.controllers.*.name, var.controllers.*.domain)) cluster_dns_service_ip = module.bootstrap.cluster_dns_service_ip cluster_domain_suffix = var.cluster_domain_suffix ssh_authorized_key = var.ssh_authorized_key - } + }) + strict = true + snippets = lookup(var.snippets, var.controllers.*.name[count.index], []) } // Kubernetes Worker profiles resource "matchbox_profile" "workers" { count = length(var.workers) name = format("%s-worker-%s", var.cluster_name, var.workers.*.name[count.index]) - raw_ignition = data.ct_config.worker-ignitions.*.rendered[count.index] + raw_ignition = data.ct_config.workers.*.rendered[count.index] } -data "ct_config" "worker-ignitions" { - count = length(var.workers) - content = data.template_file.worker-configs.*.rendered[count.index] - strict = true - snippets = lookup(var.snippets, var.workers.*.name[count.index], []) -} - -data "template_file" "worker-configs" { +# Flatcar Linux workers +data "ct_config" "workers" { count = length(var.workers) - - template = file("${path.module}/cl/worker.yaml") - - vars = { + content = templatefile("${path.module}/cl/worker.yaml", { domain_name = var.workers.*.domain[count.index] cluster_dns_service_ip = module.bootstrap.cluster_dns_service_ip cluster_domain_suffix = var.cluster_domain_suffix ssh_authorized_key = var.ssh_authorized_key node_labels = join(",", lookup(var.worker_node_labels, var.workers.*.name[count.index], [])) node_taints = join(",", lookup(var.worker_node_taints, var.workers.*.name[count.index], [])) - } + }) + strict = true + snippets = lookup(var.snippets, var.workers.*.name[count.index], []) } diff --git a/bare-metal/flatcar-linux/kubernetes/versions.tf b/bare-metal/flatcar-linux/kubernetes/versions.tf index 17f1095d..1d149448 100644 --- a/bare-metal/flatcar-linux/kubernetes/versions.tf +++ b/bare-metal/flatcar-linux/kubernetes/versions.tf @@ -3,14 +3,11 @@ terraform { required_version = ">= 0.13.0, < 2.0.0" required_providers { - template = "~> 2.2" - null = ">= 2.1" - + null = ">= 2.1" ct = { source = "poseidon/ct" version = "~> 0.9" } - matchbox = { source = "poseidon/matchbox" version = "~> 0.5.0" diff --git a/digital-ocean/fedora-coreos/kubernetes/controllers.tf b/digital-ocean/fedora-coreos/kubernetes/controllers.tf index 204d8aab..85608a9f 100644 --- a/digital-ocean/fedora-coreos/kubernetes/controllers.tf +++ b/digital-ocean/fedora-coreos/kubernetes/controllers.tf @@ -41,11 +41,11 @@ resource "digitalocean_droplet" "controllers" { size = var.controller_type # network - vpc_uuid = digitalocean_vpc.network.id + vpc_uuid = digitalocean_vpc.network.id # TODO: Only official DigitalOcean images support IPv6 ipv6 = false - user_data = data.ct_config.controller-ignitions.*.rendered[count.index] + user_data = data.ct_config.controllers.*.rendered[count.index] ssh_keys = var.ssh_fingerprints tags = [ @@ -62,39 +62,20 @@ resource "digitalocean_tag" "controllers" { name = "${var.cluster_name}-controller" } -# Controller Ignition configs -data "ct_config" "controller-ignitions" { - count = var.controller_count - content = data.template_file.controller-configs.*.rendered[count.index] - strict = true - snippets = var.controller_snippets -} - -# Controller Fedora CoreOS configs -data "template_file" "controller-configs" { +# Fedora CoreOS controllers +data "ct_config" "controllers" { count = var.controller_count - - template = file("${path.module}/fcc/controller.yaml") - - vars = { + content = templatefile("${path.module}/fcc/controller.yaml", { # Cannot use cyclic dependencies on controllers or their DNS records etcd_name = "etcd${count.index}" etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" # etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,... - etcd_initial_cluster = join(",", data.template_file.etcds.*.rendered) + etcd_initial_cluster = join(",", [ + for i in range(var.controller_count) : "etcd${i}=https://${var.cluster_name}-etcd${i}.${var.dns_zone}:2380" + ]) cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_domain_suffix = var.cluster_domain_suffix - } + }) + strict = true + snippets = var.controller_snippets } - -data "template_file" "etcds" { - count = var.controller_count - template = "etcd$${index}=https://$${cluster_name}-etcd$${index}.$${dns_zone}:2380" - - vars = { - index = count.index - cluster_name = var.cluster_name - dns_zone = var.dns_zone - } -} - diff --git a/digital-ocean/fedora-coreos/kubernetes/versions.tf b/digital-ocean/fedora-coreos/kubernetes/versions.tf index 925b7408..0e6823f5 100644 --- a/digital-ocean/fedora-coreos/kubernetes/versions.tf +++ b/digital-ocean/fedora-coreos/kubernetes/versions.tf @@ -3,14 +3,11 @@ terraform { required_version = ">= 0.13.0, < 2.0.0" required_providers { - template = "~> 2.2" - null = ">= 2.1" - + null = ">= 2.1" ct = { source = "poseidon/ct" version = "~> 0.9" } - digitalocean = { source = "digitalocean/digitalocean" version = ">= 2.12, < 3.0" diff --git a/digital-ocean/fedora-coreos/kubernetes/workers.tf b/digital-ocean/fedora-coreos/kubernetes/workers.tf index da7d71a0..5e139b38 100644 --- a/digital-ocean/fedora-coreos/kubernetes/workers.tf +++ b/digital-ocean/fedora-coreos/kubernetes/workers.tf @@ -37,11 +37,11 @@ resource "digitalocean_droplet" "workers" { size = var.worker_type # network - vpc_uuid = digitalocean_vpc.network.id + vpc_uuid = digitalocean_vpc.network.id # TODO: Only official DigitalOcean images support IPv6 ipv6 = false - user_data = data.ct_config.worker-ignition.rendered + user_data = data.ct_config.worker.rendered ssh_keys = var.ssh_fingerprints tags = [ @@ -58,20 +58,12 @@ resource "digitalocean_tag" "workers" { name = "${var.cluster_name}-worker" } -# Worker Ignition config -data "ct_config" "worker-ignition" { - content = data.template_file.worker-config.rendered +# Fedora CoreOS worker +data "ct_config" "worker" { + content = templatefile("${path.module}/fcc/worker.yaml", { + cluster_dns_service_ip = cidrhost(var.service_cidr, 10) + cluster_domain_suffix = var.cluster_domain_suffix + }) strict = true snippets = var.worker_snippets } - -# Worker Fedora CoreOS config -data "template_file" "worker-config" { - template = file("${path.module}/fcc/worker.yaml") - - vars = { - cluster_dns_service_ip = cidrhost(var.service_cidr, 10) - cluster_domain_suffix = var.cluster_domain_suffix - } -} - diff --git a/digital-ocean/flatcar-linux/kubernetes/controllers.tf b/digital-ocean/flatcar-linux/kubernetes/controllers.tf index 526160c3..1de068cf 100644 --- a/digital-ocean/flatcar-linux/kubernetes/controllers.tf +++ b/digital-ocean/flatcar-linux/kubernetes/controllers.tf @@ -46,11 +46,11 @@ resource "digitalocean_droplet" "controllers" { size = var.controller_type # network - vpc_uuid = digitalocean_vpc.network.id + vpc_uuid = digitalocean_vpc.network.id # TODO: Only official DigitalOcean images support IPv6 ipv6 = false - user_data = data.ct_config.controller-ignitions.*.rendered[count.index] + user_data = data.ct_config.controllers.*.rendered[count.index] ssh_keys = var.ssh_fingerprints tags = [ @@ -67,39 +67,20 @@ resource "digitalocean_tag" "controllers" { name = "${var.cluster_name}-controller" } -# Controller Ignition configs -data "ct_config" "controller-ignitions" { - count = var.controller_count - content = data.template_file.controller-configs.*.rendered[count.index] - strict = true - snippets = var.controller_snippets -} - -# Controller Container Linux configs -data "template_file" "controller-configs" { +# Flatcar Linux controllers +data "ct_config" "controllers" { count = var.controller_count - - template = file("${path.module}/cl/controller.yaml") - - vars = { + content = templatefile("${path.module}/cl/controller.yaml", { # Cannot use cyclic dependencies on controllers or their DNS records etcd_name = "etcd${count.index}" etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" # etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,... - etcd_initial_cluster = join(",", data.template_file.etcds.*.rendered) + etcd_initial_cluster = join(",", [ + for i in range(var.controller_count) : "etcd${i}=https://${var.cluster_name}-etcd${i}.${var.dns_zone}:2380" + ]) cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_domain_suffix = var.cluster_domain_suffix - } + }) + strict = true + snippets = var.controller_snippets } - -data "template_file" "etcds" { - count = var.controller_count - template = "etcd$${index}=https://$${cluster_name}-etcd$${index}.$${dns_zone}:2380" - - vars = { - index = count.index - cluster_name = var.cluster_name - dns_zone = var.dns_zone - } -} - diff --git a/digital-ocean/flatcar-linux/kubernetes/versions.tf b/digital-ocean/flatcar-linux/kubernetes/versions.tf index 925b7408..0e6823f5 100644 --- a/digital-ocean/flatcar-linux/kubernetes/versions.tf +++ b/digital-ocean/flatcar-linux/kubernetes/versions.tf @@ -3,14 +3,11 @@ terraform { required_version = ">= 0.13.0, < 2.0.0" required_providers { - template = "~> 2.2" - null = ">= 2.1" - + null = ">= 2.1" ct = { source = "poseidon/ct" version = "~> 0.9" } - digitalocean = { source = "digitalocean/digitalocean" version = ">= 2.12, < 3.0" diff --git a/digital-ocean/flatcar-linux/kubernetes/workers.tf b/digital-ocean/flatcar-linux/kubernetes/workers.tf index e6405b9e..cdf2919a 100644 --- a/digital-ocean/flatcar-linux/kubernetes/workers.tf +++ b/digital-ocean/flatcar-linux/kubernetes/workers.tf @@ -35,11 +35,11 @@ resource "digitalocean_droplet" "workers" { size = var.worker_type # network - vpc_uuid = digitalocean_vpc.network.id + vpc_uuid = digitalocean_vpc.network.id # only official DigitalOcean images support IPv6 ipv6 = local.is_official_image - user_data = data.ct_config.worker-ignition.rendered + user_data = data.ct_config.worker.rendered ssh_keys = var.ssh_fingerprints tags = [ @@ -56,20 +56,12 @@ resource "digitalocean_tag" "workers" { name = "${var.cluster_name}-worker" } -# Worker Ignition config -data "ct_config" "worker-ignition" { - content = data.template_file.worker-config.rendered +# Flatcar Linux worker +data "ct_config" "worker" { + content = templatefile("${path.module}/cl/worker.yaml", { + cluster_dns_service_ip = cidrhost(var.service_cidr, 10) + cluster_domain_suffix = var.cluster_domain_suffix + }) strict = true snippets = var.worker_snippets } - -# Worker Container Linux config -data "template_file" "worker-config" { - template = file("${path.module}/cl/worker.yaml") - - vars = { - cluster_dns_service_ip = cidrhost(var.service_cidr, 10) - cluster_domain_suffix = var.cluster_domain_suffix - } -} - diff --git a/google-cloud/fedora-coreos/kubernetes/controllers.tf b/google-cloud/fedora-coreos/kubernetes/controllers.tf index cbf1b7f8..fd28b1eb 100644 --- a/google-cloud/fedora-coreos/kubernetes/controllers.tf +++ b/google-cloud/fedora-coreos/kubernetes/controllers.tf @@ -35,7 +35,7 @@ resource "google_compute_instance" "controllers" { machine_type = var.controller_type metadata = { - user-data = data.ct_config.controller-ignitions.*.rendered[count.index] + user-data = data.ct_config.controllers.*.rendered[count.index] } boot_disk { @@ -66,41 +66,22 @@ resource "google_compute_instance" "controllers" { } } -# Controller Ignition configs -data "ct_config" "controller-ignitions" { - count = var.controller_count - content = data.template_file.controller-configs.*.rendered[count.index] - strict = true - snippets = var.controller_snippets -} - -# Controller Fedora CoreOS configs -data "template_file" "controller-configs" { +# Fedora CoreOS controllers +data "ct_config" "controllers" { count = var.controller_count - - template = file("${path.module}/fcc/controller.yaml") - - vars = { + content = templatefile("${path.module}/fcc/controller.yaml", { # Cannot use cyclic dependencies on controllers or their DNS records etcd_name = "etcd${count.index}" etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" # etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,... - etcd_initial_cluster = join(",", data.template_file.etcds.*.rendered) + etcd_initial_cluster = join(",", [ + for i in range(var.controller_count) : "etcd${i}=https://${var.cluster_name}-etcd${i}.${var.dns_zone}:2380" + ]) kubeconfig = indent(10, module.bootstrap.kubeconfig-kubelet) ssh_authorized_key = var.ssh_authorized_key cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_domain_suffix = var.cluster_domain_suffix - } + }) + strict = true + snippets = var.controller_snippets } - -data "template_file" "etcds" { - count = var.controller_count - template = "etcd$${index}=https://$${cluster_name}-etcd$${index}.$${dns_zone}:2380" - - vars = { - index = count.index - cluster_name = var.cluster_name - dns_zone = var.dns_zone - } -} - diff --git a/google-cloud/fedora-coreos/kubernetes/versions.tf b/google-cloud/fedora-coreos/kubernetes/versions.tf index a04cdc4d..19e7f81c 100644 --- a/google-cloud/fedora-coreos/kubernetes/versions.tf +++ b/google-cloud/fedora-coreos/kubernetes/versions.tf @@ -3,10 +3,8 @@ terraform { required_version = ">= 0.13.0, < 2.0.0" required_providers { - google = ">= 2.19, < 5.0" - template = "~> 2.2" - null = ">= 2.1" - + google = ">= 2.19, < 5.0" + null = ">= 2.1" ct = { source = "poseidon/ct" version = "~> 0.9" diff --git a/google-cloud/fedora-coreos/kubernetes/workers/versions.tf b/google-cloud/fedora-coreos/kubernetes/workers/versions.tf index d388e1af..791cb6d5 100644 --- a/google-cloud/fedora-coreos/kubernetes/workers/versions.tf +++ b/google-cloud/fedora-coreos/kubernetes/workers/versions.tf @@ -3,9 +3,7 @@ terraform { required_version = ">= 0.13.0, < 2.0.0" required_providers { - google = ">= 2.19, < 5.0" - template = "~> 2.2" - + google = ">= 2.19, < 5.0" ct = { source = "poseidon/ct" version = "~> 0.9" diff --git a/google-cloud/fedora-coreos/kubernetes/workers/workers.tf b/google-cloud/fedora-coreos/kubernetes/workers/workers.tf index 21ebd456..ce75cd5f 100644 --- a/google-cloud/fedora-coreos/kubernetes/workers/workers.tf +++ b/google-cloud/fedora-coreos/kubernetes/workers/workers.tf @@ -32,7 +32,7 @@ resource "google_compute_instance_template" "worker" { machine_type = var.machine_type metadata = { - user-data = data.ct_config.worker-ignition.rendered + user-data = data.ct_config.worker.rendered } scheduling { @@ -72,24 +72,16 @@ resource "google_compute_instance_template" "worker" { } } -# Worker Ignition config -data "ct_config" "worker-ignition" { - content = data.template_file.worker-config.rendered - strict = true - snippets = var.snippets -} - -# Worker Fedora CoreOS config -data "template_file" "worker-config" { - template = file("${path.module}/fcc/worker.yaml") - - vars = { +# Fedora CoreOS worker +data "ct_config" "worker" { + content = templatefile("${path.module}/fcc/worker.yaml", { kubeconfig = indent(10, var.kubeconfig) ssh_authorized_key = var.ssh_authorized_key cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_domain_suffix = var.cluster_domain_suffix node_labels = join(",", var.node_labels) node_taints = join(",", var.node_taints) - } + }) + strict = true + snippets = var.snippets } - diff --git a/google-cloud/flatcar-linux/kubernetes/controllers.tf b/google-cloud/flatcar-linux/kubernetes/controllers.tf index 76fbe66e..8912c9ab 100644 --- a/google-cloud/flatcar-linux/kubernetes/controllers.tf +++ b/google-cloud/flatcar-linux/kubernetes/controllers.tf @@ -35,7 +35,7 @@ resource "google_compute_instance" "controllers" { machine_type = var.controller_type metadata = { - user-data = data.ct_config.controller-ignitions.*.rendered[count.index] + user-data = data.ct_config.controllers.*.rendered[count.index] } boot_disk { @@ -66,41 +66,22 @@ resource "google_compute_instance" "controllers" { } } -# Controller Ignition configs -data "ct_config" "controller-ignitions" { - count = var.controller_count - content = data.template_file.controller-configs.*.rendered[count.index] - strict = true - snippets = var.controller_snippets -} - -# Controller Container Linux configs -data "template_file" "controller-configs" { +# Flatcar Linux controllers +data "ct_config" "controllers" { count = var.controller_count - - template = file("${path.module}/cl/controller.yaml") - - vars = { + content = templatefile("${path.module}/cl/controller.yaml", { # Cannot use cyclic dependencies on controllers or their DNS records etcd_name = "etcd${count.index}" etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" # etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,... - etcd_initial_cluster = join(",", data.template_file.etcds.*.rendered) + etcd_initial_cluster = join(",", [ + for i in range(var.controller_count) : "etcd${i}=https://${var.cluster_name}-etcd${i}.${var.dns_zone}:2380" + ]) kubeconfig = indent(10, module.bootstrap.kubeconfig-kubelet) ssh_authorized_key = var.ssh_authorized_key cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_domain_suffix = var.cluster_domain_suffix - } + }) + strict = true + snippets = var.controller_snippets } - -data "template_file" "etcds" { - count = var.controller_count - template = "etcd$${index}=https://$${cluster_name}-etcd$${index}.$${dns_zone}:2380" - - vars = { - index = count.index - cluster_name = var.cluster_name - dns_zone = var.dns_zone - } -} - diff --git a/google-cloud/flatcar-linux/kubernetes/image.tf b/google-cloud/flatcar-linux/kubernetes/image.tf index 6d78d4a4..57d67b08 100644 --- a/google-cloud/flatcar-linux/kubernetes/image.tf +++ b/google-cloud/flatcar-linux/kubernetes/image.tf @@ -1,6 +1,6 @@ # Flatcar Linux most recent image from channel data "google_compute_image" "flatcar-linux" { project = "kinvolk-public" - family = "${var.os_image}" + family = var.os_image } diff --git a/google-cloud/flatcar-linux/kubernetes/versions.tf b/google-cloud/flatcar-linux/kubernetes/versions.tf index a04cdc4d..19e7f81c 100644 --- a/google-cloud/flatcar-linux/kubernetes/versions.tf +++ b/google-cloud/flatcar-linux/kubernetes/versions.tf @@ -3,10 +3,8 @@ terraform { required_version = ">= 0.13.0, < 2.0.0" required_providers { - google = ">= 2.19, < 5.0" - template = "~> 2.2" - null = ">= 2.1" - + google = ">= 2.19, < 5.0" + null = ">= 2.1" ct = { source = "poseidon/ct" version = "~> 0.9" diff --git a/google-cloud/flatcar-linux/kubernetes/workers/image.tf b/google-cloud/flatcar-linux/kubernetes/workers/image.tf index e8c45940..d6c08969 100644 --- a/google-cloud/flatcar-linux/kubernetes/workers/image.tf +++ b/google-cloud/flatcar-linux/kubernetes/workers/image.tf @@ -1,5 +1,5 @@ # Flatcar Linux most recent image from channel data "google_compute_image" "flatcar-linux" { project = "kinvolk-public" - family = "${var.os_image}" + family = var.os_image } diff --git a/google-cloud/flatcar-linux/kubernetes/workers/versions.tf b/google-cloud/flatcar-linux/kubernetes/workers/versions.tf index d388e1af..791cb6d5 100644 --- a/google-cloud/flatcar-linux/kubernetes/workers/versions.tf +++ b/google-cloud/flatcar-linux/kubernetes/workers/versions.tf @@ -3,9 +3,7 @@ terraform { required_version = ">= 0.13.0, < 2.0.0" required_providers { - google = ">= 2.19, < 5.0" - template = "~> 2.2" - + google = ">= 2.19, < 5.0" ct = { source = "poseidon/ct" version = "~> 0.9" diff --git a/google-cloud/flatcar-linux/kubernetes/workers/workers.tf b/google-cloud/flatcar-linux/kubernetes/workers/workers.tf index 2dbcd989..360b2e24 100644 --- a/google-cloud/flatcar-linux/kubernetes/workers/workers.tf +++ b/google-cloud/flatcar-linux/kubernetes/workers/workers.tf @@ -32,7 +32,7 @@ resource "google_compute_instance_template" "worker" { machine_type = var.machine_type metadata = { - user-data = data.ct_config.worker-ignition.rendered + user-data = data.ct_config.worker.rendered } scheduling { @@ -69,24 +69,16 @@ resource "google_compute_instance_template" "worker" { } } -# Worker Ignition config -data "ct_config" "worker-ignition" { - content = data.template_file.worker-config.rendered - strict = true - snippets = var.snippets -} - -# Worker Container Linux config -data "template_file" "worker-config" { - template = file("${path.module}/cl/worker.yaml") - - vars = { +# Flatcar Linux worker +data "ct_config" "worker" { + content = templatefile("${path.module}/cl/worker.yaml", { kubeconfig = indent(10, var.kubeconfig) ssh_authorized_key = var.ssh_authorized_key cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_domain_suffix = var.cluster_domain_suffix node_labels = join(",", var.node_labels) node_taints = join(",", var.node_taints) - } + }) + strict = true + snippets = var.snippets } -