-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check health on control-plane before acting on cluster
- Loading branch information
Showing
4 changed files
with
31 additions
and
0 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
24 changes: 24 additions & 0 deletions
24
roles/preflight_check_cp/tasks/check_control_plane_health.yml
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,24 @@ | ||
--- | ||
- name: 'get kubeadm configmap if cluster running' | ||
command: kubectl get nodes -o yaml | ||
changed_when: false | ||
check_mode: false | ||
register: _all_nodes_yaml | ||
environment: | ||
KUBECONFIG: '{{ kubeconfig_admin }}' | ||
|
||
- name: 'Check control-plane health' | ||
set_fact: | ||
_failure_reasons: >- | ||
{%- set all_nodes = (_all_nodes_yaml.stdout|from_yaml)|'items'] | ||
|selectattr("metadata.labels.node-role\.kubernetes\.io/control-plane", "defined") -%} | ||
{%- if all_nodes|map(attribute="status.conditions") | ||
|map("selectattr", "type", "eq", "Ready") | ||
|map("first") | ||
|rejectattr("status", "eq", "True") | ||
|list|length != 0 -%} | ||
{%- set _ = _failure_reasons.dict(dict( | ||
cp_health = "Some control plane are not healthy")) -%} | ||
{%- endif -%} | ||
{%- endif -%} | ||
when: not cp_health_check_bypass|bool |
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