Skip to content

Commit c1606c6

Browse files
committed
Update secrets documentation with supported keys
- there was a typo for NodePublish and NodeStage docs - added a new example with secret provided for multiple operations. - updated the provisioner secrets based on recent changes allowing pvc.name and pvc.namespace.
1 parent 8b0b4cd commit c1606c6

File tree

1 file changed

+39
-6
lines changed

1 file changed

+39
-6
lines changed

book/src/secrets-and-credentials.md

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,20 @@ The value of both parameters may be a literal or a template containing the follo
4848

4949
* `${pv.name}`
5050
* Automatically replaced with the name of the `PersistentVolume` object being provisioned at provision.
51+
* `${pvc.namespace}`
52+
* Automatically replaced with the namespace of the `PersistentVolumeClaim` object being provisione
53+
54+
The value of `csi.storage.k8s.io/provisioner-secret-name` also supports the following template variables which are automatically replaced by the `external-provisioner` at provision time:
55+
56+
* `${pvc.name}`
57+
* Automatically replaced with the name of the `PersistentVolumeClaim` object being provisioned.
5158

5259
If specified, the CSI `external-provisioner` will attempt to fetch the secret before provisioning and deletion.
5360

54-
If no such secret exists in the Kubernetes API, or the provisioner is unable to fetch it, the provision or delete operation fails.
61+
If the entire namespace was deleted, including the secret needed for deletion, then no secret will be passed to the delete call.
62+
63+
If no such secret exists in the Kubernetes API, or the provisioner is unable to fetch it, the provision operation will fail. The delete operation will continue if the secret is not found. If this happens when the driver requires a secret for deletion, then the volume and PV may need to be
64+
manually cleaned up.
5565

5666
If the secret is retrieved successfully, the provisioner passes it to the CSI driver in the `CreateVolumeRequest.secrets` or `DeleteVolumeRequest.secrets` field.
5767

@@ -71,7 +81,7 @@ The value of both parameters may be a literal or a template containing the follo
7181
* `${pvc.namespace}`
7282
* Automatically replaced with the namespace of the `PersistentVolumeClaim` object being provisioned.
7383

74-
The value of `csi.storage.k8s.io/controller-publish-secret-namespace` also supports the following template variables which are automatically replaced by the `external-provisioner` at provision time:
84+
The value of `csi.storage.k8s.io/controller-publish-secret-name` also supports the following template variables which are automatically replaced by the `external-provisioner` at provision time:
7585

7686
* `${pvc.name}`
7787
* Automatically replaced with the name of the `PersistentVolumeClaim` object being provisioned.
@@ -133,7 +143,7 @@ The value of both parameters may be a literal or a template containing the follo
133143
* `${pvc.namespace}`
134144
* Automatically replaced with the namespace of the `PersistentVolumeClaim` object being provisioned.
135145

136-
The value of `csi.storage.k8s.io/node-publish-secret-namespace` also supports the following template variables which are automatically replaced by the `external-provisioner` at provision time:
146+
The value of `csi.storage.k8s.io/node-publish-secret-name` also supports the following template variables which are automatically replaced by the `external-provisioner` at provision time:
137147

138148
* `${pvc.name}`
139149
* Automatically replaced with the name of the `PersistentVolumeClaim` object being provisioned.
@@ -148,7 +158,30 @@ If no such secret exists in the Kubernetes API, or the kubelet is unable to fetc
148158

149159
If the secret is retrieved successfully, the kubelet passes it to the CSI driver in the `NodePublishVolumeRequest.secrets` field.
150160

151-
For example, consider this `StorageClass`:
161+
## Example Storage Classes
162+
163+
The following storage classes supply secrets to a sample CSI driver named `csi-driver.team.example.com`.
164+
165+
### Multiple operations support secret keys
166+
A drivers may support secret keys for multiple operations. In this case, you can provide secrets references for each operation:
167+
168+
```yaml
169+
kind: StorageClass
170+
apiVersion: storage.k8s.io/v1
171+
metadata:
172+
name: fast-storage-all
173+
provisioner: csi-driver.team.example.com
174+
parameters:
175+
type: pd-ssd
176+
csi.storage.k8s.io/provisioner-secret-name: ${pvc.name}
177+
csi.storage.k8s.io/provisioner-secret-namespace: ${pvc.namespace}-fast-storage
178+
csi.storage.k8s.io/node-publish-secret-name: ${pvc.name}-${pvc.annotations['team.example.com/key']}
179+
csi.storage.k8s.io/node-publish-secret-namespace: ${pvc.namespace}-fast-storage
180+
181+
```
182+
183+
### Only NodePublish supports secret keys
184+
Some drivers may only support secret keys for a certain operation:
152185

153186
```yaml
154187
kind: StorageClass
@@ -158,8 +191,8 @@ metadata:
158191
provisioner: csi-driver.team.example.com
159192
parameters:
160193
type: pd-ssd
161-
csiNodePublishSecretName: ${pvc.annotations['team.example.com/key']}
162-
csiNodePublishSecretNamespace: ${pvc.namespace}
194+
csi.storage.k8s.io/node-publish-secret-name: ${pvc.annotations['team.example.com/key']}
195+
csi.storage.k8s.io/node-publish-secret-namespace: ${pvc.namespace}
163196
```
164197

165198
This StorageClass instructs the CSI provisioner to do the following:

0 commit comments

Comments
 (0)