kubespray/roles/kubernetes/node-label/tasks/main.yml

48 lines
1.3 KiB
YAML
Raw Normal View History

---
- name: Kubernetes Apps | Wait for kube-apiserver
uri:
url: "{{ kube_apiserver_endpoint }}/healthz"
validate_certs: no
client_cert: "{{ kube_apiserver_client_cert }}"
client_key: "{{ kube_apiserver_client_key }}"
register: result
until: result.status == 200
retries: 10
delay: 6
when: inventory_hostname == groups['kube-master'][0]
- name: Set role node label to empty list
set_fact:
role_node_labels: []
- name: Node label for nvidia GPU nodes
set_fact:
role_node_labels: "{{ role_node_labels + [ 'nvidia.com/gpu=true' ] }}"
when:
- nvidia_gpu_nodes is defined
- nvidia_accelerator_enabled|bool
- inventory_hostname in nvidia_gpu_nodes
- name: Set inventory node label to empty list
set_fact:
inventory_node_labels: []
- name: Populate inventory node label
set_fact:
inventory_node_labels: "{{ inventory_node_labels + [ '%s=%s'|format(item.key, item.value) ] }}"
loop: "{{ node_labels|d({})|dict2items }}"
when:
- node_labels is defined
- node_labels is mapping
- debug: var=role_node_labels
- debug: var=inventory_node_labels
- name: Set label to node
command: >-
2020-06-30 03:39:59 +08:00
{{ bin_dir }}/kubectl label node {{ inventory_hostname }} {{ item }} --overwrite=true
loop: "{{ role_node_labels + inventory_node_labels }}"
delegate_to: "{{ groups['kube-master'][0] }}"
changed_when: false
...