forked from openebs/openebs
-
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.
Checking the behavior of cstor pool pod when a node is drained (opene…
…bs#1904) Signed-off-by: gprasath <giridhara.prasad@cloudbyte.com>
- Loading branch information
1 parent
690394c
commit 16f1739
Showing
4 changed files
with
260 additions
and
169 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
80 changes: 80 additions & 0 deletions
80
e2e/ansible/playbooks/hyperconverged/test-k8s-drain-nodes/drain-node-cstor.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,80 @@ | ||
--- | ||
|
||
- name: Replace storage-class to use cstor storage engine | ||
replace: | ||
path: "{{ result_kube_home.stdout }}/{{ percona_file }}" | ||
regexp: 'openebs-standard' | ||
replace: '{{ cstor_sc }}' | ||
delegate_to: "{{ groups['kubernetes-kubemasters'].0 }}" | ||
|
||
- name: Deploy Percona application | ||
include_tasks: "{{utils_path}}/deploy_task.yml" | ||
vars: | ||
app_yml: "{{ percona_file }}" | ||
ns: "{{ namespace }}" | ||
|
||
- name: Check if the application is running. | ||
include_tasks: "{{utils_path}}/deploy_check.yml" | ||
vars: | ||
ns: "{{ namespace }}" | ||
lkey: name | ||
lvalue: percona | ||
|
||
- name: Obtain the number of pools | ||
shell: source ~/.profile; kubectl get pods -n {{ operator_ns }} | grep cstor | grep -i running | wc -l | ||
args: | ||
executable: /bin/bash | ||
register: pool_count | ||
|
||
- name: Obtaining the cstor pool pods | ||
shell: source ~/.profile; kubectl get pods -n {{ operator_ns }} | grep cstor | awk {'print $1'} | ||
args: | ||
executable: /bin/bash | ||
register: cstor_pods | ||
delegate_to: "{{ groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Getting the node name | ||
shell: source ~/.profile; kubectl get pods -n {{ operator_ns }} {{ cstor_pods.stdout_lines[0] }} --no-headers -o custom-columns=:spec.nodeName | ||
args: | ||
executable: /bin/bash | ||
register: node | ||
delegate_to: "{{ groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Drain one of the nodes | ||
shell: source ~/.profile; kubectl drain {{ node.stdout }} --ignore-daemonsets --force | ||
args: | ||
executable: /bin/bash | ||
delegate_to: "{{ groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Check if one of the pools is pending. | ||
shell: source ~/.profile; kubectl get pods -n {{operator_ns}} | grep cstor | grep -i pending | wc -l | ||
args: | ||
executable: /bin/bash | ||
register: pending_pod | ||
until: "'1' in pending_pod.stdout" | ||
delay: 30 | ||
retries: 20 | ||
delegate_to: "{{ groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Uncordon the node | ||
shell: source ~/.profile; kubectl uncordon {{ node.stdout }} | ||
args: | ||
executable: /bin/bash | ||
register: result | ||
delegate_to: "{{ groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Obtain the number of pools | ||
shell: source ~/.profile; kubectl get pods -n {{ operator_ns }} | grep cstor | grep -i running | wc -l | ||
args: | ||
executable: /bin/bash | ||
register: pool_count | ||
until: "'3' in pool_count.stdout" | ||
delay: 60 | ||
retries: 20 | ||
|
||
- name: Check if the application is running. | ||
include_tasks: "{{utils_path}}/deploy_check.yml" | ||
vars: | ||
ns: "{{ namespace }}" | ||
lkey: name | ||
lvalue: percona |
132 changes: 132 additions & 0 deletions
132
e2e/ansible/playbooks/hyperconverged/test-k8s-drain-nodes/drain-node-jiva.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,132 @@ | ||
--- | ||
- name: Obtaining storage classes yaml | ||
shell: source ~/.profile; kubectl get sc openebs-standard -o yaml > "{{ result_kube_home.stdout }}/{{ create_sc }}" | ||
args: | ||
executable: /bin/bash | ||
delegate_to: "{{groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Replace the replica count in openebs-storageclasses yaml | ||
replace: | ||
path: "{{ result_kube_home.stdout }}/{{ create_sc }}" | ||
regexp: ' - name: ReplicaCount\n value: "3"' | ||
replace: ' - name: ReplicaCount\n value: "{{ (node_count) |int-1 }}"' | ||
delegate_to: "{{groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Delete the existing storage class and create new one | ||
shell: source ~/.profile; kubectl delete sc openebs-standard; kubectl apply -f "{{ result_kube_home.stdout }}/{{ create_sc }}" | ||
args: | ||
executable: /bin/bash | ||
register: sc_out | ||
until: "'created' in sc_out.stdout" | ||
delay: 10 | ||
retries: 5 | ||
delegate_to: "{{groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Deploy percona application | ||
include_tasks: "{{utils_path}}/deploy_task.yml" | ||
vars: | ||
app_yml: "{{ percona_file }}" | ||
ns: "{{ namespace }}" | ||
|
||
- name: Check percona pod is running | ||
include_tasks: "{{utils_path}}/deploy_check.yml" | ||
vars: | ||
ns: "{{namespace}}" | ||
lkey: name | ||
lvalue: percona | ||
|
||
- name: Check if the replica pods are created and running | ||
shell: source ~/.profile; kubectl get pods -n {{ namespace }} | grep rep | grep -i running |wc -l | ||
args: | ||
executable: /bin/bash | ||
register: rep_count | ||
until: "'2' in rep_count.stdout" | ||
delay: 60 | ||
retries: 5 | ||
delegate_to: "{{groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Obtaining the PV name | ||
shell: source ~/.profile; kubectl get pvc -n {{ namespace }} --no-headers | awk {'print $3'} | ||
args: | ||
executable: /bin/bash | ||
register: pv_name | ||
delegate_to: "{{groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Copy replica_patch.yaml to master | ||
copy: | ||
src: "{{ patch_file }}" | ||
dest: "{{ result_kube_home.stdout }}" | ||
delegate_to: "{{groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Get the node name where replica1 is scheduled | ||
shell: source ~/.profile; kubectl get po -n {{ namespace }} -o wide | grep "{{ pv_name.stdout }}" | grep rep | awk '{print $7}' | awk 'FNR == 1 {print}' | ||
args: | ||
executable: /bin/bash | ||
register: node1 | ||
delegate_to: "{{groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Get the node name where replica2 is scheduled | ||
shell: source ~/.profile; kubectl get po -n {{ namespace }} -o wide | grep "{{ pv_name.stdout }}" | grep rep | awk '{print $7}' | awk 'FNR == 2 {print}' | ||
args: | ||
executable: /bin/bash | ||
register: node2 | ||
delegate_to: "{{groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Update replica1 node name in replica_patch file | ||
replace: | ||
path: "{{ result_kube_home.stdout }}/{{ patch_file }}" | ||
regexp: 'nodename_where_replica_pod_1_got_scheduled' | ||
replace: '{{ node1.stdout }}' | ||
delegate_to: "{{groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Update replica2 node name in replica_patch file | ||
replace: | ||
path: "{{ result_kube_home.stdout }}/{{ patch_file }}" | ||
regexp: 'nodename_where_replica_pod_2_got_scheduled' | ||
replace: '{{ node2.stdout }}' | ||
delegate_to: "{{groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Get the deployment name | ||
shell: source ~/.profile; kubectl get deploy -n {{ namespace }} |grep "{{ pv_name.stdout }}" | grep rep |awk '{print $1}' | ||
args: | ||
executable: /bin/bash | ||
register: deploy_name | ||
delegate_to: "{{groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Apply the node affinity property | ||
shell: source ~/.profile; kubectl patch deployment "{{ deploy_name.stdout }}" -n {{ namespace }} -p "$(cat replica_patch.yaml)" | ||
args: | ||
executable: /bin/bash | ||
register: patch_out | ||
until: "'patched' in patch_out.stdout" | ||
delay: 20 | ||
retries: 5 | ||
delegate_to: "{{groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Drain the node where replica is scheduled | ||
shell: source ~/.profile; kubectl drain {{ node1.stdout }} --ignore-daemonsets --force | ||
args: | ||
executable: /bin/bash | ||
register: result | ||
delegate_to: "{{groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Check the available replicas in deployment | ||
shell: source ~/.profile; kubectl get deploy -n {{ namespace }} | grep "{{ pv_name.stdout }}" | grep rep | awk '{print $2}' | ||
args: | ||
executable: /bin/bash | ||
register: available_pods | ||
until: "'2' in available_pods.stdout" | ||
delay: 30 | ||
retries: 5 | ||
delegate_to: "{{groups['kubernetes-kubemasters'].0}}" | ||
|
||
- name: Check if the replica is in pending state after node drain | ||
shell: source ~/.profile; kubectl get pods -n {{ namespace }} -o wide | grep "{{ pv_name.stdout }}" | grep rep | grep Pending | ||
args: | ||
executable: /bin/bash | ||
register: result | ||
until: "'Pending' in result.stdout" | ||
delay: 30 | ||
retries: 15 | ||
delegate_to: "{{groups['kubernetes-kubemasters'].0}}" | ||
|
Oops, something went wrong.