k8s_drain new module (#141)

k8s_drain new module

SUMMARY

new module to drain, cordon or uncordon node from k8s cluster.
#141

ISSUE TYPE


New Module Pull Request

COMPONENT NAME

k8s_drain

Reviewed-by: Abhijeet Kasurde <None>
Reviewed-by: None <None>
Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: None <None>
This commit is contained in:
abikouo
2021-08-09 10:00:34 +02:00
committed by GitHub
parent 76a77aff1f
commit b875531c8a
8 changed files with 1208 additions and 50 deletions

View File

@@ -6,45 +6,7 @@
collections:
- kubernetes.core
vars:
node_taints:
- "node.kubernetes.io/not-ready"
- "node.kubernetes.io/unreachable"
- "node.kubernetes.io/unschedulable"
kind_bin_path: "/usr/local/bin/kind"
tasks:
# We are spawning k8s cluster using kind executable and we ensure that the cluster is up
# and node is ready, if this is not validated we may face issue later on when running tests
- name: Check if kind binary is available or not
stat:
path: "{{ kind_bin_path }}"
register: r
- name: Download kind if not available
get_url:
url: https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
dest: "{{ kind_bin_path }}"
when: not r.stat.exists
- name: Make kind executable
file:
path: "{{ kind_bin_path }}"
mode: '0755'
- name: Check if Kind cluster exists
command: "{{ kind_bin_path }} get clusters"
register: r
ignore_errors: true
- name: Create cluster
command: "{{ kind_bin_path }} create cluster"
when: r.stdout == ''
- name: Assert that nodes are ready
k8s_info:
kind: Node
retries: 10
delay: 30
register: nodes
until: nodes.resources | selectattr("spec.taints", "defined") | map(attribute="spec.taints") | list | length == 0
- name: Include drain.yml
include_tasks:
file: tasks/drain.yml