Merge "Add a destroy workflow for kolla-kubernetes"
This commit is contained in:
commit
53c74d1f69
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- name: Destroy the existing Kolla-Kubernetes deployment
|
||||
hosts: localhost
|
||||
connection: local
|
||||
roles:
|
||||
- destroy
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: "Removing label on node {{ host['metadata']['name'] }}"
|
||||
command: "kubectl label node {{ host['metadata']['name'] }} {{ item.key }}-"
|
||||
when: item.key.startswith('kolla_')
|
||||
with_dict: "{{ host['metadata']['labels'] }}"
|
|
@ -0,0 +1,86 @@
|
|||
---
|
||||
- name: Obtain node information
|
||||
command: kubectl get nodes -o json
|
||||
register: kubectl_nodes
|
||||
|
||||
- name: Set node facts
|
||||
set_fact:
|
||||
kubectl_dict: "{{ kubectl_nodes.stdout|from_json }}"
|
||||
|
||||
- name: Obtain list of Kolla PVs
|
||||
command: "kubectl get pvc -n kolla -o jsonpath={.items[*].spec.volumeName}"
|
||||
register: pv_list
|
||||
failed_when:
|
||||
- pv_list.rc != 0
|
||||
|
||||
- name: Obtain list of Kolla configmaps
|
||||
command: "kubectl get configmaps -n kolla -o name"
|
||||
register: configmaps_list
|
||||
changed_when:
|
||||
- configmaps_list | success
|
||||
failed_when:
|
||||
- configmaps_list.rc != 0
|
||||
|
||||
- name: Obtain list of Kolla secrets
|
||||
command: "kubectl get secrets -n kolla -o name"
|
||||
register: secrets_list
|
||||
changed_when:
|
||||
- secrets_list | success
|
||||
failed_when:
|
||||
- secrets_list.rc != 0
|
||||
|
||||
- name: Obtain list of Kolla Helm charts
|
||||
command: "helm list --namespace kolla --all -q"
|
||||
register: helm_list
|
||||
changed_when:
|
||||
- helm_list | success
|
||||
failed_when:
|
||||
- helm_list.rc != 0
|
||||
|
||||
- name: Delete existing Kolla Helm charts
|
||||
command: "helm delete {{ item }} --purge"
|
||||
when: helm_list.stdout | length != 0
|
||||
with_items:
|
||||
- "{{ helm_list.stdout }}"
|
||||
|
||||
- name: Delete existing Kolla secrets
|
||||
command: "kubectl delete -n kolla {{ item }}"
|
||||
when: secrets_list.stdout | length != 0
|
||||
with_items:
|
||||
- "{{ secrets_list.stdout }}"
|
||||
|
||||
- name: Delete existing Kolla configmaps
|
||||
command: "kubectl delete -n kolla {{ item }}"
|
||||
when: configmaps_list.stdout | length != 0
|
||||
with_items:
|
||||
- "{{ configmaps_list.stdout }}"
|
||||
|
||||
- name: "Delete existing Kolla labels"
|
||||
include: "label_iterator.yml"
|
||||
with_items: "{{ kubectl_dict['items'] }}"
|
||||
loop_control:
|
||||
loop_var: host
|
||||
|
||||
- name: Obtain list of Kolla PVCs
|
||||
shell: "kubectl get pvc -n kolla -o jsonpath={.items[*].metadata.name}"
|
||||
register: pvc_list
|
||||
failed_when:
|
||||
- pvc_list.rc != 0
|
||||
|
||||
- name: Delete existing Kolla PVCs
|
||||
command: "kubectl delete pvc -n kolla {{ item }}"
|
||||
when: pvc_list.stdout | length != 0
|
||||
with_items:
|
||||
- "{{ pvc_list.stdout }}"
|
||||
|
||||
- name: Delete existing Kolla PVs
|
||||
command: "kubectl delete pv {{ item }}"
|
||||
when: pv_list.stdout | length != 0
|
||||
with_items:
|
||||
- "{{ pv_list.stdout }}"
|
||||
|
||||
- name: Delete Kolla namespace
|
||||
command: "kubectl delete namespace kolla"
|
||||
register: namespace_delete
|
||||
failed_when:
|
||||
- namespace_delete.rc != 0
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
Add an Ansible workflow to destroy a kolla-kubernetes deployment. This
|
||||
will be followed up with a container which runs this specific workflow.
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash -xe
|
||||
|
||||
# Destroy kolla-kubernetes deployment and validate kolla-kubernetes is
|
||||
# indeed destroyed
|
||||
|
||||
. .venv/bin/activate
|
||||
ansible-playbook -e ansible_python_interpreter=/usr/bin/python ansible/destroy.yml
|
||||
deactivate
|
||||
|
||||
# Validate the deployment was indeed deleted
|
||||
NAMESPACED_OBJECTS=$(kubectl get all -n kolla -o name --no-headers | wc -l)
|
||||
LABELED_NODE_OBJECTS=$(kubectl get nodes --show-labels --no-headers | grep kolla | wc -l)
|
||||
PV_OBJECTS=$(kubectl get pv --no-headers | wc -l)
|
||||
|
||||
# If namespaced objects still exist, exit with failure
|
||||
if [ $NAMESPACED_OBJECTS -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If labeled nodes still exist, exit with failure
|
||||
if [ $LABELED_NODE_OBJECTS -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If PVs exist, exit with failure
|
||||
if [ $PV_OBJECTS -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
|
@ -150,4 +150,8 @@ ironic port-show $(ironic port-list | grep be:ef | awk '{print $2}' ) \
|
|||
sudo virsh list > $WORKSPACE/logs/virsh_list.txt
|
||||
sudo virsh dumpxml vm-1 > $WORKSPACE/logs/virsh_dumpxml.txt
|
||||
|
||||
kubectl get all -n kolla -o name > $WORKSPACE/logs/objects_list.txt
|
||||
kubectl get nodes -o name --show-labels | grep kolla > $WORKSPACE/logs/labels_list.txt
|
||||
kubectl get pv > $WORKSPACE/logs/pv_list.txt
|
||||
|
||||
exit -1
|
||||
|
|
|
@ -72,6 +72,7 @@ fi
|
|||
|
||||
if [ "x$4" == "xironic" ]; then
|
||||
tools/setup_gate_iscsi.sh $1 $2 $3 $4 $5 $BRANCH $PIPELINE
|
||||
tests/bin/destroy_tests.sh
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in New Issue