How to Use Secrets Manager with DigitalOcean Kubernetes

Last verified 1 Dec 2026

DigitalOcean Secrets Manager provides a central place to store and manage sensitive values used by applications running on DigitalOcean.

The DigitalOcean Secrets Manager integration for DigitalOcean Kubernetes (DOKS) uses the Kubernetes Secrets Store CSI Driver to retrieve values from Secrets Manager and make them available to applications running in DOKS.

You can mount secret values into a pod as files, sync them to a Kubernetes Secret, and refresh them when a new version becomes current.

Before You Begin

Make sure you have:

  • A DOKS cluster and kubectl configured to access it
  • Helm installed
  • Permission to install cluster components and deploy workloads
  • A personal access token with the secret:read scope
  • A secret created in DigitalOcean Secrets Manager, including the secret name, region, and key your application needs

Create an API Token Secret

Create a Kubernetes Secret that stores your DigitalOcean personal access token in the same namespace as the application that mounts Secrets Manager values. The Secret must use the key doApiToken.

touch token.env
vi token.env   # Add one line: doApiToken=YOUR_DO_API_TOKEN
kubectl create secret generic do-secrets-manager-token \
  --from-env-file=token.env \
  -n default
rm -f token.env

Replace <your-do-api-token> with your personal access token. Limit the token to the scopes your workload needs. The integration needs only the secret:read scope.

If you enable secret rotation, label the Secret so the CSI driver can use it during refresh:

kubectl label secret do-secrets-manager-token secrets-store.csi.k8s.io/used=true -n default

Install the Secrets Store CSI Driver

Install the DigitalOcean Secrets Store CSI Driver Helm chart. By default, the chart also installs the upstream Secrets Store CSI Driver:

helm install csi-secrets-store-provider-do \
  oci://ghcr.io/digitalocean-packages/csi-secrets-store-provider-do \
  --version 0.1.0 \
  -n kube-system

To enable automatic rotation at install time, add the following flags:

helm install csi-secrets-store-provider-do \
  oci://ghcr.io/digitalocean-packages/csi-secrets-store-provider-do \
  --version 0.1.0 \
  -n kube-system \
  --set secrets-store-csi-driver.enableSecretRotation=true \
  --set secrets-store-csi-driver.rotationPollInterval=2m

rotationPollInterval defaults to 2m. The example sets it explicitly to show where to change it. Set a shorter interval only for testing.

Verify that the CSI driver pods are running:

kubectl get pods -n kube-system

Create a SecretProviderClass

Create a file named secret-provider-class.yaml. The following example maps the password key from a DigitalOcean secret named app-database to a file named database-password:

File: secret-provider-class.yaml

apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
  name: app-secrets
  namespace: default
spec:
  provider: do-secrets-manager
  parameters:
    secrets: |
      - secretName: app-database
        region: nyc3
        fileName: database-password
        key: password

Update the following values for your secret:

  • secretName: The name of the secret in DigitalOcean Secrets Manager.
  • region: The region containing the secret.
  • fileName: The filename created in the mounted volume. If you omit this field, the driver uses secretName.
  • key: The key containing the value required by the application. If you omit this field, the driver returns the full JSON object.

Apply the SecretProviderClass:

kubectl apply -f secret-provider-class.yaml

Sync Secret Values to a Kubernetes Secret

To also write the value to a Kubernetes Secret, open secret-provider-class.yaml and add a secretObjects block. The objectName value must match the mounted fileName.

File: secret-provider-class.yaml

apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
  name: app-secrets
  namespace: default
spec:
  provider: do-secrets-manager
  parameters:
    secrets: |
      - secretName: app-database
        region: nyc3
        fileName: database-password
        key: password
  secretObjects:
    - secretName: app-synced-secret
      type: Opaque
      data:
        - objectName: database-password
          key: password

Re-apply secret-provider-class.yaml to the cluster:

kubectl apply -f secret-provider-class.yaml

The driver creates the synced Kubernetes Secret when a pod mounts the SecretProviderClass. Applications can then use envFrom or secretKeyRef.

Mount the Secret in a Pod

Create a file named secrets-demo.yaml. The following example mounts the secret at /mnt/secrets-store/database-password. The nodePublishSecretRef must reference the API token Secret in the same namespace as the pod:

File: secrets-demo.yaml

apiVersion: v1
kind: Pod
metadata:
  name: secrets-demo
  namespace: default
spec:
  containers:
    - name: application
      image: busybox:1.37
      command:
        - sleep
        - infinity
      volumeMounts:
        - name: secrets-store
          mountPath: /mnt/secrets-store
          readOnly: true
  volumes:
    - name: secrets-store
      csi:
        driver: secrets-store.csi.k8s.io
        readOnly: true
        volumeAttributes:
          secretProviderClass: app-secrets
        nodePublishSecretRef:
          name: do-secrets-manager-token

Deploy the pod:

kubectl apply -f secrets-demo.yaml

Confirm that the pod is running:

kubectl get pod secrets-demo

Verify the Mounted Secret

Confirm that the expected file was created:

kubectl exec secrets-demo -- ls /mnt/secrets-store

Verify that the application can read the mounted value:

kubectl exec secrets-demo -- cat /mnt/secrets-store/database-password

Avoid displaying production secret values in shared terminals, logs, screenshots, or support requests.

Verify Secret Refresh

To verify that the mounted value refreshes after you enable rotation:

  1. Confirm that the workload can access the current value.
  2. Update the corresponding value in DigitalOcean Secrets Manager.
  3. Wait for the configured polling interval.
  4. Read the mounted file again.
  5. Confirm that the file contains the current secret value.
  6. Verify that the application can use the updated credential.

Understand Application Refresh Behavior

The CSI driver can refresh a mounted file without restarting the pod. The application must reread the file before it can use the updated value. Applications that read credentials only during startup may require a configuration reload or pod restart.

Use Updated Values with Environment Variables

Environment variables in a running process do not change when the underlying Kubernetes Secret is updated. If your application consumes synchronized secrets through environment variables, restart or replace the pod after the Kubernetes Secret changes. You can automate this with a Kubernetes controller such as Reloader. Reloader watches Kubernetes Secrets and performs a rolling restart of the affected workload when their values change.

For example, annotate a Deployment so Reloader restarts it when app-synced-secret changes:

kubectl annotate deployment <your-deployment-name> -n default secret.reloader.stakater.com/reload=app-synced-secret

Replace <your-deployment-name> with the name of your deployment.

We recommend a rolling restart for applications that load credentials from environment variables during startup.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.