Skip to content

Commit f6ba9bb

Browse files
authored
feat: add node_labels to master and worker nodes (#62)
1 parent 89a1842 commit f6ba9bb

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

iac/provider/kubespray/hosts.tpl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ all:
2727
oc_worker_nodes: null
2828

2929
oc_controlplane_nodes:
30-
%{ if network_plugin == "kube-ovn" ~}
30+
%{ if length(controlplane_node_labels) > 0 ~}
3131
vars:
3232
node_labels:
33-
"kube-ovn/role": "master"
33+
%{ for key, value in controlplane_node_labels ~}
34+
"${key}": "${value}"
35+
%{ endfor ~}
3436
%{ endif ~}
3537
hosts:
3638
%{ for master in master_nodes ~}
@@ -39,6 +41,13 @@ oc_controlplane_nodes:
3941
%{endfor ~}
4042

4143
oc_worker_nodes:
44+
%{ if length(worker_node_labels) > 0 ~}
45+
vars:
46+
node_labels:
47+
%{ for key, value in worker_node_labels ~}
48+
"${key}": "${value}"
49+
%{ endfor ~}
50+
%{ endif ~}
4251
hosts:
4352
%{ for worker in worker_nodes ~}
4453
${worker.name}:

iac/provider/kubespray/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ resource "local_file" "ansible_inventory" {
2020
ssh_user = var.ssh_user
2121
worker_nodes = var.worker_nodes
2222
windows_nodes = var.windows_nodes
23+
controlplane_node_labels = var.controlplane_node_labels
24+
worker_node_labels = var.worker_node_labels
25+
2326
})
2427

2528
filename = "./inventory/inventory.yaml"

iac/provider/kubespray/variables.tf

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,16 @@ variable "windows_nodes" {
244244
variable "use_octavia" {
245245
type = bool
246246
default = true
247-
}
247+
}
248+
249+
variable "controlplane_node_labels" {
250+
type = map(string)
251+
default = {}
252+
description = "Map of Kubernetes labels to apply to control plane nodes. Keys and values are strings."
253+
}
254+
255+
variable "worker_node_labels" {
256+
type = map(string)
257+
default = {}
258+
description = "Map of Kubernetes labels to apply to worker nodes. Keys and values are strings."
259+
}

0 commit comments

Comments
 (0)