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
This commit is contained in:
Dalton Hubble 2022-08-02 18:15:03 -07:00
parent ca6eef365f
commit 256b87812e
37 changed files with 195 additions and 474 deletions

View File

@ -5,6 +5,7 @@ Notable changes between versions.
## Latest ## Latest
* Update Calico from v3.23.1 to [v3.23.3](https://github.com/projectcalico/calico/releases/tag/v3.23.3) * 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 ## v1.24.3

View File

@ -23,7 +23,7 @@ resource "aws_instance" "controllers" {
instance_type = var.controller_type 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 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 # storage
root_block_device { root_block_device {
@ -46,41 +46,22 @@ resource "aws_instance" "controllers" {
} }
} }
# Controller Ignition configs # Fedora CoreOS controllers
data "ct_config" "controller-ignitions" { data "ct_config" "controllers" {
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" {
count = var.controller_count count = var.controller_count
content = templatefile("${path.module}/fcc/controller.yaml", {
template = file("${path.module}/fcc/controller.yaml")
vars = {
# Cannot use cyclic dependencies on controllers or their DNS records # Cannot use cyclic dependencies on controllers or their DNS records
etcd_name = "etcd${count.index}" etcd_name = "etcd${count.index}"
etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}"
# etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,... # 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) kubeconfig = indent(10, module.bootstrap.kubeconfig-kubelet)
ssh_authorized_key = var.ssh_authorized_key ssh_authorized_key = var.ssh_authorized_key
cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_dns_service_ip = cidrhost(var.service_cidr, 10)
cluster_domain_suffix = var.cluster_domain_suffix 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
}
}

View File

@ -3,10 +3,8 @@
terraform { terraform {
required_version = ">= 0.13.0, < 2.0.0" required_version = ">= 0.13.0, < 2.0.0"
required_providers { required_providers {
aws = ">= 2.23, <= 5.0" aws = ">= 2.23, <= 5.0"
template = "~> 2.2" null = ">= 2.1"
null = ">= 2.1"
ct = { ct = {
source = "poseidon/ct" source = "poseidon/ct"
version = "~> 0.9" version = "~> 0.9"

View File

@ -3,9 +3,7 @@
terraform { terraform {
required_version = ">= 0.13.0, < 2.0.0" required_version = ">= 0.13.0, < 2.0.0"
required_providers { required_providers {
aws = ">= 2.23, <= 5.0" aws = ">= 2.23, <= 5.0"
template = "~> 2.2"
ct = { ct = {
source = "poseidon/ct" source = "poseidon/ct"
version = "~> 0.9" version = "~> 0.9"

View File

@ -47,7 +47,7 @@ resource "aws_launch_configuration" "worker" {
spot_price = var.spot_price > 0 ? var.spot_price : null spot_price = var.spot_price > 0 ? var.spot_price : null
enable_monitoring = false enable_monitoring = false
user_data = data.ct_config.worker-ignition.rendered user_data = data.ct_config.worker.rendered
# storage # storage
root_block_device { root_block_device {
@ -67,24 +67,16 @@ resource "aws_launch_configuration" "worker" {
} }
} }
# Worker Ignition config # Fedora CoreOS worker
data "ct_config" "worker-ignition" { data "ct_config" "worker" {
content = data.template_file.worker-config.rendered content = templatefile("${path.module}/fcc/worker.yaml", {
strict = true
snippets = var.snippets
}
# Worker Fedora CoreOS config
data "template_file" "worker-config" {
template = file("${path.module}/fcc/worker.yaml")
vars = {
kubeconfig = indent(10, var.kubeconfig) kubeconfig = indent(10, var.kubeconfig)
ssh_authorized_key = var.ssh_authorized_key ssh_authorized_key = var.ssh_authorized_key
cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_dns_service_ip = cidrhost(var.service_cidr, 10)
cluster_domain_suffix = var.cluster_domain_suffix cluster_domain_suffix = var.cluster_domain_suffix
node_labels = join(",", var.node_labels) node_labels = join(",", var.node_labels)
node_taints = join(",", var.node_taints) node_taints = join(",", var.node_taints)
} })
strict = true
snippets = var.snippets
} }

View File

@ -24,7 +24,7 @@ resource "aws_instance" "controllers" {
instance_type = var.controller_type instance_type = var.controller_type
ami = local.ami_id ami = local.ami_id
user_data = data.ct_config.controller-ignitions.*.rendered[count.index] user_data = data.ct_config.controllers.*.rendered[count.index]
# storage # storage
root_block_device { root_block_device {
@ -47,41 +47,22 @@ resource "aws_instance" "controllers" {
} }
} }
# Controller Ignition configs # Flatcar Linux controllers
data "ct_config" "controller-ignitions" { data "ct_config" "controllers" {
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" {
count = var.controller_count count = var.controller_count
content = templatefile("${path.module}/cl/controller.yaml", {
template = file("${path.module}/cl/controller.yaml")
vars = {
# Cannot use cyclic dependencies on controllers or their DNS records # Cannot use cyclic dependencies on controllers or their DNS records
etcd_name = "etcd${count.index}" etcd_name = "etcd${count.index}"
etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}"
# etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,... # 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) kubeconfig = indent(10, module.bootstrap.kubeconfig-kubelet)
ssh_authorized_key = var.ssh_authorized_key ssh_authorized_key = var.ssh_authorized_key
cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_dns_service_ip = cidrhost(var.service_cidr, 10)
cluster_domain_suffix = var.cluster_domain_suffix 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
}
}

View File

@ -3,10 +3,8 @@
terraform { terraform {
required_version = ">= 0.13.0, < 2.0.0" required_version = ">= 0.13.0, < 2.0.0"
required_providers { required_providers {
aws = ">= 2.23, <= 5.0" aws = ">= 2.23, <= 5.0"
template = "~> 2.2" null = ">= 2.1"
null = ">= 2.1"
ct = { ct = {
source = "poseidon/ct" source = "poseidon/ct"
version = "~> 0.9" version = "~> 0.9"

View File

@ -3,9 +3,7 @@
terraform { terraform {
required_version = ">= 0.13.0, < 2.0.0" required_version = ">= 0.13.0, < 2.0.0"
required_providers { required_providers {
aws = ">= 2.23, <= 5.0" aws = ">= 2.23, <= 5.0"
template = "~> 2.2"
ct = { ct = {
source = "poseidon/ct" source = "poseidon/ct"
version = "~> 0.9" version = "~> 0.9"

View File

@ -47,7 +47,7 @@ resource "aws_launch_configuration" "worker" {
spot_price = var.spot_price > 0 ? var.spot_price : null spot_price = var.spot_price > 0 ? var.spot_price : null
enable_monitoring = false enable_monitoring = false
user_data = data.ct_config.worker-ignition.rendered user_data = data.ct_config.worker.rendered
# storage # storage
root_block_device { root_block_device {
@ -67,24 +67,16 @@ resource "aws_launch_configuration" "worker" {
} }
} }
# Worker Ignition config # Flatcar Linux worker
data "ct_config" "worker-ignition" { data "ct_config" "worker" {
content = data.template_file.worker-config.rendered content = templatefile("${path.module}/cl/worker.yaml", {
strict = true
snippets = var.snippets
}
# Worker Container Linux config
data "template_file" "worker-config" {
template = file("${path.module}/cl/worker.yaml")
vars = {
kubeconfig = indent(10, var.kubeconfig) kubeconfig = indent(10, var.kubeconfig)
ssh_authorized_key = var.ssh_authorized_key ssh_authorized_key = var.ssh_authorized_key
cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_dns_service_ip = cidrhost(var.service_cidr, 10)
cluster_domain_suffix = var.cluster_domain_suffix cluster_domain_suffix = var.cluster_domain_suffix
node_labels = join(",", var.node_labels) node_labels = join(",", var.node_labels)
node_taints = join(",", var.node_taints) node_taints = join(",", var.node_taints)
} })
strict = true
snippets = var.snippets
} }

View File

@ -35,7 +35,7 @@ resource "azurerm_linux_virtual_machine" "controllers" {
availability_set_id = azurerm_availability_set.controllers.id availability_set_id = azurerm_availability_set.controllers.id
size = var.controller_type 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 # storage
source_image_id = var.os_image 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 backend_address_pool_id = azurerm_lb_backend_address_pool.controller.id
} }
# Controller Ignition configs # Fedora CoreOS controllers
data "ct_config" "controller-ignitions" { data "ct_config" "controllers" {
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" {
count = var.controller_count count = var.controller_count
content = templatefile("${path.module}/fcc/controller.yaml", {
template = file("${path.module}/fcc/controller.yaml")
vars = {
# Cannot use cyclic dependencies on controllers or their DNS records # Cannot use cyclic dependencies on controllers or their DNS records
etcd_name = "etcd${count.index}" etcd_name = "etcd${count.index}"
etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}"
# etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,... # 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) kubeconfig = indent(10, module.bootstrap.kubeconfig-kubelet)
ssh_authorized_key = var.ssh_authorized_key ssh_authorized_key = var.ssh_authorized_key
cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_dns_service_ip = cidrhost(var.service_cidr, 10)
cluster_domain_suffix = var.cluster_domain_suffix 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
}
}

View File

@ -3,10 +3,8 @@
terraform { terraform {
required_version = ">= 0.13.0, < 2.0.0" required_version = ">= 0.13.0, < 2.0.0"
required_providers { required_providers {
azurerm = ">= 2.8, < 4.0" azurerm = ">= 2.8, < 4.0"
template = "~> 2.2" null = ">= 2.1"
null = ">= 2.1"
ct = { ct = {
source = "poseidon/ct" source = "poseidon/ct"
version = "~> 0.9" version = "~> 0.9"

View File

@ -3,9 +3,7 @@
terraform { terraform {
required_version = ">= 0.13.0, < 2.0.0" required_version = ">= 0.13.0, < 2.0.0"
required_providers { required_providers {
azurerm = ">= 2.8, < 4.0" azurerm = ">= 2.8, < 4.0"
template = "~> 2.2"
ct = { ct = {
source = "poseidon/ct" source = "poseidon/ct"
version = "~> 0.9" version = "~> 0.9"

View File

@ -9,7 +9,7 @@ resource "azurerm_linux_virtual_machine_scale_set" "workers" {
# instance name prefix for instances in the set # instance name prefix for instances in the set
computer_name_prefix = "${var.name}-worker" computer_name_prefix = "${var.name}-worker"
single_placement_group = false single_placement_group = false
custom_data = base64encode(data.ct_config.worker-ignition.rendered) custom_data = base64encode(data.ct_config.worker.rendered)
# storage # storage
source_image_id = var.os_image source_image_id = var.os_image
@ -70,24 +70,17 @@ resource "azurerm_monitor_autoscale_setting" "workers" {
} }
} }
# Worker Ignition configs # Fedora CoreOS worker
data "ct_config" "worker-ignition" { data "ct_config" "worker" {
content = data.template_file.worker-config.rendered content = templatefile("${path.module}/fcc/worker.yaml", {
strict = true
snippets = var.snippets
}
# Worker Fedora CoreOS configs
data "template_file" "worker-config" {
template = file("${path.module}/fcc/worker.yaml")
vars = {
kubeconfig = indent(10, var.kubeconfig) kubeconfig = indent(10, var.kubeconfig)
ssh_authorized_key = var.ssh_authorized_key ssh_authorized_key = var.ssh_authorized_key
cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_dns_service_ip = cidrhost(var.service_cidr, 10)
cluster_domain_suffix = var.cluster_domain_suffix cluster_domain_suffix = var.cluster_domain_suffix
node_labels = join(",", var.node_labels) node_labels = join(",", var.node_labels)
node_taints = join(",", var.node_taints) node_taints = join(",", var.node_taints)
} })
strict = true
snippets = var.snippets
} }

View File

@ -41,7 +41,7 @@ resource "azurerm_linux_virtual_machine" "controllers" {
availability_set_id = azurerm_availability_set.controllers.id availability_set_id = azurerm_availability_set.controllers.id
size = var.controller_type 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 # storage
os_disk { 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 backend_address_pool_id = azurerm_lb_backend_address_pool.controller.id
} }
# Controller Ignition configs # Flatcar Linux controllers
data "ct_config" "controller-ignitions" { data "ct_config" "controllers" {
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" {
count = var.controller_count count = var.controller_count
content = templatefile("${path.module}/cl/controller.yaml", {
template = file("${path.module}/cl/controller.yaml")
vars = {
# Cannot use cyclic dependencies on controllers or their DNS records # Cannot use cyclic dependencies on controllers or their DNS records
etcd_name = "etcd${count.index}" etcd_name = "etcd${count.index}"
etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}"
# etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,... # 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) kubeconfig = indent(10, module.bootstrap.kubeconfig-kubelet)
ssh_authorized_key = var.ssh_authorized_key ssh_authorized_key = var.ssh_authorized_key
cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_dns_service_ip = cidrhost(var.service_cidr, 10)
cluster_domain_suffix = var.cluster_domain_suffix 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
}
}

View File

@ -3,10 +3,8 @@
terraform { terraform {
required_version = ">= 0.13.0, < 2.0.0" required_version = ">= 0.13.0, < 2.0.0"
required_providers { required_providers {
azurerm = ">= 2.8, < 4.0" azurerm = ">= 2.8, < 4.0"
template = "~> 2.2" null = ">= 2.1"
null = ">= 2.1"
ct = { ct = {
source = "poseidon/ct" source = "poseidon/ct"
version = "~> 0.9" version = "~> 0.9"

View File

@ -3,9 +3,7 @@
terraform { terraform {
required_version = ">= 0.13.0, < 2.0.0" required_version = ">= 0.13.0, < 2.0.0"
required_providers { required_providers {
azurerm = ">= 2.8, < 4.0" azurerm = ">= 2.8, < 4.0"
template = "~> 2.2"
ct = { ct = {
source = "poseidon/ct" source = "poseidon/ct"
version = "~> 0.9" version = "~> 0.9"

View File

@ -14,7 +14,7 @@ resource "azurerm_linux_virtual_machine_scale_set" "workers" {
# instance name prefix for instances in the set # instance name prefix for instances in the set
computer_name_prefix = "${var.name}-worker" computer_name_prefix = "${var.name}-worker"
single_placement_group = false single_placement_group = false
custom_data = base64encode(data.ct_config.worker-ignition.rendered) custom_data = base64encode(data.ct_config.worker.rendered)
# storage # storage
os_disk { os_disk {
@ -88,24 +88,16 @@ resource "azurerm_monitor_autoscale_setting" "workers" {
} }
} }
# Worker Ignition configs # Flatcar Linux worker
data "ct_config" "worker-ignition" { data "ct_config" "worker" {
content = data.template_file.worker-config.rendered content = templatefile("${path.module}/cl/worker.yaml", {
strict = true
snippets = var.snippets
}
# Worker Container Linux configs
data "template_file" "worker-config" {
template = file("${path.module}/cl/worker.yaml")
vars = {
kubeconfig = indent(10, var.kubeconfig) kubeconfig = indent(10, var.kubeconfig)
ssh_authorized_key = var.ssh_authorized_key ssh_authorized_key = var.ssh_authorized_key
cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_dns_service_ip = cidrhost(var.service_cidr, 10)
cluster_domain_suffix = var.cluster_domain_suffix cluster_domain_suffix = var.cluster_domain_suffix
node_labels = join(",", var.node_labels) node_labels = join(",", var.node_labels)
node_taints = join(",", var.node_taints) node_taints = join(",", var.node_taints)
} })
strict = true
snippets = var.snippets
} }

View File

@ -38,29 +38,22 @@ resource "matchbox_profile" "controllers" {
initrd = local.initrd initrd = local.initrd
args = concat(local.args, var.kernel_args) 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" { # Fedora CoreOS controllers
count = length(var.controllers) data "ct_config" "controllers" {
count = var.controller_count
content = data.template_file.controller-configs.*.rendered[count.index] content = templatefile("${path.module}/fcc/controller.yaml", {
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 = {
domain_name = var.controllers.*.domain[count.index] domain_name = var.controllers.*.domain[count.index]
etcd_name = var.controllers.*.name[count.index] etcd_name = var.controllers.*.name[count.index]
etcd_initial_cluster = join(",", formatlist("%s=https://%s:2380", var.controllers.*.name, var.controllers.*.domain)) 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_dns_service_ip = module.bootstrap.cluster_dns_service_ip
cluster_domain_suffix = var.cluster_domain_suffix cluster_domain_suffix = var.cluster_domain_suffix
ssh_authorized_key = var.ssh_authorized_key ssh_authorized_key = var.ssh_authorized_key
} })
strict = true
snippets = lookup(var.snippets, var.controllers.*.name[count.index], [])
} }
// Fedora CoreOS worker profile // Fedora CoreOS worker profile
@ -72,28 +65,20 @@ resource "matchbox_profile" "workers" {
initrd = local.initrd initrd = local.initrd
args = concat(local.args, var.kernel_args) 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) count = length(var.workers)
content = templatefile("${path.module}/fcc/worker.yaml", {
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 = {
domain_name = var.workers.*.domain[count.index] domain_name = var.workers.*.domain[count.index]
cluster_dns_service_ip = module.bootstrap.cluster_dns_service_ip cluster_dns_service_ip = module.bootstrap.cluster_dns_service_ip
cluster_domain_suffix = var.cluster_domain_suffix cluster_domain_suffix = var.cluster_domain_suffix
ssh_authorized_key = var.ssh_authorized_key ssh_authorized_key = var.ssh_authorized_key
node_labels = join(",", lookup(var.worker_node_labels, var.workers.*.name[count.index], [])) 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], [])) node_taints = join(",", lookup(var.worker_node_taints, var.workers.*.name[count.index], []))
} })
strict = true
snippets = lookup(var.snippets, var.workers.*.name[count.index], [])
} }

View File

@ -3,14 +3,11 @@
terraform { terraform {
required_version = ">= 0.13.0, < 2.0.0" required_version = ">= 0.13.0, < 2.0.0"
required_providers { required_providers {
template = "~> 2.2" null = ">= 2.1"
null = ">= 2.1"
ct = { ct = {
source = "poseidon/ct" source = "poseidon/ct"
version = "~> 0.9" version = "~> 0.9"
} }
matchbox = { matchbox = {
source = "poseidon/matchbox" source = "poseidon/matchbox"
version = "~> 0.5.0" version = "~> 0.5.0"

View File

@ -83,56 +83,42 @@ data "template_file" "cached-install-configs" {
resource "matchbox_profile" "controllers" { resource "matchbox_profile" "controllers" {
count = length(var.controllers) count = length(var.controllers)
name = format("%s-controller-%s", var.cluster_name, var.controllers.*.name[count.index]) 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" { # Flatcar Linux controllers
count = length(var.controllers) data "ct_config" "controllers" {
content = data.template_file.controller-configs.*.rendered[count.index] count = var.controller_count
strict = true content = templatefile("${path.module}/cl/controller.yaml", {
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 = {
domain_name = var.controllers.*.domain[count.index] domain_name = var.controllers.*.domain[count.index]
etcd_name = var.controllers.*.name[count.index] etcd_name = var.controllers.*.name[count.index]
etcd_initial_cluster = join(",", formatlist("%s=https://%s:2380", var.controllers.*.name, var.controllers.*.domain)) 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_dns_service_ip = module.bootstrap.cluster_dns_service_ip
cluster_domain_suffix = var.cluster_domain_suffix cluster_domain_suffix = var.cluster_domain_suffix
ssh_authorized_key = var.ssh_authorized_key ssh_authorized_key = var.ssh_authorized_key
} })
strict = true
snippets = lookup(var.snippets, var.controllers.*.name[count.index], [])
} }
// Kubernetes Worker profiles // Kubernetes Worker profiles
resource "matchbox_profile" "workers" { resource "matchbox_profile" "workers" {
count = length(var.workers) count = length(var.workers)
name = format("%s-worker-%s", var.cluster_name, var.workers.*.name[count.index]) 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" { # Flatcar Linux workers
count = length(var.workers) data "ct_config" "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) count = length(var.workers)
content = templatefile("${path.module}/cl/worker.yaml", {
template = file("${path.module}/cl/worker.yaml")
vars = {
domain_name = var.workers.*.domain[count.index] domain_name = var.workers.*.domain[count.index]
cluster_dns_service_ip = module.bootstrap.cluster_dns_service_ip cluster_dns_service_ip = module.bootstrap.cluster_dns_service_ip
cluster_domain_suffix = var.cluster_domain_suffix cluster_domain_suffix = var.cluster_domain_suffix
ssh_authorized_key = var.ssh_authorized_key ssh_authorized_key = var.ssh_authorized_key
node_labels = join(",", lookup(var.worker_node_labels, var.workers.*.name[count.index], [])) 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], [])) node_taints = join(",", lookup(var.worker_node_taints, var.workers.*.name[count.index], []))
} })
strict = true
snippets = lookup(var.snippets, var.workers.*.name[count.index], [])
} }

View File

@ -3,14 +3,11 @@
terraform { terraform {
required_version = ">= 0.13.0, < 2.0.0" required_version = ">= 0.13.0, < 2.0.0"
required_providers { required_providers {
template = "~> 2.2" null = ">= 2.1"
null = ">= 2.1"
ct = { ct = {
source = "poseidon/ct" source = "poseidon/ct"
version = "~> 0.9" version = "~> 0.9"
} }
matchbox = { matchbox = {
source = "poseidon/matchbox" source = "poseidon/matchbox"
version = "~> 0.5.0" version = "~> 0.5.0"

View File

@ -41,11 +41,11 @@ resource "digitalocean_droplet" "controllers" {
size = var.controller_type size = var.controller_type
# network # network
vpc_uuid = digitalocean_vpc.network.id vpc_uuid = digitalocean_vpc.network.id
# TODO: Only official DigitalOcean images support IPv6 # TODO: Only official DigitalOcean images support IPv6
ipv6 = false 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 ssh_keys = var.ssh_fingerprints
tags = [ tags = [
@ -62,39 +62,20 @@ resource "digitalocean_tag" "controllers" {
name = "${var.cluster_name}-controller" name = "${var.cluster_name}-controller"
} }
# Controller Ignition configs # Fedora CoreOS controllers
data "ct_config" "controller-ignitions" { data "ct_config" "controllers" {
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" {
count = var.controller_count count = var.controller_count
content = templatefile("${path.module}/fcc/controller.yaml", {
template = file("${path.module}/fcc/controller.yaml")
vars = {
# Cannot use cyclic dependencies on controllers or their DNS records # Cannot use cyclic dependencies on controllers or their DNS records
etcd_name = "etcd${count.index}" etcd_name = "etcd${count.index}"
etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}"
# etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,... # 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_dns_service_ip = cidrhost(var.service_cidr, 10)
cluster_domain_suffix = var.cluster_domain_suffix 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
}
}

View File

@ -3,14 +3,11 @@
terraform { terraform {
required_version = ">= 0.13.0, < 2.0.0" required_version = ">= 0.13.0, < 2.0.0"
required_providers { required_providers {
template = "~> 2.2" null = ">= 2.1"
null = ">= 2.1"
ct = { ct = {
source = "poseidon/ct" source = "poseidon/ct"
version = "~> 0.9" version = "~> 0.9"
} }
digitalocean = { digitalocean = {
source = "digitalocean/digitalocean" source = "digitalocean/digitalocean"
version = ">= 2.12, < 3.0" version = ">= 2.12, < 3.0"

View File

@ -37,11 +37,11 @@ resource "digitalocean_droplet" "workers" {
size = var.worker_type size = var.worker_type
# network # network
vpc_uuid = digitalocean_vpc.network.id vpc_uuid = digitalocean_vpc.network.id
# TODO: Only official DigitalOcean images support IPv6 # TODO: Only official DigitalOcean images support IPv6
ipv6 = false ipv6 = false
user_data = data.ct_config.worker-ignition.rendered user_data = data.ct_config.worker.rendered
ssh_keys = var.ssh_fingerprints ssh_keys = var.ssh_fingerprints
tags = [ tags = [
@ -58,20 +58,12 @@ resource "digitalocean_tag" "workers" {
name = "${var.cluster_name}-worker" name = "${var.cluster_name}-worker"
} }
# Worker Ignition config # Fedora CoreOS worker
data "ct_config" "worker-ignition" { data "ct_config" "worker" {
content = data.template_file.worker-config.rendered 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 strict = true
snippets = var.worker_snippets 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
}
}

View File

@ -46,11 +46,11 @@ resource "digitalocean_droplet" "controllers" {
size = var.controller_type size = var.controller_type
# network # network
vpc_uuid = digitalocean_vpc.network.id vpc_uuid = digitalocean_vpc.network.id
# TODO: Only official DigitalOcean images support IPv6 # TODO: Only official DigitalOcean images support IPv6
ipv6 = false 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 ssh_keys = var.ssh_fingerprints
tags = [ tags = [
@ -67,39 +67,20 @@ resource "digitalocean_tag" "controllers" {
name = "${var.cluster_name}-controller" name = "${var.cluster_name}-controller"
} }
# Controller Ignition configs # Flatcar Linux controllers
data "ct_config" "controller-ignitions" { data "ct_config" "controllers" {
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" {
count = var.controller_count count = var.controller_count
content = templatefile("${path.module}/cl/controller.yaml", {
template = file("${path.module}/cl/controller.yaml")
vars = {
# Cannot use cyclic dependencies on controllers or their DNS records # Cannot use cyclic dependencies on controllers or their DNS records
etcd_name = "etcd${count.index}" etcd_name = "etcd${count.index}"
etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}"
# etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,... # 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_dns_service_ip = cidrhost(var.service_cidr, 10)
cluster_domain_suffix = var.cluster_domain_suffix 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
}
}

View File

@ -3,14 +3,11 @@
terraform { terraform {
required_version = ">= 0.13.0, < 2.0.0" required_version = ">= 0.13.0, < 2.0.0"
required_providers { required_providers {
template = "~> 2.2" null = ">= 2.1"
null = ">= 2.1"
ct = { ct = {
source = "poseidon/ct" source = "poseidon/ct"
version = "~> 0.9" version = "~> 0.9"
} }
digitalocean = { digitalocean = {
source = "digitalocean/digitalocean" source = "digitalocean/digitalocean"
version = ">= 2.12, < 3.0" version = ">= 2.12, < 3.0"

View File

@ -35,11 +35,11 @@ resource "digitalocean_droplet" "workers" {
size = var.worker_type size = var.worker_type
# network # network
vpc_uuid = digitalocean_vpc.network.id vpc_uuid = digitalocean_vpc.network.id
# only official DigitalOcean images support IPv6 # only official DigitalOcean images support IPv6
ipv6 = local.is_official_image 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 ssh_keys = var.ssh_fingerprints
tags = [ tags = [
@ -56,20 +56,12 @@ resource "digitalocean_tag" "workers" {
name = "${var.cluster_name}-worker" name = "${var.cluster_name}-worker"
} }
# Worker Ignition config # Flatcar Linux worker
data "ct_config" "worker-ignition" { data "ct_config" "worker" {
content = data.template_file.worker-config.rendered 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 strict = true
snippets = var.worker_snippets 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
}
}

View File

@ -35,7 +35,7 @@ resource "google_compute_instance" "controllers" {
machine_type = var.controller_type machine_type = var.controller_type
metadata = { metadata = {
user-data = data.ct_config.controller-ignitions.*.rendered[count.index] user-data = data.ct_config.controllers.*.rendered[count.index]
} }
boot_disk { boot_disk {
@ -66,41 +66,22 @@ resource "google_compute_instance" "controllers" {
} }
} }
# Controller Ignition configs # Fedora CoreOS controllers
data "ct_config" "controller-ignitions" { data "ct_config" "controllers" {
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" {
count = var.controller_count count = var.controller_count
content = templatefile("${path.module}/fcc/controller.yaml", {
template = file("${path.module}/fcc/controller.yaml")
vars = {
# Cannot use cyclic dependencies on controllers or their DNS records # Cannot use cyclic dependencies on controllers or their DNS records
etcd_name = "etcd${count.index}" etcd_name = "etcd${count.index}"
etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}"
# etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,... # 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) kubeconfig = indent(10, module.bootstrap.kubeconfig-kubelet)
ssh_authorized_key = var.ssh_authorized_key ssh_authorized_key = var.ssh_authorized_key
cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_dns_service_ip = cidrhost(var.service_cidr, 10)
cluster_domain_suffix = var.cluster_domain_suffix 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
}
}

View File

@ -3,10 +3,8 @@
terraform { terraform {
required_version = ">= 0.13.0, < 2.0.0" required_version = ">= 0.13.0, < 2.0.0"
required_providers { required_providers {
google = ">= 2.19, < 5.0" google = ">= 2.19, < 5.0"
template = "~> 2.2" null = ">= 2.1"
null = ">= 2.1"
ct = { ct = {
source = "poseidon/ct" source = "poseidon/ct"
version = "~> 0.9" version = "~> 0.9"

View File

@ -3,9 +3,7 @@
terraform { terraform {
required_version = ">= 0.13.0, < 2.0.0" required_version = ">= 0.13.0, < 2.0.0"
required_providers { required_providers {
google = ">= 2.19, < 5.0" google = ">= 2.19, < 5.0"
template = "~> 2.2"
ct = { ct = {
source = "poseidon/ct" source = "poseidon/ct"
version = "~> 0.9" version = "~> 0.9"

View File

@ -32,7 +32,7 @@ resource "google_compute_instance_template" "worker" {
machine_type = var.machine_type machine_type = var.machine_type
metadata = { metadata = {
user-data = data.ct_config.worker-ignition.rendered user-data = data.ct_config.worker.rendered
} }
scheduling { scheduling {
@ -72,24 +72,16 @@ resource "google_compute_instance_template" "worker" {
} }
} }
# Worker Ignition config # Fedora CoreOS worker
data "ct_config" "worker-ignition" { data "ct_config" "worker" {
content = data.template_file.worker-config.rendered content = templatefile("${path.module}/fcc/worker.yaml", {
strict = true
snippets = var.snippets
}
# Worker Fedora CoreOS config
data "template_file" "worker-config" {
template = file("${path.module}/fcc/worker.yaml")
vars = {
kubeconfig = indent(10, var.kubeconfig) kubeconfig = indent(10, var.kubeconfig)
ssh_authorized_key = var.ssh_authorized_key ssh_authorized_key = var.ssh_authorized_key
cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_dns_service_ip = cidrhost(var.service_cidr, 10)
cluster_domain_suffix = var.cluster_domain_suffix cluster_domain_suffix = var.cluster_domain_suffix
node_labels = join(",", var.node_labels) node_labels = join(",", var.node_labels)
node_taints = join(",", var.node_taints) node_taints = join(",", var.node_taints)
} })
strict = true
snippets = var.snippets
} }

View File

@ -35,7 +35,7 @@ resource "google_compute_instance" "controllers" {
machine_type = var.controller_type machine_type = var.controller_type
metadata = { metadata = {
user-data = data.ct_config.controller-ignitions.*.rendered[count.index] user-data = data.ct_config.controllers.*.rendered[count.index]
} }
boot_disk { boot_disk {
@ -66,41 +66,22 @@ resource "google_compute_instance" "controllers" {
} }
} }
# Controller Ignition configs # Flatcar Linux controllers
data "ct_config" "controller-ignitions" { data "ct_config" "controllers" {
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" {
count = var.controller_count count = var.controller_count
content = templatefile("${path.module}/cl/controller.yaml", {
template = file("${path.module}/cl/controller.yaml")
vars = {
# Cannot use cyclic dependencies on controllers or their DNS records # Cannot use cyclic dependencies on controllers or their DNS records
etcd_name = "etcd${count.index}" etcd_name = "etcd${count.index}"
etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}"
# etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,... # 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) kubeconfig = indent(10, module.bootstrap.kubeconfig-kubelet)
ssh_authorized_key = var.ssh_authorized_key ssh_authorized_key = var.ssh_authorized_key
cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_dns_service_ip = cidrhost(var.service_cidr, 10)
cluster_domain_suffix = var.cluster_domain_suffix 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
}
}

View File

@ -1,6 +1,6 @@
# Flatcar Linux most recent image from channel # Flatcar Linux most recent image from channel
data "google_compute_image" "flatcar-linux" { data "google_compute_image" "flatcar-linux" {
project = "kinvolk-public" project = "kinvolk-public"
family = "${var.os_image}" family = var.os_image
} }

View File

@ -3,10 +3,8 @@
terraform { terraform {
required_version = ">= 0.13.0, < 2.0.0" required_version = ">= 0.13.0, < 2.0.0"
required_providers { required_providers {
google = ">= 2.19, < 5.0" google = ">= 2.19, < 5.0"
template = "~> 2.2" null = ">= 2.1"
null = ">= 2.1"
ct = { ct = {
source = "poseidon/ct" source = "poseidon/ct"
version = "~> 0.9" version = "~> 0.9"

View File

@ -1,5 +1,5 @@
# Flatcar Linux most recent image from channel # Flatcar Linux most recent image from channel
data "google_compute_image" "flatcar-linux" { data "google_compute_image" "flatcar-linux" {
project = "kinvolk-public" project = "kinvolk-public"
family = "${var.os_image}" family = var.os_image
} }

View File

@ -3,9 +3,7 @@
terraform { terraform {
required_version = ">= 0.13.0, < 2.0.0" required_version = ">= 0.13.0, < 2.0.0"
required_providers { required_providers {
google = ">= 2.19, < 5.0" google = ">= 2.19, < 5.0"
template = "~> 2.2"
ct = { ct = {
source = "poseidon/ct" source = "poseidon/ct"
version = "~> 0.9" version = "~> 0.9"

View File

@ -32,7 +32,7 @@ resource "google_compute_instance_template" "worker" {
machine_type = var.machine_type machine_type = var.machine_type
metadata = { metadata = {
user-data = data.ct_config.worker-ignition.rendered user-data = data.ct_config.worker.rendered
} }
scheduling { scheduling {
@ -69,24 +69,16 @@ resource "google_compute_instance_template" "worker" {
} }
} }
# Worker Ignition config # Flatcar Linux worker
data "ct_config" "worker-ignition" { data "ct_config" "worker" {
content = data.template_file.worker-config.rendered content = templatefile("${path.module}/cl/worker.yaml", {
strict = true
snippets = var.snippets
}
# Worker Container Linux config
data "template_file" "worker-config" {
template = file("${path.module}/cl/worker.yaml")
vars = {
kubeconfig = indent(10, var.kubeconfig) kubeconfig = indent(10, var.kubeconfig)
ssh_authorized_key = var.ssh_authorized_key ssh_authorized_key = var.ssh_authorized_key
cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_dns_service_ip = cidrhost(var.service_cidr, 10)
cluster_domain_suffix = var.cluster_domain_suffix cluster_domain_suffix = var.cluster_domain_suffix
node_labels = join(",", var.node_labels) node_labels = join(",", var.node_labels)
node_taints = join(",", var.node_taints) node_taints = join(",", var.node_taints)
} })
strict = true
snippets = var.snippets
} }