Skip to content

Commit 93ac593

Browse files
committed
Add doc for sync and secretProviderClass
1 parent 8f09965 commit 93ac593

File tree

4 files changed

+109
-7
lines changed

4 files changed

+109
-7
lines changed

README.md

Lines changed: 89 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ The Secrets Store CSI driver `secrets-store.csi.k8s.io` allows Kubernetes to mou
1515
- Supports multiple secrets stores as providers. Multiple providers can run in the same cluster simultaneously.
1616
- Supports pod portability with the SecretProviderClass CRD
1717
- Supports windows containers (Kubernetes version v1.18+)
18+
- Supports sync with Kubernetes Secrets (Secrets Store CSI Driver v0.0.10+)
1819

1920
#### Table of Contents
2021

2122
- [How It Works](#how-it-works)
2223
- [Demo](#demo)
2324
- [Usage](#usage)
2425
- [Providers](#providers)
25-
- [Azure Key Vault Provider](https://github.com/Azure/secrets-store-csi-driver-provider-azure) - Supports linux and windows
26-
- [HashiCorp Vault Provider](https://github.com/hashicorp/secrets-store-csi-driver-provider-vault) - Supports linux
27-
- [Adding a New Provider via the Provider Interface](#adding-a-new-provider-via-the-provider-interface)
26+
- [Azure Key Vault Provider](https://github.com/Azure/secrets-store-csi-driver-provider-azure) - Supports Linux and Windows
27+
- [HashiCorp Vault Provider](https://github.com/hashicorp/secrets-store-csi-driver-provider-vault) - Supports Linux
28+
- [Adding a New Provider via the Provider Interface](#criteria-for-supported-providers)
2829
- [Testing](#testing)
2930
- [Unit Tests](#unit-tests)
3031
- [End-to-end Tests](#end-to-end-tests)
@@ -121,6 +122,91 @@ Select a provider from the following list, then follow the installation steps fo
121122
- [Azure Provider](https://github.com/Azure/secrets-store-csi-driver-provider-azure#usage)
122123
- [Vault Provider](https://github.com/hashicorp/secrets-store-csi-driver-provider-vault)
123124

125+
### Create your own SecretProviderClass Object
126+
127+
To use the Secrets Store CSI driver, create a `SecretProviderClass` custom resource to provide driver configurations and provider-specific parameters to the CSI driver.
128+
129+
A `SecretProviderClass` custom resource should have the following components:
130+
```yaml
131+
apiVersion: secrets-store.csi.x-k8s.io/v1alpha1
132+
kind: SecretProviderClass
133+
metadata:
134+
name: my-provider
135+
spec:
136+
provider: vault # accepted provider options: azure or vault
137+
parameters: # provider-specific parameters
138+
```
139+
140+
Here is a sample [`SecretProviderClass` custom resource](https://github.com/kubernetes-sigs/secrets-store-csi-driver/blob/master/test/bats/tests/vault_v1alpha1_secretproviderclass.yaml)
141+
142+
### Update your Deployment Yaml
143+
144+
To ensure your application is using the Secrets Store CSI driver, update your deployment yaml to use the `secrets-store.csi.k8s.io` driver and reference the `SecretProviderClass` resource created in the previous step.
145+
146+
```yaml
147+
volumes:
148+
- name: secrets-store-inline
149+
csi:
150+
driver: secrets-store.csi.k8s.io
151+
readOnly: true
152+
volumeAttributes:
153+
secretProviderClass: "my-provider"
154+
```
155+
156+
Here is a sample [deployment yaml](https://github.com/kubernetes-sigs/secrets-store-csi-driver/blob/master/test/bats/tests/nginx-pod-vault-inline-volume-secretproviderclass.yaml) using the Secrets Store CSI driver.
157+
158+
### Secret Content is Mounted on Pod Start
159+
On pod start and restart, the driver will call the provider binary to retrieve the secret content from the external Secrets Store you have specified in the `SecretProviderClass` custom resource. Then the content will be mounted to the container's file system.
160+
161+
To validate, once the pod is started, you should see the new mounted content at the volume path specified in your deployment yaml.
162+
163+
```bash
164+
kubectl exec -it nginx-secrets-store-inline ls /mnt/secrets-store/
165+
foo
166+
```
167+
168+
### [OPTIONAL] Sync with Kubernetes Secrets
169+
170+
In some cases, you may want to create a Kubernetes Secret to mirror the mounted content. Use the optional `secretObjects` field to define the desired state of the synced Kubernetes secret objects.
171+
172+
A `SecretProviderClass` custom resource should have the following components:
173+
```yaml
174+
apiVersion: secrets-store.csi.x-k8s.io/v1alpha1
175+
kind: SecretProviderClass
176+
metadata:
177+
name: my-provider
178+
spec:
179+
provider: vault # accepted provider options: azure or vault
180+
parameters: # provider-specific parameters
181+
secretObjects: # [OPTIONAL] SecretObject defines the desired state of synced K8s secret objects
182+
- data:
183+
- key: username # data field to populate
184+
objectName: foo1 # name of the object to sync
185+
secretName: foosecret # name of the Kubernetes Secret object
186+
type: Opaque # type of the Kubernetes Secret object e.g. Opaque, kubernetes.io/tls
187+
```
188+
> NOTE: Here is the list of [supported Kubernetes Secret types](https://github.com/kubernetes-sigs/secrets-store-csi-driver/blob/master/pkg/secrets-store/utils.go#L660-L675).
189+
190+
Here is a sample [`SecretProviderClass` custom resource](https://github.com/kubernetes-sigs/secrets-store-csi-driver/blob/master/test/bats/tests/vault_synck8s_v1alpha1_secretproviderclass.yaml) that syncs Kubernetes secrets.
191+
192+
### [OPTIONAL] Set ENV VAR
193+
194+
Once the secret is created, you may wish to set an ENV VAR in your deployment to reference the new Kubernetes secret.
195+
196+
```yaml
197+
spec:
198+
containers:
199+
- image: nginx
200+
name: nginx
201+
env:
202+
- name: SECRET_USERNAME
203+
valueFrom:
204+
secretKeyRef:
205+
name: foosecret
206+
key: username
207+
```
208+
Here is a sample [deployment yaml](https://github.com/kubernetes-sigs/secrets-store-csi-driver/blob/master/test/bats/tests/nginx-deployment-synck8s.yaml) that creates an ENV VAR from the synced Kubernetes secret.
209+
124210

125211
## Providers
126212

charts/index.yaml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ entries:
33
secrets-store-csi-driver:
44
- apiVersion: v1
55
appVersion: 0.0.10
6-
created: "2020-04-28T22:05:38.049737+01:00"
6+
created: "2020-05-04T13:43:34.653627-07:00"
77
description: A Helm chart to install the SecretsStore CSI Driver inside a Kubernetes
88
cluster.
9-
digest: 0f74454ca36c979a352d8a7b6d847521897ebf78195527ed8946201a841887a7
9+
digest: 9fae95e4611c9c120ed12505e735680b70ed133ea987fd32db05046cb45eda9e
1010
icon: https://github.com/kubernetes/kubernetes/blob/master/logo/logo.png
1111
kubeVersion: '>=1.15.0-0'
1212
maintainers:
@@ -18,4 +18,21 @@ entries:
1818
urls:
1919
- https://raw.githubusercontent.com/kubernetes-sigs/secrets-store-csi-driver/master/charts/secrets-store-csi-driver-0.0.10.tgz
2020
version: 0.0.10
21-
generated: "2020-04-28T22:05:38.04544+01:00"
21+
- apiVersion: v1
22+
appVersion: 0.0.9
23+
created: "2020-04-28T22:05:38.049737+01:00"
24+
description: A Helm chart to install the SecretsStore CSI Driver inside a Kubernetes
25+
cluster.
26+
digest: 0f74454ca36c979a352d8a7b6d847521897ebf78195527ed8946201a841887a7
27+
icon: https://github.com/kubernetes/kubernetes/blob/master/logo/logo.png
28+
kubeVersion: '>=1.15.0-0'
29+
maintainers:
30+
- email: ritazh@microsoft.com
31+
name: Rita Zhang
32+
name: secrets-store-csi-driver
33+
sources:
34+
- https://github.com/kubernetes-sigs/secrets-store-csi-driver
35+
urls:
36+
- https://raw.githubusercontent.com/kubernetes-sigs/secrets-store-csi-driver/master/charts/secrets-store-csi-driver-0.0.9.tgz
37+
version: 0.0.9
38+
generated: "2020-05-04T13:43:34.652813-07:00"
4.51 KB
Binary file not shown.

secretProviderClass/config/crd/bases/secrets-store.csi.x-k8s.io_secretproviderclasses.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
---
32
apiVersion: apiextensions.k8s.io/v1beta1
43
kind: CustomResourceDefinition

0 commit comments

Comments
 (0)