feat: add option to apply custom node labels
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Robert Kaussow 2022-11-20 14:10:29 +01:00
parent a75b4c8250
commit 25c06319c0
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
4 changed files with 12 additions and 1 deletions

View File

@ -51,3 +51,5 @@ k3s_server_admission_configuration:
k3s_server_resource_creations: []
k3s_server_resource_patches: []
k3s_node_labels: {}

View File

@ -28,6 +28,8 @@
# type: Opaque
# data:
# token: "{{ hcloud_token | b64encode }}"
k3s_node_labels:
node.kubernetes.io/exclude-from-external-load-balancers: "true"
pre_tasks:
- name: Override host variables
ansible.builtin.set_fact:

View File

@ -21,6 +21,13 @@ def test_k3s_node_ready(host):
assert "rocky9-k3s:Ready=True;" in nodes
def test_k3s_node_labels(host):
jsonpth = '{.items[0].metadata.labels}' # noqa
nodes = host.run(f"k3s kubectl get nodes -o jsonpath='{jsonpth}'").stdout
assert '"node.kubernetes.io/exclude-from-external-load-balancers":"true"' in nodes
def test_k3s_cluster_ready(host):
cluster = host.run("k3s kubectl get --raw='/readyz'").stdout

View File

@ -68,7 +68,7 @@
state: patched
definition:
metadata:
labels: "{{ (__k3s_node_lables['control'] if k3s_server | bool else __k3s_node_lables['worker']) | combine(__k3s_node_lables['general']) }}"
labels: "{{ (__k3s_node_lables['control'] if k3s_server | bool else __k3s_node_lables['worker']) | combine(__k3s_node_lables['general'], k3s_node_labels) }}"
delegate_to: "{{ hostvars[k3s_server_nodes[0]]['inventory_hostname'] }}"
- name: Patch existing resources