feat: set node role labels
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Robert Kaussow 2022-10-27 14:11:11 +02:00
parent 33e58dcb83
commit 29a806227f
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
2 changed files with 19 additions and 0 deletions

View File

@ -38,6 +38,17 @@
changed_when: False
when: k3s_server | bool
- name: Add node role label
k8s:
kind: "Node"
name: "{{ ansible_hostname }}"
kubeconfig: "{{ __k3s_config_dir }}/k3s.yaml"
state: present
definition:
metadata:
labels: "{{ (__k3s_node_lables['control'] if k3s_server | bool else __k3s_node_lables['worker']) | combine(__k3s_node_lables['general']) }}"
delegate_to: "{{ hostvars[k3s_server_nodes[0]]['inventory_hostname'] }}"
- name: Patch existing resources
k8s:
kind: "{{ item.kind }}"

View File

@ -18,3 +18,11 @@ __k3s_config_dir: /etc/rancher/k3s
__k3s_data_dir: /var/lib/rancher/k3s
__k3s_manifests_dir: "{{ __k3s_data_dir }}/server/manifests"
__k3s_log_dir: /var/log/rancher/k3s
__k3s_node_lables:
general:
node-role.kubernetes.io/k3s-node: "true"
control:
node-role.kubernetes.io/control-plane: "true"
worker:
node-role.kubernetes.io/worker: "true"