Uninstalling watsonx Assistant
An instance administrator can uninstall watsonx Assistant.
- Who needs to complete this task?
-
Instance administrator To uninstall watsonx Assistant, you must be an instance administrator. An instance administrator has permission to manage software in the following projects:
- The operators project for the instance
-
The operators for this instance of IBM Software Hub are installed in the operators project. In the uninstall commands, the
${PROJECT_CPD_INST_OPERATORS}environment variable refers to the operators project. - The operands project for the instance
-
The IBM Software Hub control plane and the services for this instance of IBM Software Hub are installed in the operands project. In the uninstall commands, the
${PROJECT_CPD_INST_OPERANDS}environment variable refers to the operands project.
- When do you need to complete this task?
-
Complete this task if you want to remove watsonx Assistant from an instance of IBM Software Hub.
Repeat as needed If you are responsible for multiple instances of IBM Software Hub, you can repeat this task to remove other instances of watsonx Assistant on the cluster.
Information you need to complete this task
Review the following information before you uninstall watsonx Assistant:
- Environment variables
- The commands in this task use environment variables so that you can run the commands exactly as
written.
- If you don't have the script that defines the environment variables, see Setting up installation environment variables.
- To use the environment variables from the script, you must source the environment variables
before you run the commands in this task. For example,
run:
source ./cpd_vars.sh
Dependent services
Before you uninstall watsonx Assistant, ensure that the following services are uninstalled:
Procedure
Complete the following tasks to uninstall watsonx Assistant:
Deleting service instances
Before you uninstall watsonx Assistant, you must delete any service instances that are associated with watsonx Assistant to ensure that each instance releases the resources that it reserved.
- Who needs to complete this task?
- A user with the Manage service instances permission must complete this task.
- When do you need to complete this task?
- Complete this task before you uninstall watsonx Assistant.
From the IBM Software Hub web client:
- Log in to the web client as a user with sufficient permissions to complete the task.
- From the menu, select .
- Filter the list to show the assistant type.
-
Delete each assistant instance in the list.
Uninstalling the service
To uninstall watsonx Assistant:
-
Log the
cpd-cliin to the Red Hat® OpenShift® Container Platform cluster:${CPDM_OC_LOGIN}Remember:CPDM_OC_LOGINis an alias for thecpd-cli manage login-to-ocpcommand. - Get the name of the watsonx Assistant
service.
oc get WatsonAssistant --namespace ${PROJECT_CPD_INST_OPERANDS} - Set the
INSTANCEenvironment variable to the name of the watsonx Assistant service:export INSTANCE=<wa-instance-name> - Delete the custom resource and operator for watsonx Assistant.
cpd-cli manage uninstall-components \ --instance_ns=${PROJECT_CPD_INST_OPERANDS} \ --components=watson_assistant \ --include_dependency=trueWait for thecpd-clito return the following message:[SUCCESS]... The uninstall-components command ran successfully
Cleaning up the remaining resources
- Who needs to complete this task?
- You must be an administrator of the project where watsonx Assistant is installed.
- When do you need to complete this task?
- Complete this task to clean up resources after you remove watsonx Assistant from your deployment.
- Create a file named
wxa_cleanup_script.shin your working directory. - Copy the following content in
wxa_cleanup_script.sh.#!/bin/bash ################################################################################ # Watson Assistant Cleanup Script # This script performs comprehensive cleanup of Watson Assistant resources: # Deletes data from Deployment Verification Tests # Deletes Persistent Volume Claims # Deletes Temporary Patches # Cleans up Multicloud Object Gateway # Deletes Secrets # Cleans up Data Governor ################################################################################ set -eu # Check and set environment variables check_and_set_env_vars() { echo "Checking required environment variables..." # Check PROJECT_CPD_INST_OPERANDS if [[ -z "${PROJECT_CPD_INST_OPERANDS}" ]]; then echo "PROJECT_CPD_INST_OPERANDS is not set" exit 1 fi echo "PROJECT_CPD_INST_OPERANDS: ${PROJECT_CPD_INST_OPERANDS}" # Check INSTANCE if [[ -z "${INSTANCE}" ]]; then echo "INSTANCE is not set" exit 1 fi echo "Watson Assistant instance '${INSTANCE}' verified" } # Step 1: Delete Deployment Verification Tests delete_dvt() { echo "Step 1: Checking for Deployment Verification Tests..." dvt_list=$(oc get dvt -n ${PROJECT_CPD_INST_OPERANDS} --no-headers 2>/dev/null | awk '{print $1}' || true) if [[ -z "${dvt_list}" ]]; then echo "No DVT resources found" return fi for dvt_name in ${dvt_list}; do echo "Deleting DVT: ${dvt_name}" oc delete dvt ${dvt_name} -n ${PROJECT_CPD_INST_OPERANDS} || echo "Failed to delete DVT: ${dvt_name}" done } # Step 2: Delete Persistent Volume Claims delete_pvcs() { echo "Step 2: Deleting Persistent Volume Claims..." pvc_list=$(oc get pvc -n ${PROJECT_CPD_INST_OPERANDS} --no-headers 2>/dev/null | grep "${INSTANCE}-" | awk '{print $1}' || true) if [[ -z "${pvc_list}" ]]; then echo "No PVCs found for instance: ${INSTANCE}" return fi for pvc_name in ${pvc_list}; do echo "Deleting PVC: ${pvc_name}" oc delete pvc ${pvc_name} -n ${PROJECT_CPD_INST_OPERANDS} || echo "Failed to delete PVC: ${pvc_name}" done } # Step 3: Delete Temporary Patches delete_temporary_patches() { echo "Step 3: Deleting Temporary Patches..." tp_list=$(oc get temporarypatch -n ${PROJECT_CPD_INST_OPERANDS} --no-headers 2>/dev/null | grep "${INSTANCE}-" | awk '{print $1}' || true) if [[ -z "${tp_list}" ]]; then echo "No Temporary Patches found for instance: ${INSTANCE}" return fi for tp_name in ${tp_list}; do echo "Deleting Temporary Patch: ${tp_name}" # Try normal delete first if ! timeout 30s oc delete temporarypatch ${tp_name} -n ${PROJECT_CPD_INST_OPERANDS} 2>/dev/null; then echo "Delete hung up, removing finalizers for: ${tp_name}" oc patch temporarypatch ${tp_name} -n ${PROJECT_CPD_INST_OPERANDS} --type=merge -p '{"metadata": {"finalizers":null}}' || echo "Failed to patch: ${tp_name}" fi done } # Step 4: Clean up Multicloud Object Gateway cleanup_mcg() { echo "Step 4: Cleaning up Multicloud Object Gateway..." # Check if mc (MinIO client) is installed if ! command -v mc &> /dev/null; then echo "MinIO client (mc) not found. Skipping MCG cleanup." echo "To install: https://min.io/docs/minio/linux/reference/minio-mc.html" return fi # Get MCG endpoint echo "Getting MCG endpoint..." export MCG_ENDPOINT="$(oc get route s3 --namespace openshift-storage --output jsonpath='https://{.spec.host}' 2>/dev/null || true)" if [[ -z "${MCG_ENDPOINT}" ]]; then echo "MCG endpoint not found. Skipping MCG cleanup." return fi echo "MCG Endpoint: ${MCG_ENDPOINT}" # Get access keys echo "Extracting MCG access keys..." export MCG_ACCESS_KEY="$(oc extract secret/noobaa-account-watson-assistant --keys=AWS_ACCESS_KEY_ID --to=- --namespace ${PROJECT_CPD_INST_OPERANDS} 2>/dev/null || true)" export MCG_SECRET_KEY="$(oc extract secret/noobaa-account-watson-assistant --keys=AWS_SECRET_ACCESS_KEY --to=- --namespace ${PROJECT_CPD_INST_OPERANDS} 2>/dev/null || true)" if [[ -z "${MCG_ACCESS_KEY}" ]] || [[ -z "${MCG_SECRET_KEY}" ]]; then echo "MCG credentials not found. Skipping MCG cleanup." return fi # Configure MinIO client echo "Configuring MinIO client..." mc alias set assistant "${MCG_ENDPOINT}" "${MCG_ACCESS_KEY}" "${MCG_SECRET_KEY}" --insecure || { echo "Failed to configure MinIO client. Skipping MCG cleanup." return } # List buckets to verify connection echo "Listing buckets..." mc ls assistant --insecure || { echo "Failed to list buckets. Skipping MCG cleanup." mc alias remove assistant 2>/dev/null || true return } # Delete Watson Assistant buckets buckets=("nlclassifier-icp" "wa-api-prod-wa-v1" "icp") for bucket in "${buckets[@]}"; do bucket_name="${bucket}-${PROJECT_CPD_INST_OPERANDS}" if mc ls assistant/${bucket_name} --insecure &>/dev/null; then echo "Deleting bucket contents: ${bucket_name}" mc rm --recursive --force assistant/${bucket_name} --insecure || echo "Failed to delete contents of: ${bucket_name}" echo "Removing bucket: ${bucket_name}" mc rb assistant/${bucket_name} --insecure || echo "Failed to remove bucket: ${bucket_name}" else echo "Bucket not found: ${bucket_name}" fi done # Remove MinIO client configuration echo "Removing MinIO client configuration..." mc alias remove assistant || echo "Failed to remove MinIO alias" } # Step 5: Delete Secrets delete_secrets() { echo "Step 5: Deleting Secrets..." secret_list=$(oc get secret -n ${PROJECT_CPD_INST_OPERANDS} --no-headers 2>/dev/null | grep "${INSTANCE}-" | awk '{print $1}' || true) if [[ -z "${secret_list}" ]]; then echo "No Secrets found for instance: ${INSTANCE}" return fi for secret_name in ${secret_list}; do echo "Deleting Secret: ${secret_name}" oc delete secret ${secret_name} -n ${PROJECT_CPD_INST_OPERANDS} || echo "Failed to delete Secret: ${secret_name}" done } # Step 6: Clean up Data Governor cleanup_data_governor() { echo "Step 6: Cleaning up Data Governor..." dg_name="${INSTANCE}-data-governor" echo "Data Governor Instance Name - $dg_name" # Check if Data Governor exists if oc get dg ${dg_name} -n ${PROJECT_CPD_INST_OPERANDS} &>/dev/null; then echo "Removing finalizers from Data Governor: ${dg_name}" oc patch dg ${dg_name} -n ${PROJECT_CPD_INST_OPERANDS} --patch '{"metadata": {"finalizers": []}}' --type merge || echo "Failed to patch Data Governor" echo "Deleting Data Governor: ${dg_name}" oc delete dg ${dg_name} -n ${PROJECT_CPD_INST_OPERANDS} || echo "Failed to delete Data Governor" else echo "Data Governor not found: ${dg_name}" fi # Delete Data Governor PVCs echo "Checking for Data Governor PVCs..." dg_pvc_list=$(oc get pvc -n ${PROJECT_CPD_INST_OPERANDS} --no-headers 2>/dev/null | grep "data-governor" | awk '{print $1}' || true) if [[ -z "${dg_pvc_list}" ]]; then echo "No Data Governor PVCs found" return fi for pvc_name in ${dg_pvc_list}; do echo "Deleting Data Governor PVC: ${pvc_name}" oc delete pvc ${pvc_name} -n ${PROJECT_CPD_INST_OPERANDS} || echo "Failed to delete PVC: ${pvc_name}" done } echo "==========================================" echo "Watson Assistant Cleanup Script" echo "==========================================" echo "" check_and_set_env_vars echo "------------------------------------" cleanup_data_governor echo "------------------------------------" delete_pvcs echo "------------------------------------" delete_temporary_patches echo "------------------------------------" cleanup_mcg echo "------------------------------------" delete_secrets echo "------------------------------------" echo "==========================================" echo "Cleanup completed!" echo "==========================================" - Change the script permission.
chmod +x wxa_cleanup_script.sh - Run the script.
sh wxa_cleanup_script.sh