---
title: How to Use Secrets Manager with DigitalOcean Kubernetes
description: Access DigitalOcean Secrets Manager secrets from DigitalOcean Kubernetes (DOKS) clusters.
product: Secrets Manager
url: https://docs.digitalocean.com/products/secrets-manager/how-to/doks/
last_updated: "2026-12-01"
---

> **For AI agents:** The documentation index is at [https://docs.digitalocean.com/llms.txt](https://docs.digitalocean.com/llms.txt). Markdown versions of pages use the same URL with `index.html.md` in place of the HTML page (for example, append `index.html.md` to the directory path instead of opening the HTML document).

# How to Use Secrets Manager with DigitalOcean Kubernetes

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](https://docs.digitalocean.com/products/kubernetes/how-to/connect-to-cluster/index.html.md)
- Helm installed
- Permission to install cluster components and deploy workloads
- A [personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) 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`.

```shell
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:

```shell
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:

```shell
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:

```shell
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:

```shell
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`

```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:

```shell
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`

```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:

```shell
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`

```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:

```shell
kubectl apply -f secrets-demo.yaml
```

Confirm that the pod is running:

```shell
kubectl get pod secrets-demo
```

## Verify the Mounted Secret

Confirm that the expected file was created:

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

Verify that the application can read the mounted value:

```shell
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](https://github.com/stakater/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:

```shell
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.

## Related Topics

- [Manage Secrets in the Control Panel](https://docs.digitalocean.com/products/secrets-manager/how-to/console/index.html.md)
- [Manage Secrets with doctl](https://docs.digitalocean.com/products/secrets-manager/how-to/doctl/index.html.md)
- [Versions and Rotations](https://docs.digitalocean.com/products/secrets-manager/concepts/versions-and-rotations/index.html.md)
- [Secrets Manager Limits](https://docs.digitalocean.com/products/secrets-manager/details/limits/index.html.md)