diff --git a/python/src/mas/cli/uninstall/app.py b/python/src/mas/cli/uninstall/app.py index 0ac1e15c7d..80192f38b0 100644 --- a/python/src/mas/cli/uninstall/app.py +++ b/python/src/mas/cli/uninstall/app.py @@ -42,6 +42,9 @@ def uninstall(self, argv): if args.image_pull_policy and args.image_pull_policy != "": self.setParam("image_pull_policy", args.image_pull_policy) + cpdOperatorsNamespace = args.cpd_operators_namespace + cpdInstanceNamespace = args.cpd_instance_namespace + if args.uninstall_all_deps: uninstallGrafana = True uninstallIBMCatalog = True @@ -49,6 +52,7 @@ def uninstall(self, argv): uninstallDRO = True uninstallMongoDb = True uninstallSLS = True + uninstallCp4d = True else: uninstallGrafana = args.uninstall_grafana uninstallIBMCatalog = args.uninstall_ibm_catalog @@ -56,6 +60,7 @@ def uninstall(self, argv): uninstallDRO = args.uninstall_dro uninstallMongoDb = args.uninstall_mongodb uninstallSLS = args.uninstall_sls + uninstallCp4d = args.uninstall_cp4d if instanceId is None: self.printH1("Set Target OpenShift Cluster") @@ -106,6 +111,7 @@ def uninstall(self, argv): uninstallDRO = True uninstallMongoDb = True uninstallSLS = True + uninstallCp4d = True else: self.printDescription(["If you choose to uninstall MongoDb, IBM Suite License Service will be automatically set to uninstall as well"]) uninstallMongoDb = self.yesOrNo("Uninstall MongoDb") @@ -116,6 +122,7 @@ def uninstall(self, argv): uninstallSLS = self.yesOrNo("Uninstall IBM Suite Licensing Service") uninstallGrafana = self.yesOrNo("Uninstall Grafana") + uninstallCp4d = self.yesOrNo("Uninstall Cloud Pak for Data") self.printDescription( [ "If you choose to uninstall the IBM Operator Catalog, IBM Common Services, IBM User Data Services, & IBM Suite License Service will be automatically set to uninstall as well" @@ -158,6 +165,7 @@ def uninstall(self, argv): self.printSummary("Uninstall DRO", uninstallDRO) self.printSummary("Uninstall MongoDb", uninstallMongoDb) self.printSummary("Uninstall SLS", uninstallSLS) + self.printSummary("Uninstall CP4D", uninstallCp4d) if not self.noConfirm: print() @@ -195,6 +203,9 @@ def uninstall(self, argv): uninstallMongoDb=uninstallMongoDb, uninstallSLS=uninstallSLS, droNamespace=droNamespace, + uninstallCp4d=uninstallCp4d, + cpdOperatorsNamespace=cpdOperatorsNamespace, + cpdInstanceNamespace=cpdInstanceNamespace, ) if pipelineURL is not None: h.stop_and_persist(symbol=self.successIcon, text=f"PipelineRun for {instanceId} uninstall submitted") diff --git a/python/src/mas/cli/uninstall/argParser.py b/python/src/mas/cli/uninstall/argParser.py index aac29259a2..cf2149c407 100644 --- a/python/src/mas/cli/uninstall/argParser.py +++ b/python/src/mas/cli/uninstall/argParser.py @@ -87,6 +87,25 @@ default=False, help="Uninstall IBM User Data Services from the target cluster", ) +depsArgGroup.add_argument( + "--uninstall-cp4d", + required=False, + action="store_true", + default=False, + help="Uninstall Cloud Pak for Data from the target cluster", +) +depsArgGroup.add_argument( + "--cpd-operators-namespace", + required=False, + default="", + help="CP4D operators namespace (default: ibm-cpd-operators)", +) +depsArgGroup.add_argument( + "--cpd-instance-namespace", + required=False, + default="", + help="CP4D instance namespace (default: ibm-cpd)", +) otherArgGroup = uninstallArgParser.add_argument_group("More") otherArgGroup.add_argument( diff --git a/tekton/generate-tekton-tasks.yml b/tekton/generate-tekton-tasks.yml index df80d8d9a9..eca7f883a9 100644 --- a/tekton/generate-tekton-tasks.yml +++ b/tekton/generate-tekton-tasks.yml @@ -29,6 +29,7 @@ - cp4d-service - cp4d-service-update - cp4d + - cp4d-uninstall - db2 - dro - eck diff --git a/tekton/src/pipelines/mas-uninstall.yml.j2 b/tekton/src/pipelines/mas-uninstall.yml.j2 index 24f743a8c4..d00c1f84e2 100644 --- a/tekton/src/pipelines/mas-uninstall.yml.j2 +++ b/tekton/src/pipelines/mas-uninstall.yml.j2 @@ -54,6 +54,18 @@ spec: - name: dro_namespace default: "redhat-marketplace" type: string + - name: cp4d_action + type: string + description: Optional. Used to uninstall CP4D + default: "none" + - name: cpd_operators_namespace + type: string + description: Optional. CP4D operators namespace + default: "" + - name: cpd_instance_namespace + type: string + description: Optional. CP4D instance namespace + default: "" tasks: # Content @@ -274,7 +286,33 @@ spec: value: suite-uninstall - # 4. Uninstall IBM Suite Licensing Service + # 4. Uninstall Cloud Pak for Data + # ------------------------------------------------------------------------- + # CP4D is a cluster-level dependency, independent of any MAS instance. + # Runs in parallel with app-uninstall tasks immediately after approval. + # The cp4d_uninstall role safely exits if CP4D is not installed. + - name: uninstall-cp4d + timeout: "0" + params: + {{ lookup('template', pipeline_src_dir ~ '/taskdefs/common/cli-params.yml.j2') | indent(8) }} + - name: cpd_operators_namespace + value: $(params.cpd_operators_namespace) + - name: cpd_instance_namespace + value: $(params.cpd_instance_namespace) + - name: devops_suite_name + value: dependencies-cp4d-uninstall + taskRef: + kind: Task + name: mas-devops-cp4d-uninstall + when: + - input: "$(params.cp4d_action)" + operator: in + values: ["uninstall"] + runAfter: + - waitfor-approval + + + # 5. Uninstall IBM Suite Licensing Service # ------------------------------------------------------------------------- - name: uninstall-sls timeout: "0" diff --git a/tekton/src/tasks/dependencies/cp4d-uninstall.yml.j2 b/tekton/src/tasks/dependencies/cp4d-uninstall.yml.j2 new file mode 100644 index 0000000000..dd062e38fb --- /dev/null +++ b/tekton/src/tasks/dependencies/cp4d-uninstall.yml.j2 @@ -0,0 +1,48 @@ +--- +apiVersion: tekton.dev/v1 +kind: Task +metadata: + name: mas-devops-cp4d-uninstall +spec: + params: + {{ lookup('template', task_src_dir ~ '/common/cli-params.yml.j2') | indent(4) }} + + # CP4D Namespace configuration (Optional, defaults built into Ansible role) + - name: cpd_operators_namespace + type: string + default: "" + - name: cpd_instance_namespace + type: string + default: "" + + # Uninstall options (Optional, defaults built into Ansible role) + - name: cpd_uninstall_delete_pvcs + type: string + default: "" + - name: cpd_uninstall_delete_namespaces + type: string + default: "" + + stepTemplate: + env: + {{ lookup('template', task_src_dir ~ '/common/cli-env.yml.j2') | indent(6) }} + + # Namespace configuration + - name: CPD_OPERATORS_NAMESPACE + value: $(params.cpd_operators_namespace) + - name: CPD_INSTANCE_NAMESPACE + value: $(params.cpd_instance_namespace) + + # Uninstall options + - name: CPD_UNINSTALL_DELETE_PVCS + value: $(params.cpd_uninstall_delete_pvcs) + - name: CPD_UNINSTALL_DELETE_NAMESPACES + value: $(params.cpd_uninstall_delete_namespaces) + + steps: + - name: cp4d-uninstall + command: + - /opt/app-root/src/run-role.sh + - cp4d_uninstall + image: "quay.io/ibmmas/cli:latest" + imagePullPolicy: $(params.image_pull_policy)