Skip to content

Secrets

Mount Secrets fields into pods as files, through pod identity.

Updated View as Markdown

The secrets-store add-on mounts fields of your Secrets into pods as files. It runs the Kubernetes Secrets Store CSI Driver with an EZGH provider, and reads each secret as the pod’s bot, through pod identity. No API key is stored in the cluster.

Set it up

  1. Add the add-on:

    ezgh kubernetes addons create secrets-store --cluster kcl_3k9d0a1m2x7q --wait
  2. Give the pod’s service account a pod identity association with a bot that can read the secret (secrets.versions.access on it, or a grant).

  3. Create a SecretProviderClass with provider ezgh naming the secrets and fields to mount, and mount it in the pod as a CSI volume with driver secrets-store.csi.k8s.io:

    apiVersion: secrets-store.csi.x-k8s.io/v1
    kind: SecretProviderClass
    metadata:
      name: checkout
      namespace: shop
    spec:
      provider: ezgh
      parameters:
        objects: |
          - secret: stripe
            field: apiKey
          - secret: sec_6v2b8n4m1c3x
            path: database
    ---
    apiVersion: v1
    kind: Pod
    metadata:
      name: checkout
      namespace: shop
    spec:
      serviceAccountName: checkout
      containers:
        - name: app
          image: shop/checkout:1.4
          volumeMounts:
            - name: secrets
              mountPath: /mnt/secrets
              readOnly: true
      volumes:
        - name: secrets
          csi:
            driver: secrets-store.csi.k8s.io
            readOnly: true
            volumeAttributes:
              secretProviderClass: checkout

Each entry of objects:

Field
secret The secret, by ID (sec_…) or name. Required
version A version number. Default the latest
field One field to mount. Left out, every field of the secret, each a file named after it
path The file a field is written to (default the field’s name), or the directory every field is written under

parameters.project reads the secrets from another project (prj_…); by default they’re read from the cluster’s.

Rotation

The add-on reads each mounted secret again every 10 minutes and updates the files when a new version is current. Applications that read the file again see the new value. Each read is a billed Secrets read; the add-on’s rotationPollInterval configuration (at least 1m, for example 30m or 1h) changes how often.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close