Uninstalling foundational services

You can uninstall services by using the Operand Deployment Lifecycle Manager.

Uninstalling all services

If you want to delete all the installed services, complete the steps in this section. Complete these steps by using the command-line interface (CLI).

  1. Log in to the cluster by using the oc login command.

  2. Locate the operator namespace where the IBM Cloud Pak foundational services operator is deployed. For example, the foundational-services namespace.

     export operatorNamespace=<foundational-services-namespace>
    
  3. Locate the service namespace where the services are deployed.

     export servicesNamespace=$(oc get commonservice common-service -n $operatorNamespace -o jsonpath='{.spec.servicesNamespace}')
    
  4. Delete the CommonService APIs from the operator and service namespace.

     oc delete commonservice common-service -n $operatorNamespace
     oc delete commonservice common-service -n $servicesNamespace
    
  5. Uninstall the IBM Cloud Pak foundational services operator from the operator namespace.

     oc delete csv -l operators.coreos.com/ibm-common-service-operator.$operatorNamespace -n $operatorNamespace
     oc delete subscription -l operators.coreos.com/ibm-common-service-operator.$operatorNamespace -n $operatorNamespace
    
  6. Delete the IBM Cloud Pak foundational services APIs from the operator namespace and service namespace.

    1. Delete the OperandRequest instances.

       oc delete operandrequest --all -n $operatorNamespace
       oc delete operandrequest --all -n $servicesNamespace
      
    2. Delete the OperandConfig instances.

       oc delete operandconfig --all -n $operatorNamespace
       oc delete operandconfig --all -n $servicesNamespace
      
    3. Delete the OperandRegistry instances.

       oc delete operandregistry --all -n $operatorNamespace
       oc delete operandregistry --all -n $servicesNamespace
      
    4. Delete the NamespaceScope instances.

       oc delete namespacescope --all -n $operatorNamespace
      
  7. Uninstall the Operand Deployment Lifecycle Manager operator.

     oc delete csv -l operators.coreos.com/ibm-odlm.$operatorNamespace -n $operatorNamespace
     oc delete subscription -l operators.coreos.com/ibm-odlm.$operatorNamespace -n $operatorNamespace
    
  8. Uninstall the IBM NamespaceScope operator if it exists.

     oc delete csv -l operators.coreos.com/ibm-namespace-scope-operator.$operatorNamespace -n $operatorNamespace
     oc delete subscription -l operators.coreos.com/ibm-namespace-scope-operator.$operatorNamespace -n $operatorNamespace
    
  9. Delete operator and service namespaces.

    oc delete namespace $operatorNamespace
    oc delete namespace $servicesNamespace
    

    Note: If namespace deletion fails or hangs, patch out the finalizers for remaining objects in the namespaces.

    • Determine which resources to patch by running the following command:

        oc describe namespace <foundational-services-namespace>
      

      Under the Conditions field, look for the NamespaceContentRemaining Type.

        Conditions:
        Type                                         Status  LastTransitionTime               Reason                Message
        ----                                         ------  ------------------               ------                -------
        NamespaceFinalizersRemaining                 True    Wed, 25 Jan 2023 12:10:16 -0800  SomeFinalizersRemain  Some content in the namespace has finalizers remaining: commonui.operators.ibm.com in 1 resource instances, commonui1.operators.ibm.com in 1 resource instances
      
      • For each resource listed in NamespaceContentRemaining, run the following two commands:

         oc get <resource type> -n <foundational-services-namespace>
        

        For example, resource type commonwebuis.operators.ibm.com. Note down the names of the resources.

         oc patch <resource type> <resource name> -n <cs namespace> --type="json" -p '[{"op": "remove", "path":"/metadata/finalizers"}]'
        
  10. Delete additional cluster resources.

    1. Delete the common-service-maps ConfigMap.

      • If you have other IBM Cloud Pak foundational services instances v3.x installed in the cluster, update the common-service-maps ConfigMap in kube-public namespace, to delete the namespace mapping for the IBM Cloud Pak foundational services instance that you are uninstalling.

          oc edit configmap common-service-maps -n kube-public
        

        For example, if you are uninstalling the IBM Cloud Pak foundational services instance from namespace cpfs-v4-operator-ns and cpfs-v4-services-ns with cloudpak-tethered-ns-a, remove the following entry:

          kind: ConfigMap
          apiVersion: v1
          metadata:
          name: common-service-maps
          namespace: kube-public
          data:
              common-service-maps.yaml: |
                  controlNamespace: cs-control
                  namespaceMapping:
                      - map-to-common-service-namespace: cpfs-v4-services-ns    <-- Remove this entry starting from here
                          requested-from-namespace:
                          - cpfs-v4-operator-ns
                          - cpfs-v4-services-ns
                          - cloudpak-tethered-ns-a                              <-- Remove this entry ending here
                      - map-to-common-service-namespace: cpfs-v3-ns
                          requested-from-namespace:
                          - cpfs-v3-ns
                          - cloudpak-tethered-ns-b
        
        • If all the IBM Cloud Pak foundational services instances are v4.x in the cluster, delete the common-service-maps ConfigMap in kube-public namespace.
        oc delete configmap common-service-maps -n kube-public
        
    2. Delete the ibm-cs-ns-mapping-webhook-configuration ValidatingWebhookConfiguration.

      oc delete validatingwebhookconfiguration ibm-cs-ns-mapping-webhook-configuration --ignore-not-found
      
    3. Delete the ibm-common-service-validating-webhook-<operator-namespace> ValidatingWebhookConfiguration.

      oc delete validatingwebhookconfiguration ibm-common-service-validating-webhook-$operatorNamespace --ignore-not-found
      
    4. Delete the ibm-operandrequest-webhook-configuration-<operator-namespace> MutatingWebhookConfiguration.

      oc delete mutatingwebhookconfiguration ibm-operandrequest-webhook-configuration-$operatorNamespace --ignore-not-found
      

Uninstalling individual services

If you want to delete one or more services, complete the following steps:

  1. Log in to the cluster by using the oc login command.

  2. Find the OperandRequest created by IBM Cloud Paks in the IBM Cloud Paks namespaces.

  3. Run the following command to edit the OperandRequest:

     oc edit operandrequest <operandrequest-name> -n <IBM Cloud Paks namespaces>
    

    The following is an example of an OperandRequest definition:

     apiVersion: operator.ibm.com/v1alpha1
     kind: OperandRequest
     metadata:
       name: common-service
       namespace: <IBM Cloud Paks namespaces>
     spec:
       requests:
         - operands:
             - name: ibm-im-operator
             - name: ibm-platformui-operator
           registry: common-service
    
  4. Delete the service that you want to uninstall from your cluster from the list of operands. For example, if you want to uninstall the ibm-platformui-operator service, the OperandRequest definition would resemble the following code:

     apiVersion: operator.ibm.com/v1alpha1
     kind: OperandRequest
     metadata:
       name: common-service
       namespace: <IBM Cloud Paks namespaces>
     spec:
       requests:
         - operands:
             - name: ibm-im-operator
           registry: common-service
    
  5. Save the changes and close the editor.