From 28306a4b315b2dedb8209061330bc74d1942ce97 Mon Sep 17 00:00:00 2001 From: Valer Cara Date: Tue, 24 Sep 2019 16:37:39 +0300 Subject: [PATCH] Node labels: add `worker_node_labels` to main module and `node_labels` to workers - aws (cl, fedora) - google-cloud - azure --- 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 7005e63b6..b76f3d54e 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 b5df22138..9bebffdeb 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 a54411410..7d18b1631 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 e5c5b6082..830a480cd 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 5effb7890..79729bef0 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 8df68d856..da2643fd6 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 4a2e50764..e8b57e620 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 79ab90652..549749410 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 a1de562fb..90700e004 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 4ea1dec08..f63fd2b2d 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 74b2dde83..77bfdb4c4 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 5775f55c9..11b77c50f 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 7c3a68115..f12be17ea 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 a430a94a6..026222ac9 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 9e32c4b68..d6d6d3c27 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 874deecb8..e6c4120a2 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 eef186687..00e34c5f1 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 ddc78680c..29e6cd9a2 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 a6c6aba33..292af163f 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 18b938f74..83eea9484 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) } }