Removing Elasticsearch resources

Follow these steps to remove the leftover Elasticsearch resources.

Before you begin

Make sure that you have completed the data migration from Elasticsearch to OpenSearch before running this script.

To remove Elasticsearch resources. you need the OpenShift command-line interface (CLI), the oc command, on your client machine.

Procedure

  1. Download the cert-kubernetes repository to a Linux® based machine (CentOS Stream/RHEL/MacOS) or a client to a Linux-based machine.
  2. Change the directory to the scripts folder under cert-kubernetes/scripts. For more information, see Preparing a client to connect to the cluster.
  3. Choose one of the two options below based on your Cloud Pak for Business Automation version:
    • Option 1: From 24.0.0-IF001 Use the following steps to remove Elasticsearch resources.
    1. Run the cp4a-remove-elasticsearch.sh script found in the cert-kubernetes repository.
      The following options are available:
       ./cp4a-remove-elasticsearch.sh -h
      Usage: ./cp4a-remove-elasticsearch.sh -h -n
       -h Display help.
       -n Enter the namespace where Elasticsearch is installed.
       -s Use this option to skip confirmation.
    2. Log in by using the OpenShift CLI to log in to the target cluster as the <cluster-admin> user.
      oc login https://<cluster-ip>:<port> -u <cluster-admin> -p <password>
    3. If you are not already logged in, on ROCKS, run the following command:
      oc login --token=<token> --server=https://<cluster-ip>:<port>
    4. Run the script by specifying the namespace using the -n option:
      ./cp4a-remove-elasticsearch.sh -n <ELASTICSEARCH_NAMESPACE>

      The <ELASTICSEARCH_NAMESPACE> is the target project where Elasticsearch is installed.

    • Option 2: For 24.0.0-GA Use the following steps to remove Elasticsearch resources.
    1. Retrieve the name of the instance:
      oc get Elasticsearch -n <namespace>
    2. Delete an instance:
      oc delete Elasticsearch iaf-system -n <namespace>
    3. Retrieve the names of the Subscriptions:
      oc get Subscription -n <namespace>
    4. Delete Elasticsearch Subscription:
      oc delete Subscription <elasticsearch-subscription> -n <namespace>
    5. Retrieve the names of the OperandRequests:
      oc get OperandRequest -n <namespace>
    6. Delete Elasticsearch OperandRequest:
      oc delete OperandRequest elastic-request -n <namespace>
    7. Retrieve the names of the Deployments:
      oc get Deployment -n <namespace>
    8. Delete Elasticsearch Operator Deployment:
      oc delete Deployment ibm-elastic-operator-controller-manager -n <namespace>
    9. Retrieve the names of the Issuers:
      oc get Issuer -n <namespace>
    10. Delete Elasticsearch Issuer:
      oc delete Issuer foundation-iaf-automationbase-ab-issuer -n <namespace>
    11. Retrieve the names of the Secrets:
      oc get Secret -n <namespace>
    12. Delete Elasticsearch Secrets:
      oc delete Secrets foundation-iaf-automationbase-ab-ca -n <namespace>
    13. Retrieve the names of the Network Policies:
      oc get NetworkPolicy -n <namespace>
    14. Delete Elasticsearch Network Policy:
      oc delete NetworkPolicy <cr_name>-cp4a-egress-allow-elasticsearch -n <namespace>
    15. Retrieve the names of the Routes:
      oc get Route -n <namespace>
    16. Delete Elasticsearch Route:
      oc delete Route iaf-system-es -n <namespace>
    17. Delete the Elasticseacrh CSV operator.
      oc delete csv $csv_name -n $namespace
      Important: Make sure you delete the Elasticsearch operator ibm-automation-elastic.v1.xxx and not the OpenSearch operator ibm-elasticsearch-operator.v1.xxx. Accidentally deleting the wrong one causes OpenSearch operator failure.