From 6a581ab5779a999c8575c30b46f0868b0a52cfaf Mon Sep 17 00:00:00 2001 From: Ben Drucker Date: Mon, 21 May 2018 16:15:54 -0700 Subject: [PATCH] Render etcd_initial_cluster using a template_file --- aws/container-linux/kubernetes/controllers.tf | 16 ++++++++-------- aws/fedora-atomic/kubernetes/controllers.tf | 16 ++++++++-------- .../container-linux/kubernetes/controllers.tf | 16 ++++++++-------- .../fedora-atomic/kubernetes/controllers.tf | 16 ++++++++-------- .../container-linux/kubernetes/controllers.tf | 16 ++++++++-------- .../fedora-atomic/kubernetes/controllers.tf | 16 ++++++++-------- 6 files changed, 48 insertions(+), 48 deletions(-) diff --git a/aws/container-linux/kubernetes/controllers.tf b/aws/container-linux/kubernetes/controllers.tf index c08be944..6a8b4e01 100644 --- a/aws/container-linux/kubernetes/controllers.tf +++ b/aws/container-linux/kubernetes/controllers.tf @@ -54,7 +54,7 @@ data "template_file" "controller_config" { 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(",", formatlist("%s=https://%s:2380", null_resource.repeat.*.triggers.name, null_resource.repeat.*.triggers.domain))}" + etcd_initial_cluster = "${join(",", data.template_file.etcds.*.rendered)}" kubeconfig = "${indent(10, module.bootkube.kubeconfig)}" ssh_authorized_key = "${var.ssh_authorized_key}" @@ -63,14 +63,14 @@ data "template_file" "controller_config" { } } -# Horrible hack to generate a Terraform list of a desired length without dependencies. -# Ideal ${repeat("etcd", 3) -> ["etcd", "etcd", "etcd"]} -resource null_resource "repeat" { - count = "${var.controller_count}" +data "template_file" "etcds" { + count = "${var.controller_count}" + template = "etcd$${index}=https://$${cluster_name}-etcd$${index}.$${dns_zone}:2380" - triggers { - name = "etcd${count.index}" - domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" + vars { + index = "${count.index}" + cluster_name = "${var.cluster_name}" + dns_zone = "${var.dns_zone}" } } diff --git a/aws/fedora-atomic/kubernetes/controllers.tf b/aws/fedora-atomic/kubernetes/controllers.tf index 875d44a0..d8ed8e06 100644 --- a/aws/fedora-atomic/kubernetes/controllers.tf +++ b/aws/fedora-atomic/kubernetes/controllers.tf @@ -54,7 +54,7 @@ data "template_file" "controller-cloudinit" { 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(",", formatlist("%s=https://%s:2380", null_resource.repeat.*.triggers.name, null_resource.repeat.*.triggers.domain))}" + etcd_initial_cluster = "${join(",", data.template_file.etcds.*.rendered)}" kubeconfig = "${indent(6, module.bootkube.kubeconfig)}" ssh_authorized_key = "${var.ssh_authorized_key}" @@ -63,13 +63,13 @@ data "template_file" "controller-cloudinit" { } } -# Horrible hack to generate a Terraform list of a desired length without dependencies. -# Ideal ${repeat("etcd", 3) -> ["etcd", "etcd", "etcd"]} -resource null_resource "repeat" { - count = "${var.controller_count}" +data "template_file" "etcds" { + count = "${var.controller_count}" + template = "etcd$${index}=https://$${cluster_name}-etcd$${index}.$${dns_zone}:2380" - triggers { - name = "etcd${count.index}" - domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" + vars { + index = "${count.index}" + cluster_name = "${var.cluster_name}" + dns_zone = "${var.dns_zone}" } } diff --git a/digital-ocean/container-linux/kubernetes/controllers.tf b/digital-ocean/container-linux/kubernetes/controllers.tf index 03014da7..ae223610 100644 --- a/digital-ocean/container-linux/kubernetes/controllers.tf +++ b/digital-ocean/container-linux/kubernetes/controllers.tf @@ -69,20 +69,20 @@ data "template_file" "controller_config" { 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(",", formatlist("%s=https://%s:2380", null_resource.repeat.*.triggers.name, null_resource.repeat.*.triggers.domain))}" + etcd_initial_cluster = "${join(",", data.template_file.etcds.*.rendered)}" k8s_dns_service_ip = "${cidrhost(var.service_cidr, 10)}" cluster_domain_suffix = "${var.cluster_domain_suffix}" } } -# Horrible hack to generate a Terraform list of a desired length without dependencies. -# Ideal ${repeat("etcd", 3) -> ["etcd", "etcd", "etcd"]} -resource null_resource "repeat" { - count = "${var.controller_count}" +data "template_file" "etcds" { + count = "${var.controller_count}" + template = "etcd$${index}=https://$${cluster_name}-etcd$${index}.$${dns_zone}:2380" - triggers { - name = "etcd${count.index}" - domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" + vars { + index = "${count.index}" + cluster_name = "${var.cluster_name}" + dns_zone = "${var.dns_zone}" } } diff --git a/digital-ocean/fedora-atomic/kubernetes/controllers.tf b/digital-ocean/fedora-atomic/kubernetes/controllers.tf index 0afc0edc..50e7fecc 100644 --- a/digital-ocean/fedora-atomic/kubernetes/controllers.tf +++ b/digital-ocean/fedora-atomic/kubernetes/controllers.tf @@ -69,7 +69,7 @@ data "template_file" "controller-cloudinit" { 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(",", formatlist("%s=https://%s:2380", null_resource.repeat.*.triggers.name, null_resource.repeat.*.triggers.domain))}" + etcd_initial_cluster = "${join(",", data.template_file.etcds.*.rendered)}" ssh_authorized_key = "${var.ssh_authorized_key}" k8s_dns_service_ip = "${cidrhost(var.service_cidr, 10)}" @@ -77,13 +77,13 @@ data "template_file" "controller-cloudinit" { } } -# Horrible hack to generate a Terraform list of a desired length without dependencies. -# Ideal ${repeat("etcd", 3) -> ["etcd", "etcd", "etcd"]} -resource null_resource "repeat" { - count = "${var.controller_count}" +data "template_file" "etcds" { + count = "${var.controller_count}" + template = "etcd$${index}=https://$${cluster_name}-etcd$${index}.$${dns_zone}:2380" - triggers { - name = "etcd${count.index}" - domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" + vars { + index = "${count.index}" + cluster_name = "${var.cluster_name}" + dns_zone = "${var.dns_zone}" } } diff --git a/google-cloud/container-linux/kubernetes/controllers.tf b/google-cloud/container-linux/kubernetes/controllers.tf index a3d28c79..036e4fb9 100644 --- a/google-cloud/container-linux/kubernetes/controllers.tf +++ b/google-cloud/container-linux/kubernetes/controllers.tf @@ -71,7 +71,7 @@ data "template_file" "controller_config" { 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(",", formatlist("%s=https://%s:2380", null_resource.repeat.*.triggers.name, null_resource.repeat.*.triggers.domain))}" + etcd_initial_cluster = "${join(",", data.template_file.etcds.*.rendered)}" kubeconfig = "${indent(10, module.bootkube.kubeconfig)}" ssh_authorized_key = "${var.ssh_authorized_key}" @@ -80,14 +80,14 @@ data "template_file" "controller_config" { } } -# Horrible hack to generate a Terraform list of a desired length without dependencies. -# Ideal ${repeat("etcd", 3) -> ["etcd", "etcd", "etcd"]} -resource null_resource "repeat" { - count = "${var.controller_count}" +data "template_file" "etcds" { + count = "${var.controller_count}" + template = "etcd$${index}=https://$${cluster_name}-etcd$${index}.$${dns_zone}:2380" - triggers { - name = "etcd${count.index}" - domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" + vars { + index = "${count.index}" + cluster_name = "${var.cluster_name}" + dns_zone = "${var.dns_zone}" } } diff --git a/google-cloud/fedora-atomic/kubernetes/controllers.tf b/google-cloud/fedora-atomic/kubernetes/controllers.tf index fe1f596d..ad86345f 100644 --- a/google-cloud/fedora-atomic/kubernetes/controllers.tf +++ b/google-cloud/fedora-atomic/kubernetes/controllers.tf @@ -71,7 +71,7 @@ data "template_file" "controller-cloudinit" { 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(",", formatlist("%s=https://%s:2380", null_resource.repeat.*.triggers.name, null_resource.repeat.*.triggers.domain))}" + etcd_initial_cluster = "${join(",", data.template_file.etcds.*.rendered)}" kubeconfig = "${indent(6, module.bootkube.kubeconfig)}" ssh_authorized_key = "${var.ssh_authorized_key}" @@ -80,13 +80,13 @@ data "template_file" "controller-cloudinit" { } } -# Horrible hack to generate a Terraform list of a desired length without dependencies. -# Ideal ${repeat("etcd", 3) -> ["etcd", "etcd", "etcd"]} -resource null_resource "repeat" { - count = "${var.controller_count}" +data "template_file" "etcds" { + count = "${var.controller_count}" + template = "etcd$${index}=https://$${cluster_name}-etcd$${index}.$${dns_zone}:2380" - triggers { - name = "etcd${count.index}" - domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}" + vars { + index = "${count.index}" + cluster_name = "${var.cluster_name}" + dns_zone = "${var.dns_zone}" } }