mirror of
https://github.com/puppetmaster/typhoon.git
synced 2025-07-01 15:34:35 +02:00
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:
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user