From 99ab81f79c600d747439a0646b181b5885be44ed Mon Sep 17 00:00:00 2001 From: Valer Cara Date: Sun, 29 Sep 2019 00:59:24 +0300 Subject: [PATCH] Add node_labels variable in workers modules to set initial node labels (#550) * Also add `worker_node_labels` variable in `kubernetes` modules to set initial node labels for the default workers --- aws/container-linux/kubernetes/variables.tf | 6 ++++++ aws/container-linux/kubernetes/workers.tf | 1 + aws/container-linux/kubernetes/workers/cl/worker.yaml.tmpl | 3 +++ aws/container-linux/kubernetes/workers/variables.tf | 5 +++++ aws/container-linux/kubernetes/workers/workers.tf | 1 + aws/fedora-coreos/kubernetes/variables.tf | 5 +++++ aws/fedora-coreos/kubernetes/workers.tf | 1 + aws/fedora-coreos/kubernetes/workers/fcc/worker.yaml | 3 +++ aws/fedora-coreos/kubernetes/workers/variables.tf | 5 +++++ aws/fedora-coreos/kubernetes/workers/workers.tf | 1 + azure/container-linux/kubernetes/variables.tf | 6 ++++++ azure/container-linux/kubernetes/workers.tf | 1 + .../container-linux/kubernetes/workers/cl/worker.yaml.tmpl | 3 +++ azure/container-linux/kubernetes/workers/variables.tf | 5 +++++ azure/container-linux/kubernetes/workers/workers.tf | 1 + google-cloud/container-linux/kubernetes/variables.tf | 6 ++++++ google-cloud/container-linux/kubernetes/workers.tf | 1 + .../container-linux/kubernetes/workers/cl/worker.yaml.tmpl | 3 +++ .../container-linux/kubernetes/workers/variables.tf | 6 ++++++ google-cloud/container-linux/kubernetes/workers/workers.tf | 1 + 20 files changed, 64 insertions(+) diff --git a/aws/container-linux/kubernetes/variables.tf b/aws/container-linux/kubernetes/variables.tf index 7005e63b..b76f3d54 100644 --- a/aws/container-linux/kubernetes/variables.tf +++ b/aws/container-linux/kubernetes/variables.tf @@ -154,3 +154,9 @@ variable "enable_aggregation" { default = "false" } +variable "worker_node_labels" { + description = "List of additional labels to add to worker nodes" + type = list + default = [] +} + diff --git a/aws/container-linux/kubernetes/workers.tf b/aws/container-linux/kubernetes/workers.tf index b5df2213..9bebffde 100644 --- a/aws/container-linux/kubernetes/workers.tf +++ b/aws/container-linux/kubernetes/workers.tf @@ -19,5 +19,6 @@ module "workers" { service_cidr = var.service_cidr cluster_domain_suffix = var.cluster_domain_suffix clc_snippets = var.worker_clc_snippets + node_labels = var.worker_node_labels } diff --git a/aws/container-linux/kubernetes/workers/cl/worker.yaml.tmpl b/aws/container-linux/kubernetes/workers/cl/worker.yaml.tmpl index a5441141..7d18b163 100644 --- a/aws/container-linux/kubernetes/workers/cl/worker.yaml.tmpl +++ b/aws/container-linux/kubernetes/workers/cl/worker.yaml.tmpl @@ -61,6 +61,9 @@ systemd: --lock-file=/var/run/lock/kubelet.lock \ --network-plugin=cni \ --node-labels=node.kubernetes.io/node \ + %{ for label in split(",", node_labels) } + --node-labels=${label} \ + %{ endfor ~} --pod-manifest-path=/etc/kubernetes/manifests \ --read-only-port=0 \ --volume-plugin-dir=/var/lib/kubelet/volumeplugins diff --git a/aws/container-linux/kubernetes/workers/variables.tf b/aws/container-linux/kubernetes/workers/variables.tf index e5c5b608..830a480c 100644 --- a/aws/container-linux/kubernetes/workers/variables.tf +++ b/aws/container-linux/kubernetes/workers/variables.tf @@ -105,3 +105,8 @@ variable "cluster_domain_suffix" { default = "cluster.local" } +variable "node_labels" { + description = "List of additional labels to add to worker nodes" + type = list + default = [] +} diff --git a/aws/container-linux/kubernetes/workers/workers.tf b/aws/container-linux/kubernetes/workers/workers.tf index 5effb789..79729bef 100644 --- a/aws/container-linux/kubernetes/workers/workers.tf +++ b/aws/container-linux/kubernetes/workers/workers.tf @@ -86,6 +86,7 @@ data "template_file" "worker-config" { cluster_dns_service_ip = cidrhost(var.service_cidr, 10) cluster_domain_suffix = var.cluster_domain_suffix cgroup_driver = local.flavor == "flatcar" && local.channel == "edge" ? "systemd" : "cgroupfs" + node_labels = join(",", var.node_labels) } } diff --git a/aws/fedora-coreos/kubernetes/variables.tf b/aws/fedora-coreos/kubernetes/variables.tf index 8df68d85..da2643fd 100644 --- a/aws/fedora-coreos/kubernetes/variables.tf +++ b/aws/fedora-coreos/kubernetes/variables.tf @@ -154,3 +154,8 @@ variable "enable_aggregation" { default = "false" } +variable "worker_node_labels" { + description = "List of additional labels to add to worker nodes" + type = list + default = [] +} diff --git a/aws/fedora-coreos/kubernetes/workers.tf b/aws/fedora-coreos/kubernetes/workers.tf index 4a2e5076..e8b57e62 100644 --- a/aws/fedora-coreos/kubernetes/workers.tf +++ b/aws/fedora-coreos/kubernetes/workers.tf @@ -19,5 +19,6 @@ module "workers" { service_cidr = var.service_cidr cluster_domain_suffix = var.cluster_domain_suffix snippets = var.worker_snippets + node_labels = var.worker_node_labels } diff --git a/aws/fedora-coreos/kubernetes/workers/fcc/worker.yaml b/aws/fedora-coreos/kubernetes/workers/fcc/worker.yaml index 79ab9065..54974941 100644 --- a/aws/fedora-coreos/kubernetes/workers/fcc/worker.yaml +++ b/aws/fedora-coreos/kubernetes/workers/fcc/worker.yaml @@ -66,6 +66,9 @@ systemd: --lock-file=/var/run/lock/kubelet.lock \ --network-plugin=cni \ --node-labels=node.kubernetes.io/node \ + %{ for label in split(",", node_labels) } + --node-labels=${label} \ + %{ endfor ~} --pod-manifest-path=/etc/kubernetes/manifests \ --read-only-port=0 \ --volume-plugin-dir=/var/lib/kubelet/volumeplugins diff --git a/aws/fedora-coreos/kubernetes/workers/variables.tf b/aws/fedora-coreos/kubernetes/workers/variables.tf index a1de562f..90700e00 100644 --- a/aws/fedora-coreos/kubernetes/workers/variables.tf +++ b/aws/fedora-coreos/kubernetes/workers/variables.tf @@ -105,3 +105,8 @@ variable "cluster_domain_suffix" { default = "cluster.local" } +variable "node_labels" { + description = "List of additional labels to add to worker nodes" + type = list + default = [] +} diff --git a/aws/fedora-coreos/kubernetes/workers/workers.tf b/aws/fedora-coreos/kubernetes/workers/workers.tf index 4ea1dec0..f63fd2b2 100644 --- a/aws/fedora-coreos/kubernetes/workers/workers.tf +++ b/aws/fedora-coreos/kubernetes/workers/workers.tf @@ -85,6 +85,7 @@ data "template_file" "worker-config" { 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) } } diff --git a/azure/container-linux/kubernetes/variables.tf b/azure/container-linux/kubernetes/variables.tf index 74b2dde8..77bfdb4c 100644 --- a/azure/container-linux/kubernetes/variables.tf +++ b/azure/container-linux/kubernetes/variables.tf @@ -135,3 +135,9 @@ variable "enable_aggregation" { default = "false" } +variable "worker_node_labels" { + description = "List of additional labels to add to worker nodes" + type = list + default = [] +} + diff --git a/azure/container-linux/kubernetes/workers.tf b/azure/container-linux/kubernetes/workers.tf index 5775f55c..11b77c50 100644 --- a/azure/container-linux/kubernetes/workers.tf +++ b/azure/container-linux/kubernetes/workers.tf @@ -20,5 +20,6 @@ module "workers" { service_cidr = var.service_cidr cluster_domain_suffix = var.cluster_domain_suffix clc_snippets = var.worker_clc_snippets + node_labels = var.worker_node_labels } diff --git a/azure/container-linux/kubernetes/workers/cl/worker.yaml.tmpl b/azure/container-linux/kubernetes/workers/cl/worker.yaml.tmpl index 7c3a6811..f12be17e 100644 --- a/azure/container-linux/kubernetes/workers/cl/worker.yaml.tmpl +++ b/azure/container-linux/kubernetes/workers/cl/worker.yaml.tmpl @@ -59,6 +59,9 @@ systemd: --lock-file=/var/run/lock/kubelet.lock \ --network-plugin=cni \ --node-labels=node.kubernetes.io/node \ + %{ for label in split(",", node_labels) } + --node-labels=${label} \ + %{ endfor ~} --pod-manifest-path=/etc/kubernetes/manifests \ --read-only-port=0 \ --volume-plugin-dir=/var/lib/kubelet/volumeplugins diff --git a/azure/container-linux/kubernetes/workers/variables.tf b/azure/container-linux/kubernetes/workers/variables.tf index a430a94a..026222ac 100644 --- a/azure/container-linux/kubernetes/workers/variables.tf +++ b/azure/container-linux/kubernetes/workers/variables.tf @@ -91,3 +91,8 @@ variable "cluster_domain_suffix" { default = "cluster.local" } +variable "node_labels" { + description = "List of additional labels to add to worker nodes" + type = list + default = [] +} diff --git a/azure/container-linux/kubernetes/workers/workers.tf b/azure/container-linux/kubernetes/workers/workers.tf index 9e32c4b6..d6d6d3c2 100644 --- a/azure/container-linux/kubernetes/workers/workers.tf +++ b/azure/container-linux/kubernetes/workers/workers.tf @@ -111,6 +111,7 @@ data "template_file" "worker-config" { 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) } } diff --git a/google-cloud/container-linux/kubernetes/variables.tf b/google-cloud/container-linux/kubernetes/variables.tf index 874deecb..e6c4120a 100644 --- a/google-cloud/container-linux/kubernetes/variables.tf +++ b/google-cloud/container-linux/kubernetes/variables.tf @@ -129,3 +129,9 @@ variable "enable_aggregation" { default = "false" } +variable "worker_node_labels" { + description = "List of additional labels to add to worker nodes" + type = list + default = [] +} + diff --git a/google-cloud/container-linux/kubernetes/workers.tf b/google-cloud/container-linux/kubernetes/workers.tf index eef18668..00e34c5f 100644 --- a/google-cloud/container-linux/kubernetes/workers.tf +++ b/google-cloud/container-linux/kubernetes/workers.tf @@ -18,5 +18,6 @@ module "workers" { service_cidr = var.service_cidr cluster_domain_suffix = var.cluster_domain_suffix clc_snippets = var.worker_clc_snippets + node_labels = var.worker_node_labels } diff --git a/google-cloud/container-linux/kubernetes/workers/cl/worker.yaml.tmpl b/google-cloud/container-linux/kubernetes/workers/cl/worker.yaml.tmpl index ddc78680..29e6cd9a 100644 --- a/google-cloud/container-linux/kubernetes/workers/cl/worker.yaml.tmpl +++ b/google-cloud/container-linux/kubernetes/workers/cl/worker.yaml.tmpl @@ -60,6 +60,9 @@ systemd: --lock-file=/var/run/lock/kubelet.lock \ --network-plugin=cni \ --node-labels=node.kubernetes.io/node \ + %{ for label in split(",", node_labels) } + --node-labels=${label} \ + %{ endfor ~} --pod-manifest-path=/etc/kubernetes/manifests \ --read-only-port=0 \ --volume-plugin-dir=/var/lib/kubelet/volumeplugins diff --git a/google-cloud/container-linux/kubernetes/workers/variables.tf b/google-cloud/container-linux/kubernetes/workers/variables.tf index a6c6aba3..292af163 100644 --- a/google-cloud/container-linux/kubernetes/workers/variables.tf +++ b/google-cloud/container-linux/kubernetes/workers/variables.tf @@ -81,6 +81,12 @@ variable "cluster_domain_suffix" { default = "cluster.local" } +variable "node_labels" { + description = "List of additional labels to add to worker nodes" + type = list + default = [] +} + variable "clc_snippets" { type = list(string) description = "Container Linux Config snippets" diff --git a/google-cloud/container-linux/kubernetes/workers/workers.tf b/google-cloud/container-linux/kubernetes/workers/workers.tf index 18b938f7..83eea948 100644 --- a/google-cloud/container-linux/kubernetes/workers/workers.tf +++ b/google-cloud/container-linux/kubernetes/workers/workers.tf @@ -82,6 +82,7 @@ data "template_file" "worker-config" { 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) } }