forked from kubernetes-sigs/kubespray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(kubernetes): taint nodes with kubectl (kubernetes-sigs#10705)
Signed-off-by: Maxime Leroy <19607336+maxime1907@users.noreply.github.com>
- Loading branch information
1 parent
320af20
commit 9282b10
Showing
6 changed files
with
41 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
- name: Set role and inventory node taint to empty list | ||
set_fact: | ||
role_node_taints: [] | ||
inventory_node_taints: [] | ||
|
||
- name: Node taint for nvidia GPU nodes | ||
set_fact: | ||
role_node_taints: "{{ role_node_taints + ['nvidia.com/gpu=:NoSchedule'] }}" | ||
when: | ||
- nvidia_gpu_nodes is defined | ||
- nvidia_accelerator_enabled | bool | ||
- inventory_hostname in nvidia_gpu_nodes | ||
|
||
- name: Populate inventory node taint | ||
set_fact: | ||
inventory_node_taints: "{{ inventory_node_taints + ['%s' | format(item)] }}" | ||
loop: "{{ node_taints | d([]) }}" | ||
when: | ||
- node_taints is defined | ||
- node_taints is not string | ||
- node_taints is not mapping | ||
- node_taints is iterable | ||
- debug: # noqa name[missing] | ||
var: role_node_taints | ||
- debug: # noqa name[missing] | ||
var: inventory_node_taints | ||
|
||
- name: Set taint to node | ||
command: >- | ||
{{ kubectl }} taint node {{ kube_override_hostname | default(inventory_hostname) }} {{ (role_node_taints + inventory_node_taints) | join(' ') }} --overwrite=true | ||
delegate_to: "{{ groups['kube_control_plane'][0] }}" | ||
changed_when: false | ||
when: | ||
- (role_node_taints + inventory_node_taints) | length > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters