Uninstalling a Business Automation Insights deployment

You can uninstall Business Automation Insights resources either from the command line or through the Rancher platform.

Before you begin

If you need to back up your data, make sure that you take the necessary steps to reinstall the deployment. For example, make a copy of the custom resource (CR) that you used in the environment. Make copies of the security definitions that are used to protect the configuration data in the environment. Make copies of the persistent volumes (PV) and persistent volume claims (PVC) in the environment.

About this task

Uninstalling and cleaning up the cluster involves several separate high-level tasks.

  • Uninstalling the BAI deployment.
  • Uninstalling the operators.
  • Deleting PVs and PVCs. If you do delete the PVs and PVCs, the persistent data along with configuration and log files are also deleted. Delete the PVCs before you delete the PVs.
  • Deleting the secrets created by the BAI deployment. Set the project to the BAI project and search for secrets and then delete the secrets.

If you do delete all the secrets that you created for IBM® Business Automation Insights, then you must create them again if you want to install another BAI deployment.

  • Deleting the BAI project.
  • Uninstalling the Cloud Pak foundational services is necessary only if you want to completely clean up the cluster. The uninstallation of Business Automation Insights uninstalls Cloud Pak foundation services only and does not remove the Cloud Pak foundation services operators and some of its resources. To completely remove Cloud Pak foundational services, see Uninstalling foundational services External link opens a new window or tab .

To uninstall the BAI deployment, use the following steps.

Procedure

  1. You can delete your custom resource deployments by deleting the CR YAML file or the CR instance. The name of the instance is taken from the value of the name parameter in the CR YAML file. To retrieve the names of the instances, run the get command.
    kubectl get InsightsEngine

    To delete an instance, run the delete command.

    kubectl delete InsightsEngine <MY-INSTANCE>
  2. To uninstall the operator, run the scripts/deleteOperator.sh script.
    cd cert-kubernetes-bai
    ./scripts/bai-deleteOperator.sh -n <namespace>
    For more information about downloading cert-kubernetes-bai, see Preparing your cluster for an online deployment.
  3. Verify that all the pods that you created with the operator are stopped and deleted.
    Note: Deleting the InsightsEngine and uninstalling the BAI operator does not delete the existing PVs/PVC, or the databases that are used by the various components. Check the persisted data before you delete the PVs/PVCs manually to make sure that you no longer want to keep them. Likewise, if the data no longer needs to be retained or reused you can delete the databases.

What to do next

If you now plan to install another instance of the Business Automation Insights on the same cluster, check if the dependencies like Namespaces, OperandRequests, and so on are properly deleted. If you are sharing the project with another Business Automation Insights, then do not delete the dependencies.

Optional: Deleting PVs

To identify which PV can be removed, check the status of the PV. If the status is Available, then the PVs can be deleted.

  1. Get a list of all the PVs.
    kubectl get pv
  2. Delete a PV.
    kubectl delete pv <PV name>
Deleting secrets
  1. Remove the foundation subscription in the BAI namespace for operators.coreos.com/v1alpha1. Now, all of the BAI secrets can be deleted.
  2. The kubectl delete secret command followed by the name of a secret can be used to delete a secret.

    The BAI secrets include the strings ibm-bai or insightsengine in the names. The custom secrets can also be deleted, for example ldap-bind-secret.

Uninstall Cloud Pak foundational services
Note: If you plan to clean up your Business Automation Insights and Cloud Pak foundational services namespaces after you uninstall the foundational services, then do not delete the Cloud Pak foundational services namespace and the common-service-maps ConfigMap in kube-public namespace. The Cloud Pak foundational services and the common-service-maps ConfigMap in kube-public namespace are required when you run the bai-clean-up.sh script.

If you want to uninstall the Cert Manager from Cloud Pak foundational services, see Manual steps for uninstalling singleton services - Cert Manager External link opens a new window or tab. If your IBM Cert Manager was installed in the ibm-cert-manager namespace, you can delete the namespace.

If you want to uninstall the License Service from Cloud Pak foundational services, see Uninstalling License Service External link opens a new window or tab. If your License Manager was installed in the ibm-licensing namespace, you can delete the namespace.

For more information about uninstalling foundational services, see Uninstalling foundational services External link opens a new window or tab.

Note: You can also run a script if the foundational services uninstallation does not remove all the components. For more information, see Uninstallation is not successful External link opens a new window or tab .
Cleaning up your Business Automation Insights and Cloud Pak foundational services namespaces
You can use the bai-clean-up.sh script to clean up resources that are left over after uninstallation. The script makes sure that all resources from the Business Automation Insights and Cloud Pak foundational services namespaces are cleaned up. If a namespace is not cleaned up, you might not be able to terminate the namespace or some resources might show up when you use the same namespace name. If your Cloud Pak foundational services is not shared with other Cloud Paks, then you can clean up your Business Automation Insights and Cloud Pak foundational services namespaces.

Run the script if one of the following are true:

  • The BAI namespace is not deleted.
  • The common-service-maps ConfigMap in kube-public namespace is not deleted.
  1. Change the directory to the scripts folder under cert-kubernetes-bai/scripts.
    cd /<path_to_cert-kubernetes-bai>/cert-kubernetes-bai/scripts
    Where <path_to_cert-kubernetes-bai> is the path to cert-kubernetes-bai.
  2. Run the bai-clean.sh script to clean up the Business Automation Insights and Cloud Pak foundational services namespaces.
    ./bai-clean.sh -n <bai-ns>
    Where <bai-ns> is the target namespace.
Important: If you installed your BAI deployment with separation of duties, make sure that you use the namespace that contains the BAI deployment and not the BAI operators namespace. If you do not specify a namespace, the script asks you to enter the services namespace.

The script takes the following actions:

  • Checks whether the Cloud Pak foundational services associated with Business Automation Insights is shared and if the script detects that Cloud Pak foundational services is shared, the script cleans only the Business Automation Insights namespace.
  • The script detects if the deployment has separation of duty where the Business Automation Insights operators and Business Automation Insights deployment are in different namespaces. If the Business Automation Insights operators and Business Automation Insights deployment are in different namespaces, the script cleans both the Business Automation Insights and Cloud Pak foundational services namespaces.
  • The script asks whether you have multiple Business Automation Insights deployments on the same cluster. If you select Yes, then the Business Automation Insights related custom resource definitions are not deleted. If you select No, then the Business Automation Insights related custom resource definitions are deleted.
  • The script displays the list of resources in each namespace to be deleted. You need to confirm whether to clean up the Business Automation and Cloud Pak foundational services namespaces including deleting the namespace where the Business Automation Insights instance is installed.
Deleting the BAI project
Note: If deleting a project fails and the project is stuck in the Terminating state, some objects may still exist in the namespace after a force deletion. Do not use the same project name to rebuild instead use a new project name.

Use the kubectl get namespace command to list the available and currently selected project. The kubectl delete namesapce command can be used to delete a project. In the following example, bai-project is deleted.

kubectl delete namespace bai-project

The project might not terminate successfully until you uninstall the Cloud Pak foundational services.

Note: If foundational services are installed in a namespace-scoped instance in the same namespace as the BAI deployment, then delete the BAI project after you uninstalled the foundational services. For more information, see Uninstalling foundational services External link opens a new window or tab.

If a project remains in the terminating state, run the following command to find the associated resources that are stuck.

kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found -n <NAMESPACE>|grep -E -v "packagemanifest|Normal|Warning|NAME|MESSAGE|message:"
Note: You might also see messages from the cluster about the resources that cannot be deleted.
 message: 'Some resources are remaining: namespacescopes.operator.ibm.com has 2
      resource instances, operandbindinfos.operator.ibm.com has 1 resource instances,
      operandrequests.operator.ibm.com has 3 resource instances, rolebindings.authorization.openshift.io
      has 1 resource instances, rolebindings.rbac.authorization.k8s.io has 1 resource
      instances' 

From the example messages, you can see that the following resources are stuck.

  • namespacescopes.operator.ibm.com
  • operandbindinfos.operator.ibm.com
  • operandrequests.operator.ibm.com
  • rolebindings.authorization.openshift.io
  • rolebindings.rbac.authorization.k8s.io

When you have a list of the blocked resources, run the following command to delete them.

for i in $(kubectl get <resource_name> -n <NAMESPACE> --no-headers | awk '\{print $1}'); do                                                                                                                                                                                    
    kubectl patch <resource_name>/$i -p '\{"metadata":{"finalizers":[]}}' --type=merge -n <NAMESPACE>
    kubectl delete <resource_name> $i -n <NAMESPACE>
done 
Deleting the catalog sources
If you decide to remove BAI completely, then remove the related catalog sources.
  1. Click Search > Catalog Sources
  2. Delete the following sources:
    • bts-operator
    • ibm-bai-operator-catalog
    • cloud-native-postgresql-catalog
    • ibm-cert-manager-catalog
    • ibm-cs-install-catalog
    • ibm-cs-opensearch-catalog
    • ibm-events-operator-catalog
    • ibm-iam-operator-catalog
    • ibm-licensing-catalog
    • ibm-opencontent-flink
    • ibm-zen-operator-catalog
Optional: Deleting custom resource definitions
If you plan to remove all the dependencies, the custom resource definitions (CRD) for both Business Automation Insights and the Cloud Pak foundational services can be deleted.
Note: Do not delete the custom resource definitions if you have other Business Automation Insights deployment on the cluster.

Search for CustomResourceDefinitions by name and delete it.

Delete the following CRDs from the cluster.
insightsengines.bai.ibm.com
foundations.bai.ibm.com