Use a Secrets Manager
Keep the credentials of a self-hosted Soda Runner in HashiCorp Vault and sync them into Kubernetes with the External Secrets Operator, so that rotated passwords reach the runner without a redeploy.
A self-hosted Soda Runner connects to your data sources from your own Kubernetes cluster, so the data source credentials can stay in your environment. This guide keeps every credential the runner needs in HashiCorp Vault: the user name and password of the data source, and the runner's own API key. None of them appears in Soda Cloud or in the Helm values of the runner.
The External Secrets Operator (ESO) copies the credentials from Vault into Kubernetes secrets and reads Vault again at a set interval. The runner mounts the data source credentials into every job it starts, and the data source configuration in Soda Cloud refers to them as environment variables. When you rotate the password in Vault, the next job uses the new one.
The examples use a PostgreSQL database sales_dw with a read-only user soda_reader, and a runner in the namespace soda-runner. The setup has these parts:
Vault
Holds the credentials under secret/soda/ in a KV version 2 secrets engine
SecretStore
Tells ESO how to reach Vault and how to authenticate, here with an AppRole
ExternalSecret
Tells ESO which Vault secret to copy into which Kubernetes secret, and how often to refresh it
Soda Runner
Reads its API key from one Kubernetes secret and mounts the data source credentials from another into its jobs
Data source in Soda Cloud
Refers to the credentials as ${env.POSTGRES_USER} and ${env.POSTGRES_PASSWORD}
ESO supports other secrets managers, such as AWS Secrets Manager and Azure Key Vault. With another provider, you store the credentials there and write a SecretStore for that provider; the runner and the data source configuration stay the same.
Prerequisites
A Kubernetes cluster, with
kubectland Helm installed. See Deploy a Soda Runner in a Kubernetes cluster for the network access the runner needs.A Vault server that pods in the cluster can reach, with a KV version 2 secrets engine mounted at
secret, and thevaultCLI logged in with permission to write policies and enable auth methods.A PostgreSQL database that the cluster can reach, with a read-only user for Soda. See PostgreSQL for the grants.
In Soda Cloud, the global permission Create data sources and manage runners. See Global and dataset roles.
Store the credentials in Vault
Store the user name and password of the database user in Vault. read -rs reads the password without showing it, and password=- makes Vault read it from standard input, so it does not end up in your shell history:
Give ESO read access to Vault
Create a policy that can read the secrets under secret/soda/. With KV version 2, the policy path includes data/:
Write the policy, enable the AppRole auth method, and create a role with the policy:
ESO logs in with the role ID and a secret ID of this role, and uses the token it receives to read the secrets.
Install the External Secrets Operator
Install ESO with its Helm chart:
The operator serves its resources in the API version external-secrets.io/v1.
Sync the credentials into Kubernetes
Create the namespace of the runner, and a Kubernetes secret with the role ID and a new secret ID of the AppRole. The values go from vault straight into the secret:
Create a SecretStore that connects to Vault with the AppRole. Set server to the address of your Vault server:
Create an ExternalSecret that copies the database credentials into the Kubernetes secret sales-postgres-credentials:
A few details in the two resources:
A
SecretStoreserves only theExternalSecretresources in its own namespace. To share one Vault connection across namespaces, use aClusterSecretStore: add thenamespaceof thevault-approlesecret toroleRefandsecretRef, and setkind: ClusterSecretStoreinsecretStoreRef. See SecretStore and ClusterSecretStore in the ESO documentation.dataFrom.extractreads every key of the Vault secretsoda/sales-postgres, so the template can use.usernameand.password.The template writes a single key,
sales_postgres.env, in the dotenv format. The runner reads each key of the secret as a file of environment variables. The single quotes keep characters such as#,$, and spaces in the password as they are. See Templating for the template syntax.refreshIntervalsets how often ESO reads Vault and updates the Kubernetes secret. Without it, ESO refreshes every hour. Match it to how soon the runner must pick up a rotated password.
Apply both resources and check that they are ready:
Deploy the runner
Sync the API key into Kubernetes
The runner uses its API key twice: to connect to Soda Cloud, and to pull its images from the Soda container registry. Create two ExternalSecret resources, one for each:
The registry is registry.us.soda.io for the US region of Soda Cloud and registry.cloud.soda.io for the EU region.
Install the runner
Create a values file that points the runner at the three Kubernetes secrets:
A few details in the values:
soda.apikey.existingSecretandsecretKeysname the secret and the keys that hold the API key ID and secret.imageCredentials.create: falsestops the chart from creating its own registry secret from the API key, andexistingImagePullSecretsgives it the one that ESO maintains.soda.scanLauncher.existingSecretsmounts each listed secret into every job the runner starts, including contract verifications, and tells the job to read the mounted files as environment variables.soda.cloud.regionisusoreu, the region of your Soda Cloud organization.
Install the runner:
Once the runner registers with Soda Cloud, it shows up in Settings > Runners, with a green dot under Last seen while it is online.

For every value of the Helm chart, see Soda Runner: additional information.
Connect the data source
Add the data source in Soda Cloud on the new runner:
Go to Data Sources, click New Data Source, and select PostgreSQL.
Under Data Source Identifier, enter
sales_postgres.Under Default Runner, in Default Scan Runner, select
secrets-manager-guide.
The data source runs on the self-hosted runner Under Connection Details, enter the host, port, and database. In User, enter
${env.POSTGRES_USER}, and in Password, enter${env.POSTGRES_PASSWORD}.Click Test connection. When the test passes, click Connect and complete the remaining steps.

Soda Cloud stores only the variable names. The runner's jobs resolve them from the mounted secret. This is the data source configuration that Soda Cloud stores:
To create the data source with the REST API instead, send this configuration in configurationFileContents to POST /api/v1/datasources, with the runner's ID in runnerId. See the REST API reference.
After you connect the data source, onboard its datasets and verify contracts as with any other data source. Every scan runs on the runner with the credentials from Vault.

fact_internet_sales, verified on the runnerFor the onboarding steps, see Onboard datasets on Soda Cloud.
Rotate the password
To rotate the password, change it in the database:
Then update it in Vault. vault kv patch changes the password and keeps the user name:
At its next refresh, ESO writes the new password to the Kubernetes secret, and every job that the runner starts after that uses it. You don't redeploy or restart the runner. Until the refresh, jobs use the old password, so keep the refreshInterval of the ExternalSecret short enough for your rotation.
Next steps
Use Soda secrets for credentials that Soda Cloud stores. See Onboard datasets on Soda Cloud.
Verify contracts on the runner from Soda Cloud or on a schedule. See Verify a contract.
Configure the runner further. See Soda Runner: additional information.
Last updated
Was this helpful?
