Uninstalling foundational services

Uninstalling foundational services in an online environment

Uninstall all services, or only selected services from your cluster.

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 <span data-key-file="/home/jenkins/workspace/workspace/dita-converter/git_repo/conrefs.yml" data-conkeyref="conrefs/keyword.cs" data-variable="keyword.cs" class="md-conref">keyword.cs</span> operator is deployed. For example, the <span data-key-file="/home/jenkins/workspace/workspace/dita-converter/git_repo/conrefs.yml" data-conkeyref="conrefs/keyword.cs_ns" data-variable="keyword.cs_ns" class="md-conref">keyword.cs_ns</span> 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 <span data-key-file="/home/jenkins/workspace/workspace/dita-converter/git_repo/conrefs.yml" data-conkeyref="conrefs/keyword.cs" data-variable="keyword.cs" class="md-conref">keyword.cs</span> 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 <span data-key-file="/home/jenkins/workspace/workspace/dita-converter/git_repo/conrefs.yml" data-conkeyref="conrefs/keyword.cs" data-variable="keyword.cs" class="md-conref">keyword.cs</span> 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 <span data-key-file="/home/jenkins/workspace/workspace/dita-converter/git_repo/conrefs.yml" data-conkeyref="conrefs/keyword.cs" data-variable="keyword.cs" class="md-conref">keyword.cs</span> instances v3.x installed in the cluster, update the common-service-maps ConfigMap in kube-public namespace, to delete the namespace mapping for the <span data-key-file="/home/jenkins/workspace/workspace/dita-converter/git_repo/conrefs.yml" data-conkeyref="conrefs/keyword.cs" data-variable="keyword.cs" class="md-conref">keyword.cs</span> instance that you are uninstalling.

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

        For example, if you are uninstalling the <span data-key-file="/home/jenkins/workspace/workspace/dita-converter/git_repo/conrefs.yml" data-conkeyref="conrefs/keyword.cs" data-variable="keyword.cs" class="md-conref">keyword.cs</span> 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 <span data-key-file="/home/jenkins/workspace/workspace/dita-converter/git_repo/conrefs.yml" data-conkeyref="conrefs/keyword.cs" data-variable="keyword.cs" class="md-conref">keyword.cs</span> 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.

Uninstalling foundational services in an air-gapped environment

Uninstall IBM Cloud Pak foundational services in your cluster that has no Internet connectivity.

Run the following commands to uninstall foundational services:

  1. Uninstall the catalog source.

    oc ibm-pak case launch \
      --case ./ \
      --inventory ibmCommonServiceOperatorSetup \
      --action uninstall-catalog \
      --namespace ${NAMESPACE} \
      --args "--registry <IP_or_FQDN_of_your_local_registry>:5000 --user admin --pass admin"
    
  2. Uninstall the foundational services operators.

    oc ibm-pak case launch \
      --case ./ \
      --inventory ibmCommonServiceOperatorSetup \
      --action uninstall-operator \
      --namespace ${NAMESPACE} \
      --args "--registry <IP_or_FQDN_of_your_local_registry>:5000 --user admin --pass admin"
    
  3. Verify that the CatalogSource is removed.

    oc get pods -n openshift-marketplace
    oc get catalogsource -n openshift-marketplace
    
  4. Verify that the foundational services are removed.

    oc get pod -n ${NAMESPACE}