Rotating Cassandra credentials in Hashicorp Vault Stay organized with collections Save and categorize content based on your preferences.
Overview
This procedure describes rotating Cassandra credentials within Hashicorp Vault. For rotating credentials in Kubernetes secrets in your cluster, seeRotating Cassandra credentials in Kubernetes secrets.
This feature allows platform administrators to:
- Rotate Cassandra credentials in Hashicorp Vault.
- Roll back to the previous Cassandra credentials in Vault in case of any issues during password rotation.
- Rotate the Cassandra password for one region at a time, so that you can ensure minimal impact on service availability and maintain control over the rotation process.
- Track the start, progress, and completion of the rotation for a single region.
This feature is available in Apigee Hybrid 1.13.1 and later.
Note: Before using this feature, you must have Vault storage of Cassandra credentials set up. Follow the instructions inStoring Cassandra secrets in Hashicorp VaultBefore you begin
Before setting up credential rotation:
- Backup your Cassandra database. This backup is to ensure recovery is possible to pre-rotated credentials.
- Ensure the cluster is in a healthy state (i.e. all Apigee resources are running, no state changes are pending).
kubectl apply -f within the cluster to set up credential rotation.Single region setup
- Create a new
SecretProviderClassKubernetes resource in your Apigee namespace for the new Cassandra credentials.SeeStoring Cassandra secrets in Hashicorp Vault for a template to use.This allows a Vault role to access secrets within the Kubernetes namespaces. - Create a new
SecretRotationcustom resource using the following template:# rotation.yamlapiVersion: apigee.cloud.google.com/v1alpha1kind: SecretRotationmetadata: name:ROTATION_PROCESS_NAME namespace:APIGEE_NAMESPACEspec: organizationId:ORG_NAME rotationId:ROTATION_ID timeoutMinutes: 480 # optional. overrides the default (480m == 8hr). # less than or equal to 0 means infinite timeout. precheck: true cassandra: oldSecretProviderClass:OLD_SPC_NAME newSecretProviderClass:NEW_SPC_NAME jobType: ROTATE
- ROTATION_PROCESS_NAME: A unique name for the rotation job. You will need to set
metadata.nameto a unique value for the rotation precheck job and again for the rotation job. For examplesr-1-precheckfollowed bysr-1. - ROTATION_ID: Set
spec.rotationIdto a custom identifier, for examplerotation-1-precheck. - NEW_SPC_NAME: Set
spec.cassandra.newSecretProviderClassto the new secret provider class name you created in the previous step. - OLD_SPC_NAME: Set
spec.cassandra.oldSecretProviderClassto the SPC name currently being used by theApigeeDatastore.
- ROTATION_PROCESS_NAME: A unique name for the rotation job. You will need to set
- Trigger the rotation precheck job by applying the
rotation.yamlfile.kubectl -nAPIGEE_NAMESPACE apply -f rotation.yaml
- Check the job status to verify when the precheck job is complete.
Tip: You can also view the logs while the job is running.kubectl -nAPIGEE_NAMESPACE get job sr-(rotationId)-(rotate|rollback|cleanup)-job
kubectl -nAPIGEE_NAMESPACE logs sr-(rotationId)-(rotate|rollback|cleanup)-job-(hash)
- Once the rotation precheck job completes, change the value of
metadata.nameand setspec.prechecktofalse. Apply the file again to perform the rotation.kubectl -nAPIGEE_NAMESPACE apply -f rotation.yaml
- After the rotation job completes and you have validated traffic is still flowing correctly, clean up the process with the following two steps:
- Update the value of
metadata.nameand setspec.cassandra.jobTypetoCLEANUP. - Trigger the cleanup job by applying the file.
Note: Up until this step, you can trigger arollback job to revert the rotation process and leave the cluster in its original state.kubectl -nAPIGEE_NAMESPACE apply -f rotation.yaml
When the cleanup job is completed, the rotation process is complete.
- Update the value of
- Update your overrides file and set
cassandra.auth.secretProviderClassto the new secret provider class (newSecretProviderClass).cassandra: auth: secretProviderClass:NEW_SPC_NAME
- Backup your Cassandra database. This backup is to ensure recovery is possible to post-rotated credentials.
- Delete the old Cassandra credentials, role, and policy from Vault.
Multi-region setup
The multi-region setup procedures are divided into two sections: setup for the first region and setup for the remaining regions.
- Complete the following steps in the first region before starting the subsequent regions.
- Create a new
SecretProviderClassKubernetes resource in theAPIGEE_NAMESPACEnamespace for the new Cassandra credentials. SeeStoring Cassandra secrets in Hashicorp Vault for a template to use. This allows a Vault role to access secrets within the Kubernetes namespaces. - Create a new
SecretRotationcustom resource using the following template:# rotation.yamlapiVersion: apigee.cloud.google.com/v1alpha1kind: SecretRotationmetadata: name:ROTATION_PROCESS_NAME namespace:APIGEE_NAMESPACEspec: organizationId:ORG_NAME rotationId:ROTATION_ID timeoutMinutes: -1 # this value is required and should not be changed. precheck: true cassandra: oldSecretProviderClass:OLD_SPC_NAME newSecretProviderClass:NEW_SPC_NAME jobType: ROTATE
- ROTATION_PROCESS_NAME: A unique name for the rotation job. You will need to set
metadata.nameto a unique value for the rotation precheck job and again for the rotation job. For examplesr-1-precheckfollowed bysr-1. - ROTATION_ID: Set
spec.rotationIdto a custom identifier, for examplerotation-1-precheck. - NEW_SPC_NAME: Set
spec.cassandra.newSecretProviderClassto the new secret provider class name you created in the previous step. - OLD_SPC_NAME: Set
spec.cassandra.oldSecretProviderClassto the SPC name currently being used by theApigeeDatastore.
- ROTATION_PROCESS_NAME: A unique name for the rotation job. You will need to set
- Trigger the rotation precheck job by applying the
rotation.yamlfile.kubectl -nAPIGEE_NAMESPACE apply -f rotation.yaml
- Check the job status to verify when the precheck job is complete.
Tip: You can also view the logs while the job is running.kubectl -nAPIGEE_NAMESPACE get job sr-(rotationId)-(rotate|rollback|cleanup)-job
kubectl -nAPIGEE_NAMESPACE logs sr-(rotationId)-(rotate|rollback|cleanup)-job-(hash)
- Once the rotation precheck job completes:
- Change the value of
metadata.name, for example fromsr-1-prechecktosr-1. - Set
spec.prechecktofalseto turn off the precheck and perform the rotation. - Set
spec.rotationIdto a new identifier, for examplerotation-1.
- Change the value of
- Apply the file again to perform the rotation.
kubectl -nAPIGEE_NAMESPACE apply -f rotation.yaml
- Check the state of the
SecretRotationand wait until it iscomplete.kubectl -nAPIGEE_NAMESPACE get srSR_NAME
- Create a new
- In each subsequent region, complete the following steps:
- Create a new
SecretProviderClassKubernetes resource in your Apigee namespace for the new Cassandra credentials.SeeStoring Cassandra secrets in Hashicorp Vault for a template to use.This should be the same definition as step 1a. - Update your
overrides.yamland setcassandra.auth.secretProviderClassto the match the value ofspec.cassandra.newSecretProviderClassin therotation.yamlfile.cassandra: auth: secretProviderClass:NEW_SPC_NAME
- Apply the operator chart:
helm upgrade operator apigee-operator/ \ --namespaceAPIGEE_NAMESPACE \ --atomic \ -fOVERRIDES_FILE
- A new
ReplicaSetwill be created. Check that the new controller-manager pods are using the new SPC:export POD=NEW_CONTROLLER_MANAGER_POD_NAME
kubectl -nAPIGEE_NAMESPACE get pods $POD -o jsonpath='{.spec.volumes[?(@.name=="apigee-external-secrets")].csi.volumeAttributes.secretProviderClass}'The result should match the value you set for
spec.cassandra.newSecretProviderClassinrotation.yaml, for example:kubectl -n apigee get pods $POD -o jsonpath='{.spec.volumes[?(@.name=="apigee-external-secrets")].csi.volumeAttributes.secretProviderClass}'my-new-spc - Apply the datastore chart:
Note: Applying the datastore chart will also trigger releases for the organization and environments.helm upgrade datastore apigee-datastore/ \ --namespaceAPIGEE_NAMESPACE \ --atomic \ -fOVERRIDES_FILE
- The datastore will go into a releasing state. Wait until the datastore has finished releasing and is in the running state.
kubectl -nAPIGEE_NAMESPACE get apigeedatastoreDATASTORE_NAME
DATASTORE_NAME is
defaultin most installations. - Check that the new datastore pods are using the new SPC:
export POD=NEW_DATASTORE_POD_NAME
kubectl -nAPIGEE_NAMESPACE get pods $POD -o jsonpath='{.spec.volumes[?(@.name=="apigee-external-secrets")].csi.volumeAttributes.secretProviderClass}'The result should match the value you set for
spec.cassandra.newSecretProviderClassinrotation.yaml, for example:kubectl -n apigee get pods $POD -o jsonpath='{.spec.volumes[?(@.name=="apigee-external-secrets")].csi.volumeAttributes.secretProviderClass}'my-new-spc - Wait until the organization and environments are done releasing and have returned to the running state.
kubectl -nAPIGEE_NAMESPACE get apigeeorgORG_NAME
kubectl -nAPIGEE_NAMESPACE get apigeeenvENV_NAME - Check that the new MART, runtime, and synchronizer pods are using the new SPC:
export POD=NEW_MART_POD_NAME
kubectl -nAPIGEE_NAMESPACE get pods $POD -o jsonpath='{.spec.volumes[?(@.name=="apigee-external-secrets")].csi.volumeAttributes.secretProviderClass}'export POD=NEW_RUNTIME_POD_NAMEkubectl -nAPIGEE_NAMESPACE get pods $POD -o jsonpath='{.spec.volumes[?(@.name=="apigee-external-secrets")].csi.volumeAttributes.secretProviderClass}'export POD=NEW_SYNCHRONIZER_POD_NAMEkubectl -nAPIGEE_NAMESPACE get pods $POD -o jsonpath='{.spec.volumes[?(@.name=="apigee-external-secrets")].csi.volumeAttributes.secretProviderClass}'The result should match the value you set for
spec.cassandra.newSecretProviderClassinrotation.yaml, for example:kubectl -n apigee get pods $POD -o jsonpath='{.spec.volumes[?(@.name=="apigee-external-secrets")].csi.volumeAttributes.secretProviderClass}'my-new-spc
- Create a new
- After completing the steps in every region and validate traffic is still flowing correctly, clean up the process in the first region with the following two steps:
- In the first region, update the value of
metadata.nameand setspec.cassandra.jobTypetoCLEANUP. - Trigger the cleanup job by applying the file.
kubectl -nAPIGEE_NAMESPACE apply -f rotation.yaml
- Check the job status and watch the job logs to verify when the cleanup job is complete.
When the cleanup job is completed, the rotation process is complete.
- In the first region, update the value of
- Update your overrides file and set
cassandra.auth.secretProviderClassto the new secret provider class (newSecretProviderClass).cassandra: auth: secretProviderClass:NEW_SPC_NAME
- Backup your Cassandra database. This backup is to ensure recovery is possible to post-rotated credentials.
- Delete the old Cassandra credentials, role, and policy from Vault.
Rolling back a rotation
Note: You can only roll back a rotation before the cleanup job has been triggered.For multi-region, perform the rollback in each region.
- Create a new SecretRotation custom resource using the following template:
# rollback-rotation.yamlapiVersion: apigee.cloud.google.com/v1alpha1kind: SecretRotationmetadata: name:ROLLBACK_NAME namespace:APIGEE_NAMESPACEspec: organizationId:APIGEE_ORG rotationId:ROTATION_ID # match the current rotation. timeoutMinutes:TIMEOUT_MINUTES # optional. precheck:false cassandra: oldSecretProviderClass:OLD_SPC_NAME # Must match the previous oldSecretProviderClass. newSecretProviderClass:NEW_SPC_NAME # Must match the previous newSecretProviderClass. jobType:ROLLBACK
Where:
- ROLLBACK_NAME: A name for the rollback job, for example:
sr-1-rollback. - APIGEE_NAMESPACE: your Apigee namespace.
- APIGEE_ORG: Your Apigee organization ID.
- ROTATION_ID: The id of the current rotation that you are rolling back, for example:
rot-1. - TIMEOUT_MINUTES: Optional. Overrides the default (480m == 8hr). <=0 means infinite timeout.
- OLD_SPC_NAME: This must match the secret name for
oldSecretProviderClass:in the rotation YAML file you used inSingle region setup orMulti-region setup procedure. - NEW_SPC_NAME: this must match the secret name for
newSecretProviderClass:in the rotation YAML file you used inSingle region setup orMulti-region setup procedure.
- ROLLBACK_NAME: A name for the rollback job, for example:
- Apply the rollback:
kubectl -nAPIGEE_NAMESPACE apply -fROLLBACK_YAML_FILE
- Check the job status and wait for it to complete.
kubectl -nAPIGEE_NAMESPACE describe srROTATION_NAME
- When the rollback(s) complete, verify that traffic is still flowing correctly.
- For multi-region installations, when the traffic is flowing correctly, repeat the rollback process in each region.
- Once you have completed the rollback and verified that traffic is still flowing correctly in all regions, start the cleanup process.
Make the following changes in the rotation YAML file:
- Change
metadata.nameto a name indicating this is a cleanup job, for example:sr-1-cleanup-rollback. - Change
spec.cassandra.jobTypetoCLEANUP_ROLLBACK.
- Change
- Apply the file to trigger the cleanup job:
kubectl -nAPIGEE_NAMESPACE apply -fROTATION_YAML_FILE
- Check the job status and wait for it to complete.
kubectl -nAPIGEE_NAMESPACE describe srROTATION_NAME
When the cleanup job is completed, the rollback process is complete.
- Update your overrides file and set
cassandra.auth.secretProviderClassto the old secret provider class (oldSecretProviderClass).cassandra: auth: secretProviderClass:OLD_SPC_NAME
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-17 UTC.