Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Terraform template provider dependency #1194

Merged
merged 1 commit into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
39 changes: 10 additions & 29 deletions aws/fedora-coreos/kubernetes/controllers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}

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
}
})
strict = true
snippets = var.controller_snippets
}

6 changes: 2 additions & 4 deletions aws/fedora-coreos/kubernetes/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 1 addition & 3 deletions aws/fedora-coreos/kubernetes/workers/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 7 additions & 15 deletions aws/fedora-coreos/kubernetes/workers/workers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

39 changes: 10 additions & 29 deletions aws/flatcar-linux/kubernetes/controllers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}

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
}
})
strict = true
snippets = var.controller_snippets
}

6 changes: 2 additions & 4 deletions aws/flatcar-linux/kubernetes/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 1 addition & 3 deletions aws/flatcar-linux/kubernetes/workers/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 7 additions & 15 deletions aws/flatcar-linux/kubernetes/workers/workers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

39 changes: 10 additions & 29 deletions azure/fedora-coreos/kubernetes/controllers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}

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
}
})
strict = true
snippets = var.controller_snippets
}

6 changes: 2 additions & 4 deletions azure/fedora-coreos/kubernetes/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 1 addition & 3 deletions azure/fedora-coreos/kubernetes/workers/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
21 changes: 7 additions & 14 deletions azure/fedora-coreos/kubernetes/workers/workers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Loading