Skip to content

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:

Set environment variables

export NAMESPACE="DATAROBOT_NAMESPACE"
export DATAROBOT_VERSION="X.X.X"

Note

  • Replace DATAROBOT_NAMESPACE with your DataRobot namespace.
  • Replace X.X.X with the installed DataRobot chart version (helm list -n ${NAMESPACE}). The commands below expect the chart at datarobot-prime-${DATAROBOT_VERSION}.tgz and your values in values_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%40ss for p@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=server command in the steps below requires.
  • Back up the pcs-* Secrets and the datarobot-image-pullsecret Secret:

    kubectl -n ${NAMESPACE} get -o yaml \
      $(kubectl -n ${NAMESPACE} get secret -o name | grep -E 'secret/(pcs-|datarobot-image-pullsecret)') \
      > dr-secrets-backup.yaml
    

    Check that dr-secrets-backup.yaml contains the pcs-* Secrets before you continue. If the command fails with an error asking for a resource type, no Secret matched; check NAMESPACE.

    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 credentialSecretsUpgradeHook
    

    Don't skip that step if you set credentialSecretsUpgradeHook: false in your values, or if you deploy with Argo CD or helm template instead of helm upgrade. To detect a changed password, the chart reads the pcs-* Secrets from the cluster when Helm renders the chart. Argo CD and plain helm template render the chart without cluster access.

  • If you set passwords in your values file, set secretLock: false in the values file. With secretLock: true, the chart refuses a changed password and the upgrade fails with secret rotation not supported.

  • Remove any connection string that contains a database password from your values file, such as a MONGO_URI set under core.config_env_vars or under a service's envVars. DataRobot builds its connection strings from the pcs-* 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 databases[].password, or 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 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:

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.

  1. Set the new password in your shell:

    export NEW_PASSWORD='NEW_PASSWORD'
    

    Note

    Replace NEW_PASSWORD with the new password. Keep the single quotes.

  2. Change the password inside each database you rotate:

    • MongoDB: Find the primary. Run the following command for pcs-mongo-0, pcs-mongo-1, and pcs-mongo-2. The primary prints true:

      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-0 with 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 prints f:

      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, and username keys of the pcs-postgresql Secret, and the username key of each pcs-db-<database> Secret. Replace ROLE_NAME with the role and pcs-postgresql-0 with 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_PASSWORD again 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, and pcs-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.

  3. Set the new password in your values file (see Where each password is set).

  4. Apply the Secrets as described in step 3 of Rotate an external database password set in values.
  5. 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
    
  6. Restart DataRobot services.

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.

  1. Change the password in the database.
  2. Set the new password where it is configured (see Where each password is set).
  3. 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 existingSecret that 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. The credentialSecretsUpgradeHook=false setting 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 template for one of the files, the chart doesn't render the Secret for that database in your configuration. Remove that --show-only line.

  4. 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
    
  5. Restart DataRobot services.

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.

  1. Change the password in the database.
  2. Change the password in the external secret store.
  3. Force a refresh, so the pcs-* Secrets get the new password right away. Otherwise, they don't update until the next refreshInterval, which defaults to 1h:

    for es in $(kubectl -n ${NAMESPACE} get externalsecret -o name | grep '/pcs-'); do
      kubectl -n ${NAMESPACE} annotate ${es} force-sync=$(date +%s) --overwrite
    done
    
  4. Check that each ExternalSecret synced. The READY column shows True and the STATUS column shows SecretSynced:

    kubectl -n ${NAMESPACE} get externalsecret | grep pcs-
    
  5. 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
    
  6. Restart DataRobot services.

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"): Change global.imageCredentials.password in 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_URL with the registry that DataRobot pulls images from (for example, docker.io or your private registry), REGISTRY_USERNAME with the registry username, and NEW_REGISTRY_PASSWORD with the new password. Keep the single quotes, so the shell doesn't change special characters in the password. If you set global.imageCredentials.name, use that name instead of datarobot-image-pullsecret.

  • An external secret store creates the image pull Secret: Change the password in the external secret store. Then force the datarobot-image-pullsecret ExternalSecret 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:

  1. 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.
  2. Check that every pcs-* Secret in dr-secrets-backup.yaml still exists in the namespace (kubectl -n ${NAMESPACE} get secret). If a pcs-* 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 -
    
  3. Update the out-of-date Secret:

  4. Run helm upgrade again.

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.