Rotate database and registry passwords¶
DataRobot keeps the passwords it uses to connect to its databases in Kubernetes Secrets whose names start with pcs-. It keeps the credentials for your image registry in an image pull Secret, datarobot-image-pullsecret by default (the value of global.imageCredentials.name). When a password changes, update the matching Secret before the next helm upgrade. The upgrade runs pre-upgrade jobs, such as dr-queue-migration, that connect to the databases and pull images. If a job starts with an old password, the upgrade fails, and every retry fails the same way until you update the matching Secret.
This page covers the image registry and three database setups:
- Databases that the DataRobot chart installs (bundled PostgreSQL, MongoDB, Redis, and RabbitMQ). To rotate the password of a bundled Elasticsearch, contact DataRobot Support.
- External databases whose passwords are set in your values file. The chart writes the
pcs-*Secrets from your values. - External databases whose passwords come from an external secret store, such as a vault synced by the External Secrets Operator.
Set environment variables¶
export NAMESPACE="DATAROBOT_NAMESPACE"
export DATAROBOT_VERSION="X.X.X"
Note
- Replace
DATAROBOT_NAMESPACEwith your DataRobot namespace. - Replace
X.X.Xwith the installed DataRobot chart version (helm list -n ${NAMESPACE}). The commands below expect the chart atdatarobot-prime-${DATAROBOT_VERSION}.tgzand your values invalues_dr.yaml.
Password requirements¶
DataRobot services put database passwords into connection strings. To make sure every service can use the new password:
- Use only letters, digits, and the characters
-,_,.,~, and*. - Don't use spaces or any of these characters:
@/#%?'"\$:!. - Enter the password as is. Don't percent-encode it (for example, don't write
p%40ssforp@ss). DataRobot encodes passwords itself, and a pre-encoded password is encoded twice and fails to authenticate.
Before you start¶
- Use Helm 3.13 or later, which the
helm template --dry-run=servercommand in the steps below requires. -
Back up the
pcs-*Secrets and thedatarobot-image-pullsecretSecret:kubectl -n ${NAMESPACE} get -o yaml \ $(kubectl -n ${NAMESPACE} get secret -o name | grep -E 'secret/(pcs-|datarobot-image-pullsecret)') \ > dr-secrets-backup.yamlCheck that
dr-secrets-backup.yamlcontains thepcs-*Secrets before you continue. If the command fails with an error asking for a resource type, no Secret matched; checkNAMESPACE.Warning
The backup file contains passwords. Store it securely, and delete it after the rotation succeeds.
-
Check whether your chart version writes a changed database password to its Secret before the pre-upgrade jobs run. If the following command prints
credentialSecretsUpgradeHook: true, the chart writes the changed password for you, and you can skip step 3 of Rotate an external database password set in values:helm show values datarobot-prime-${DATAROBOT_VERSION}.tgz | grep credentialSecretsUpgradeHookDon't skip that step if you set
credentialSecretsUpgradeHook: falsein your values, or if you deploy with Argo CD orhelm templateinstead ofhelm upgrade. To detect a changed password, the chart reads thepcs-*Secrets from the cluster when Helm renders the chart. Argo CD and plainhelm templaterender the chart without cluster access. -
If you set passwords in your values file, set
secretLock: falsein the values file. WithsecretLock: true, the chart refuses a changed password and the upgrade fails withsecret rotation not supported. - Remove any connection string that contains a database password from your values file, such as a
MONGO_URIset undercore.config_env_varsor under a service'senvVars. DataRobot builds its connection strings from thepcs-*Secrets, and a connection string in your values keeps the old password.
Where each password is set¶
If you use an external secret store (global.externalSecretStore.enabled: true), change the password in the store instead of the values file. If you set an existingSecret, change the password in that Secret.
The following table lists the values key for each password and the Secret that holds it in the namespace.
| Database | Values key | Secret in the namespace |
|---|---|---|
| PostgreSQL | postgresql-ha.postgresql.postgresPassword, or global.postgresql.auth.existingSecret |
pcs-postgresql |
| PostgreSQL database per service | global.databases[].password, or global.databases[].existingSecret |
pcs-db-<database> |
| MongoDB | global.mongodb.auth.password, or global.mongodb.auth.existingSecret |
pcs-mongo |
| Redis | global.redis.auth.password |
pcs-redis |
| RabbitMQ | global.rabbitmq.auth.password |
pcs-rabbitmq |
| Elasticsearch | elasticsearch.security.elasticPassword |
pcs-elasticsearch |
| Image registry | global.imageCredentials.password |
datarobot-image-pullsecret (the value of global.imageCredentials.name) |
To rotate the password of a PostgreSQL database per service, add an entry for it under global.databases with only database and the new password. The entry is matched to the default entry by database name, so the username and the pcs-db-<database> Secret stay the same:
global:
databases:
- database: modmon
password: 'NEW_MODMON_PASSWORD'
- database: pipelines
password: 'NEW_PIPELINES_PASSWORD'
MongoDB with LDAP authentication¶
If DataRobot authenticates to MongoDB through LDAP, set the authentication source and mechanism in your values file, including for the workload-api service:
global:
mongodb:
auth_source: $external
auth_mechanism: PLAIN
workload-api:
component:
mongo:
authSource: $external
authMechanism: PLAIN
DataRobot adds these options to every MongoDB connection string it builds. Don't also add authSource or authMechanism to global.mongodb.uri_template, or the options appear twice in the connection string.
Rotate a database password¶
Plan a maintenance window
From the time you change the password in the database until the upgrade finishes, DataRobot services can't connect to that database. Schedule the rotation during a maintenance window.
Follow the section that matches your setup. Each ends with Restart DataRobot services.
Rotate a bundled database password¶
The bundled databases keep their own copy of the password, which doesn't change when the pcs-* Secret changes. Change the password inside each database first, while the pcs-* Secret still holds the old password, and then update the Secret.
-
Set the new password in your shell:
export NEW_PASSWORD='NEW_PASSWORD'Note
Replace
NEW_PASSWORDwith the new password. Keep the single quotes. -
Change the password inside each database you rotate:
-
MongoDB: Find the primary. Run the following command for
pcs-mongo-0,pcs-mongo-1, andpcs-mongo-2. The primary printstrue:kubectl -n ${NAMESPACE} exec pcs-mongo-0 -c mongodb -- bash -c \ 'mongosh --quiet -u "$MONGODB_ROOT_USER" -p "$(cat "$MONGODB_ROOT_PASSWORD_FILE")" --authenticationDatabase admin --eval "db.hello().isWritablePrimary"'Then change the password on the primary. Replace
pcs-mongo-0with the primary:kubectl -n ${NAMESPACE} exec pcs-mongo-0 -c mongodb -- env NEW_PASSWORD="${NEW_PASSWORD}" bash -c \ 'mongosh --quiet -u "$MONGODB_ROOT_USER" -p "$(cat "$MONGODB_ROOT_PASSWORD_FILE")" --authenticationDatabase admin --eval "db.getSiblingDB(\"admin\").changeUserPassword(process.env.MONGODB_ROOT_USER, process.env.NEW_PASSWORD)"' -
PostgreSQL: Find the primary. Run the following command for each
pcs-postgresql-<n>pod. The primary printsf:kubectl -n ${NAMESPACE} exec pcs-postgresql-0 -c postgresql -- bash -c \ 'PGPASSWORD="$(cat "$POSTGRES_POSTGRES_PASSWORD_FILE")" psql -h 127.0.0.1 -U postgres -tAc "SELECT pg_is_in_recovery()"'Then, on the primary, change the password of each role you rotate. The role names are the
postgres-username,repmgr-username, andusernamekeys of thepcs-postgresqlSecret, and theusernamekey of eachpcs-db-<database>Secret. ReplaceROLE_NAMEwith the role andpcs-postgresql-0with the primary:export ROLE='ROLE_NAME' echo "ALTER ROLE :\"role\" WITH PASSWORD :'pw';" \ | kubectl -n ${NAMESPACE} exec -i pcs-postgresql-0 -c postgresql -- env ROLE="${ROLE}" NEW_PASSWORD="${NEW_PASSWORD}" bash -c \ 'PGPASSWORD="$(cat "$POSTGRES_POSTGRES_PASSWORD_FILE")" psql -h 127.0.0.1 -U postgres -v ON_ERROR_STOP=1 -v role="$ROLE" -v pw="$NEW_PASSWORD"'If each role has its own password, set
NEW_PASSWORDagain before each role. -
RabbitMQ: Run the following command once. The change applies to the whole cluster:
kubectl -n ${NAMESPACE} exec pcs-rabbitmq-0 -c rabbitmq -- env NEW_PASSWORD="${NEW_PASSWORD}" bash -c \ 'rabbitmqctl change_password "$RABBITMQ_USERNAME" "$NEW_PASSWORD"' -
Redis: Run the following commands for each of
pcs-redis-node-0,pcs-redis-node-1, andpcs-redis-node-2. The commands update the Redis server and the Sentinel that monitors it:kubectl -n ${NAMESPACE} exec pcs-redis-node-0 -c redis -- env NEW_PASSWORD="${NEW_PASSWORD}" bash -c \ 'export REDISCLI_AUTH="$(cat "$REDIS_PASSWORD_FILE")"; redis-cli CONFIG SET masterauth "$NEW_PASSWORD" && redis-cli CONFIG SET requirepass "$NEW_PASSWORD"' kubectl -n ${NAMESPACE} exec pcs-redis-node-0 -c sentinel -- env NEW_PASSWORD="${NEW_PASSWORD}" bash -c \ 'redis-cli -p 26379 SENTINEL SET redis0 auth-pass "$NEW_PASSWORD"'
If you enabled TLS for a bundled database, add the TLS options for that client to its command.
-
-
Set the new password in your values file (see Where each password is set).
- Apply the Secrets as described in step 3 of Rotate an external database password set in values.
-
Run the upgrade with the same chart version and values file:
helm upgrade --install dr datarobot-prime-${DATAROBOT_VERSION}.tgz \ --namespace ${NAMESPACE} \ --values values_dr.yaml
Rotate an external database password set in values¶
Use this section if DataRobot connects to a database it doesn't install, and the password is set in your values file or in the Secret named in existingSecret.
- Change the password in the database.
- Set the new password where it is configured (see Where each password is set).
-
Apply the Secrets. Skip this step if your chart version writes the Secrets for you (see Before you start), or if you set the password in an
existingSecretthat you already updated.The command below renders only the
pcs-*Secrets from your values and writes them to the cluster before the upgrade. For any Secret value you didn't change, the command reuses the value already stored in the cluster. ThecredentialSecretsUpgradeHook=falsesetting makes the chart render each Secret once; chart versions that don't have the setting ignore it:helm template dr datarobot-prime-${DATAROBOT_VERSION}.tgz \ --namespace ${NAMESPACE} \ --values values_dr.yaml \ --set credentialSecretsUpgradeHook=false \ --dry-run=server \ --show-only templates/postgresql-initdb.yaml \ --show-only templates/mongodb-secrets.yaml \ --show-only templates/redis-secrets.yaml \ --show-only templates/rabbitmq-secrets.yaml \ --show-only templates/elasticsearch-secrets.yaml \ | kubectl -n ${NAMESPACE} apply -f -If Helm reports
could not find templatefor one of the files, the chart doesn't render the Secret for that database in your configuration. Remove that--show-onlyline. -
Run the upgrade with the same chart version and values file:
helm upgrade --install dr datarobot-prime-${DATAROBOT_VERSION}.tgz \ --namespace ${NAMESPACE} \ --values values_dr.yaml
Rotate an external database password from an external secret store¶
Use this section if the pcs-* Secrets are synced from an external secret store (global.externalSecretStore.enabled: true and externalSecret: true for the database). The chart doesn't write these Secrets; the External Secrets Operator does.
- Change the password in the database.
- Change the password in the external secret store.
-
Force a refresh, so the
pcs-*Secrets get the new password right away. Otherwise, they don't update until the nextrefreshInterval, which defaults to1h:for es in $(kubectl -n ${NAMESPACE} get externalsecret -o name | grep '/pcs-'); do kubectl -n ${NAMESPACE} annotate ${es} force-sync=$(date +%s) --overwrite done -
Check that each ExternalSecret synced. The
READYcolumn showsTrueand theSTATUScolumn showsSecretSynced:kubectl -n ${NAMESPACE} get externalsecret | grep pcs- -
Run the upgrade with the same chart version and values file:
helm upgrade --install dr datarobot-prime-${DATAROBOT_VERSION}.tgz \ --namespace ${NAMESPACE} \ --values values_dr.yaml
Restart DataRobot services¶
DataRobot services read the password when they start. helm upgrade restarts only the services whose configuration changed, so restart the rest to pick up the new password:
kubectl -n ${NAMESPACE} rollout restart deployment
kubectl -n ${NAMESPACE} rollout status deployment --timeout=30m
Rotate the image registry password¶
How you rotate the image registry password depends on how the image pull Secret is created.
- The chart creates the image pull Secret (
global.imageCredentials.createSecret: "true"): Changeglobal.imageCredentials.passwordin your values and run the upgrade. In Release 11.12 and later, the chart writes the image pull Secret before any other pre-upgrade job runs. In earlier releases, also update the image pull Secret yourself before the upgrade, using the command in the next item. -
You create the image pull Secret (
global.imageCredentials.createSecret: "false", the default): Your values file doesn't update the image pull Secret. Update the image pull Secret yourself before you run the upgrade:export REGISTRY_SERVER='REGISTRY_URL' export REGISTRY_USERNAME='REGISTRY_USERNAME' export REGISTRY_PASSWORD='NEW_REGISTRY_PASSWORD' kubectl -n ${NAMESPACE} create secret docker-registry datarobot-image-pullsecret \ --docker-server="${REGISTRY_SERVER}" \ --docker-username="${REGISTRY_USERNAME}" \ --docker-password="${REGISTRY_PASSWORD}" \ --dry-run=client -o yaml \ | kubectl -n ${NAMESPACE} apply -f -Note
Replace
REGISTRY_URLwith the registry that DataRobot pulls images from (for example,docker.ioor your private registry),REGISTRY_USERNAMEwith the registry username, andNEW_REGISTRY_PASSWORDwith the new password. Keep the single quotes, so the shell doesn't change special characters in the password. If you setglobal.imageCredentials.name, use that name instead ofdatarobot-image-pullsecret. -
An external secret store creates the image pull Secret: Change the password in the external secret store. Then force the
datarobot-image-pullsecretExternalSecret to sync, so the image pull Secret gets the new password right away:kubectl -n ${NAMESPACE} annotate externalsecret datarobot-image-pullsecret force-sync=$(date +%s) --overwrite
Recover an upgrade that fails after a password change¶
If a password changes but the matching pcs-* Secret or the image pull Secret still holds the old password, helm upgrade fails with an error such as pre-upgrade hooks failed: resource Job/<namespace>/dr-queue-migration not ready. The output of helm history dr -n ${NAMESPACE} shows the latest revision as failed, and the log of the dr-queue-migration job shows the authentication error:
kubectl -n ${NAMESPACE} logs job/dr-queue-migration
To recover from the failed upgrade:
- Confirm that the new password is wherever your installation reads it from—your values file, the Secret named in
existingSecret, or your external secret store. -
Check that every
pcs-*Secret indr-secrets-backup.yamlstill exists in the namespace (kubectl -n ${NAMESPACE} get secret). If apcs-*Secret is missing, restore the Secrets from the backup. The restored Secrets hold the passwords from before the rotation; the next step writes the new ones:grep -vE '^[[:space:]]+(resourceVersion|uid|creationTimestamp):' dr-secrets-backup.yaml \ | kubectl -n ${NAMESPACE} apply -f - -
Update the out-of-date Secret:
- Database password: Write the
pcs-*Secrets as described in step 3 of Rotate an external database password set in values. If you use an external secret store, force a refresh as described in step 3 of Rotate an external database password from an external secret store instead. - Image registry password: Update the image pull Secret as described in Rotate the image registry password.
- Database password: Write the
- Run
helm upgradeagain.
If helm upgrade fails with secrets "pcs-<name>" already exists, another controller in your cluster also writes that Secret and recreated it while Helm was replacing it. Set credentialSecretsUpgradeHook: false in your values file, and then follow the steps above.
Don't use helm upgrade --no-hooks to get past the failure. The --no-hooks flag skips the database migrations, and it also skips writing the image pull Secret.