-
Notifications
You must be signed in to change notification settings - Fork 20
/
pb_uncordon_node.yaml
41 lines (36 loc) · 1.39 KB
/
pb_uncordon_node.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
---
- hosts: all
tasks:
- set_fact:
unsafe_show_logs: "{{ not (kuboardspray_no_log | default(true)) }}"
- name: 恢复调度
hosts: target
vars:
# If non-empty, will use this string as identification instead of the actual hostname
kube_override_hostname: >-
{%- if cloud_provider is defined and cloud_provider in [ 'aws' ] -%}
{%- else -%}
{{ inventory_hostname }}
{%- endif -%}
kubectl: kubectl
tasks:
# Node Ready: type = ready, status = True
# Node NotReady: type = ready, status = Unknown
- name: See if node is in ready state
command: >
{{ kubectl }} get node {{ kube_override_hostname|default(inventory_hostname) }}
-o jsonpath="{ range .status.conditions[?(@.type == 'Ready')].status }{ @ }{ end }"
register: kubectl_node_ready
delegate_to: "{{ groups['kube_control_plane'][0] }}"
failed_when: false
changed_when: false
- name: Fail after rescue
fail:
msg: "节点 {{ inventory_hostname }} 当前并不处于 READY 状态"
when: kubectl_node_ready.stdout != "True"
- name: debug
debug:
msg: "节点 {{ inventory_hostname }} 当前处于 READY 状态,恢复调度"
- name: Cordon node
command: "{{ kubectl }} uncordon {{ kube_override_hostname|default(inventory_hostname) }}"
delegate_to: "{{ groups['kube_control_plane'][0] }}"