KOP Recipes - AWS Secrets Manager Access - Rafay Product Documentation

Access

In this part, you will


Step 1: Create Secret Provider Class

To take advantage of the Secrets Store CSI driver, a SecretProviderClass custom resource will need to be created. This provides driver configurations and parameter specific details to the CSI driver.

Important
The SecretProviderClass must be in the same namespace as the pods referencing it.

Create and Publish Workload

apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
  name: vault-database
spec:
  provider: vault
  parameters:
    vaultAddress: "http://vault.default:8200"
    roleName: "database"
    objects: |
      - objectName: "db-password"
        secretPath: "secret/data/db-pass"
        secretKey: "password"

Step 2: Deploy Application

In this step, we will configure and deploy a test pod to the cluster. We will use a K8s YAML manifest which will reference the service account, SecretProviderClass and Volume Mount path.

Create and Publish Workload

Below is an example of a sample application. Note the following:

kind: Pod
apiVersion: v1
metadata:
  name: webapp
spec:
  serviceAccountName: webapp-sa
  containers:
  - image: jweissig/app:0.0.1
    name: webapp
    volumeMounts:
    - name: secrets-store-inline
      mountPath: "/mnt/secrets-store"
      readOnly: true
  volumes:
    - name: secrets-store-inline
      csi:
        driver: secrets-store.csi.k8s.io
        readOnly: true
        volumeAttributes:
          secretProviderClass: "vault-database"

Step 3: Access the secrets

# cat /mnt/secrets-store/db-password

You can see that the value displayed matches the password value for the secret secret/db-pass.


Congratulations! You can now pull and inject secrets from Vault into your applications.

More information about Secret Store CSI driver and examples can be found here.