Simplify usage of pre-remove role (#8334)

- Use builtin task scheduling of ansible (same task on each host)
  instead of manual looping on master

Benefits:
- One less play in remove-node.yml playbook
- Parralel node drain
- Drain parameters (timeout, grace period, retries,
  allow_ungraceful_removal) can be adjusted separately for each node
  with ansible variables
This commit is contained in:
Max Gautier
2022-01-04 16:10:53 +01:00
committed by GitHub
parent 63a53c79d0
commit 92f25bf267
2 changed files with 3 additions and 11 deletions

View File

@@ -14,14 +14,12 @@
--ignore-daemonsets
--grace-period {{ drain_grace_period }}
--timeout {{ drain_timeout }}
--delete-emptydir-data {{ hostvars[item]['kube_override_hostname']|default(item) }}
loop: "{{ node.split(',') | default(groups['kube_node']) }}"
--delete-emptydir-data {{ kube_override_hostname|default(inventory_hostname) }}
# ignore servers that are not nodes
when: hostvars[item]['kube_override_hostname']|default(item) in nodes.stdout_lines
when: kube_override_hostname|default(inventory_hostname) in nodes.stdout_lines
register: result
failed_when: result.rc != 0 and not allow_ungraceful_removal
delegate_to: "{{ groups['kube_control_plane']|first }}"
run_once: true
until: result.rc == 0 or allow_ungraceful_removal
retries: "{{ drain_retries }}"
delay: "{{ drain_retry_delay_seconds }}"