> [!CAUTION]
> You are currently viewing version 1.7 of the Apigee hybrid documentation. **This version is end of life.** You should upgrade to a newer version. For more information, see [Supported versions](https://docs.cloud.google.com/apigee/docs/hybrid/supported-platforms.md.txt#supported-versions).

<button class="button button-with-icon cloud-select-dropdown__button button-primary" aria-haspopup="true">Version 1.7 (unsupported)</button>

- Supported versions:
- [v1.17 (latest)](https://docs.cloud.google.com/apigee/docs/hybrid/v1.17/decommission-org.md.txt)
- [v1.16](https://docs.cloud.google.com/apigee/docs/hybrid/v1.16/decommission-org.md.txt)
- [v1.15](https://docs.cloud.google.com/apigee/docs/hybrid/v1.15/decommission-org.md.txt)
- [v1.14](https://docs.cloud.google.com/apigee/docs/hybrid/v1.14/decommission-org.md.txt)
- [List of supported versions](https://docs.cloud.google.com/apigee/docs/hybrid/supported-platforms.md.txt#supported-versions)
- Unsupported versions:
- [v1.13](https://docs.cloud.google.com/apigee/docs/hybrid/v1.13/decommission-org.md.txt)
- [v1.12](https://docs.cloud.google.com/apigee/docs/hybrid/v1.12/decommission-org.md.txt)
- [v1.11](https://docs.cloud.google.com/apigee/docs/hybrid/v1.11/decommission-org.md.txt)
- [v1.10](https://docs.cloud.google.com/apigee/docs/hybrid/v1.10/decommission-org.md.txt)
- [v1.9](https://docs.cloud.google.com/apigee/docs/hybrid/v1.9/decommission-org.md.txt)
- [v1.8](https://docs.cloud.google.com/apigee/docs/hybrid/v1.8/decommission-org.md.txt)
- [v1.7](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/decommission-org.md.txt)
- [v1.6](https://docs.cloud.google.com/apigee/docs/hybrid/v1.6/decommission-org.html)
- [v1.5](https://docs.cloud.google.com/apigee/docs/hybrid/v1.5/decommission-org.html)
- [v1.4](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/decommission-org.html)
- [v1.3](https://docs.cloud.google.com/apigee/docs/hybrid/v1.3/decommission-org.html)
- [v1.2](https://docs.cloud.google.com/apigee/docs/hybrid/v1.2/decommission-org.html)
- [v1.1](https://docs.cloud.google.com/apigee/docs/hybrid/v1.1/decommission-org.html)


This document outlines the steps to decommission an org from a hybrid deployment. Decommissioning
an org means deleting all data related to the org across all Cassandra pods in all Kubernetes
clusters.

> [!WARNING]
> Please ensure there is no live traffic going to the org you plan to remove.

## Limitations


Only one org can be decommissioned at a time. Decommissioning multiple orgs simultaneously is not
supported.

## Get the org name

Some commands in these instructions require you to use a properly formatted org name.

To get the org name for use in commands on this page:


1. Retrieve the org name from the org's `overrides.yaml` file.
2. If the org name contains any dashes ("-"), replace them with underscores ("_").

## Instructions

Follow these instructions to decommission an org from a hybrid deployment.

1. Back up the org
   1. If it's not already enabled, enable backups on the hybrid deployment. In multi-region setups, use the hybrid deployment operating in the primary region. See [Cassandra backup overview](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/cassandra-backup-overview.md.txt) for information on hybrid backups.
   2. Trigger a hybrid backup job using the following command:

      ```
      kubectl create job -n apigee --from=cronjob/apigee-cassandra-backup BACKUP_JOB_NAME
      ```

      <br />


      The <var translate="no">BACKUP_JOB_NAME</var> can be any valid container name.
   3. Once the backup job completes, use the "Check the status of the backup job" and
      "Check the backup logs" instructions in [Monitoring backups](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/monitor-cassandra-backups.md.txt)
      to verify the backup was successful.

2. **(Optional)** If you have configured Apigee Telemetry (Metrics and Logger) on the org to be deleted, follow these steps to reconfigure them so that the metrics and log data apply to a new org/project.
   1. Run this command for the org where you want to send the data. Be sure to use the `overrides.yaml` file for the org. For example, if the org to be decommissioned is "test-dev" the `overrides.yaml` file should contain an `org: test-dev` org field.


      ```
      apigeectl apply --telemetry -f overrides.yaml
      ```

      <br />

   2. Run this command, making sure to use the correct org/project:

      ```
      kubectl -n apigee get apigeetelemetry apigee-telemetry -oyaml | grep `gcpProjectID:`
      ```
3. Delete the org's Kubernetes resources from the hybrid deployment. Be sure to use the
   `overrides.yaml` file for the org. For example, if the org to be decommissioned is
   "test-dev" the `overrides.yaml` file should contain an `org: test-dev`
   org field.

   For multi-region hybrid deployments, run these commands against each hybrid deployment in
   each region.

   ```
   kubectl config current-context # Verify the current context is the correct context for the hybrid deployment
   apigeectl check-ready -f overrides.yaml # Check the deployment status
   apigeectl delete --settings virtualhost -f overrides.yaml
   apigeectl check-ready -f overrides.yaml # Check the deployment status
   apigeectl delete --all-envs -f overrides.yaml
   apigeectl check-ready -f overrides.yaml # Check the deployment status
   apigeectl delete --org -f overrides.yaml
   apigeectl check-ready -f overrides.yaml # Check the deployment status
       
   ```
4. Delete the org data from the hybrid deployment. **Once this step is complete all org data
   will be gone from the hybrid deployment.**
   1. Exec into the `apigee-cassandra-default-0` pod:

      ```
      kubectl exec -it -n apigee apigee-cassandra-default-0 -- /bin/bash
      ```
   2. Execute the following command. Copy the list of all the names that are shown in the output. This list will be needed later.

      ```
      find /opt/apigee/data/apigee-cassandra/ -iname '*ORG_NAME_hybrid' -type d -maxdepth 2 -printf "%f\n"
      ```


      See [Get org name](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/decommission-org.md.txt#get-org-name) for instructions on how to find and prepare the
      <var translate="no">ORG_NAME</var>.

      Exit from the `apigee-cassandra-default-0` pod.
   3. Create a Cassandra debug client pod as described in [Create a client container for debugging](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/ts-cassandra.md.txt#create-a-client-container-for-debugging). Move on to the next step after getting a `cqlsh` prompt.
   4. Execute the following commands in the `cqlsh` prompt:

      ```
      desc keyspaces;
      ```

      Make sure this command returns no errors.

      For each name in the list created earlier from the `apigee apigee-cassandra-default-0`,
      run the following commands:

      ```
      drop keyspace ;
      ```

      Exit from the Cassandra debug client pod.
   5. Perform a rolling restart of all Cassandra pods. Restarting the Cassandra pods can be done in any order as long as only one Cassandra pod is restarted at a time. For multi-region deployments, perform a rolling restart on all Cassandra pods in each hybrid region. Run the following command and verify the state shows "Running":

      ```
      kubectl get apigeeds -n apigee
      ```

      Restart a single Cassandra pod with the following command:

      ```
      kubectl delete pod -n apigee CASSANDRA_POD_NAME
      ```

      Wait for the pod to reach `Running` state using:

      ```
      kubectl get pods -n apigee
      ```

      Restart the next Cassandra pod.
   6. After executing the `cqlsh` commands, run the following commands on all Cassandra pods in the hybrid deployment. For multi-region hybrid deployments, run the commands on all Cassandra pods in all hybrid regions.

      ```
      kubectl exec -it -n apigee CASSANDRA_POD_NAME -- /bin/bash
      ```

      ```
      find /opt/apigee/data/apigee-cassandra/ -iname '*ORG_NAME_hybrid' -type d -maxdepth 2
      ```

      See [Get org name](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/decommission-org.md.txt#get-org-name) for instructions on how to find and prepare the
      <var translate="no">ORG_NAME</var>.

      ```
      find /opt/apigee/data/apigee-cassandra/ -iname '*ORG_NAME_hybrid' -type d -maxdepth 2 -exec rm -rf {} +
      ```
   7. Exit from the Cassandra pod.