-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added operator cleanup task module to ocp-descheduler role
Signed-off-by: Aditya Honkalas <[email protected]>
- Loading branch information
1 parent
504a385
commit 97865de
Showing
6 changed files
with
117 additions
and
24 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
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
78 changes: 78 additions & 0 deletions
78
playbooks/roles/ocp-descheduler/tasks/descheduler-operator-cleanup.yaml
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,78 @@ | ||
--- | ||
|
||
## Descheduler operator cleanup | ||
|
||
- name: Check the namespaces containing descheduler operator installed | ||
shell: oc get csv -A | awk '{ if($2 ~ /clusterkubedescheduleroperator/) print($1)}' | ||
register: descheduler_installed_namespaces | ||
|
||
- name: Cleanup block to remove the operator support objects and namespace | ||
block: | ||
- name: Delete the subscriptions for descheduler | ||
shell: "oc delete subscription --all -n {{ item }}" | ||
loop: "{{ descheduler_installed_namespaces.stdout_lines }}" | ||
|
||
- name: Delete the operatorgroups for descheduler | ||
shell: "oc delete operatorgroup --all -n {{ item }}" | ||
loop: "{{ descheduler_installed_namespaces.stdout_lines }}" | ||
|
||
- name: Delete the operator deployments | ||
shell: "oc delete deploy --all -n {{ item }}" | ||
loop: "{{ descheduler_installed_namespaces.stdout_lines }}" | ||
|
||
- name: Delete the CSV for operator | ||
shell: "oc delete csv --all -n {{ item }}" | ||
loop: "{{ descheduler_installed_namespaces.stdout_lines }}" | ||
|
||
- name: Delete the projects | ||
shell: "oc delete ns {{ item }}" | ||
loop: "{{ descheduler_installed_namespaces.stdout_lines }}" | ||
|
||
- name: Check if the {{ descheduler_namespace }} namespace is active | ||
shell: "oc get namespace {{ descheduler_namespace }} --no-headers | wc -l" | ||
register: namespace_exists | ||
|
||
- name: Delete the OperatorGroup, Subscription and {{ descheduler_namespace }} namespace | ||
block: | ||
- name: Delete the subscription | ||
kubernetes.core.k8s: | ||
state: absent | ||
definition: | ||
apiVersion: operators.coreos.com/v1alpha1 | ||
kind: Subscription | ||
metadata: | ||
name: openshift-descheduler-subscription | ||
namespace: "{{ descheduler_namespace }}" | ||
spec: | ||
channel: "{{ descheduler_channel }}" | ||
installPlanApproval: Automatic | ||
name: cluster-kube-descheduler-operator | ||
source: "{{ descheduler_catalogsource_name }}" | ||
sourceNamespace: openshift-marketplace | ||
|
||
- name: Delete the OperatorGroup | ||
kubernetes.core.k8s: | ||
state: absent | ||
definition: | ||
apiVersion: operators.coreos.com/v1 | ||
kind: OperatorGroup | ||
metadata: | ||
name: openshift-descheduler-operatorgroup | ||
namespace: "{{ descheduler_namespace }}" | ||
spec: | ||
targetNamespaces: | ||
- "{{ descheduler_namespace }}" | ||
|
||
- name: Create a target namespace | ||
kubernetes.core.k8s: | ||
state: absent | ||
definition: | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: "{{ descheduler_namespace }}" | ||
spec: | ||
targetNamespaces: | ||
- "{{ descheduler_namespace }}" | ||
|
||
when: namespace_exists.stdout != 0 |
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