Skip to content

Commit 45f3664

Browse files
authored
Merge pull request #27884 from jingxu97/nodename
Update note for waitForFirstConsumer binding mode with example
2 parents 36f5cd1 + e7d3e27 commit 45f3664

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

content/en/docs/concepts/storage/storage-classes.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ the class or PV. If a mount option is invalid, the PV mount fails.
154154
### Volume Binding Mode
155155

156156
The `volumeBindingMode` field controls when [volume binding and dynamic
157-
provisioning](/docs/concepts/storage/persistent-volumes/#provisioning) should occur.
157+
provisioning](/docs/concepts/storage/persistent-volumes/#provisioning) should occur. When unset, "Immediate" mode is used by default.
158158

159-
By default, the `Immediate` mode indicates that volume binding and dynamic
159+
The `Immediate` mode indicates that volume binding and dynamic
160160
provisioning occurs once the PersistentVolumeClaim is created. For storage
161161
backends that are topology-constrained and not globally accessible from all Nodes
162162
in the cluster, PersistentVolumes will be bound or provisioned without knowledge of the Pod's scheduling
@@ -188,6 +188,36 @@ The following plugins support `WaitForFirstConsumer` with pre-created Persistent
188188
and pre-created PVs, but you'll need to look at the documentation for a specific CSI driver
189189
to see its supported topology keys and examples.
190190

191+
{{< note >}}
192+
If you choose to use `waitForFirstConsumer`, do not use `nodeName` in the Pod spec
193+
to specify node affinity. If `nodeName` is used in this case, the scheduler will be bypassed and PVC will remain in `pending` state.
194+
195+
Instead, you can use node selector for hostname in this case as shown below.
196+
{{< /note >}}
197+
198+
```yaml
199+
apiVersion: v1
200+
kind: Pod
201+
metadata:
202+
name: task-pv-pod
203+
spec:
204+
nodeSelector:
205+
kubernetes.io/hostname: kube-01
206+
volumes:
207+
- name: task-pv-storage
208+
persistentVolumeClaim:
209+
claimName: task-pv-claim
210+
containers:
211+
- name: task-pv-container
212+
image: nginx
213+
ports:
214+
- containerPort: 80
215+
name: "http-server"
216+
volumeMounts:
217+
- mountPath: "/usr/share/nginx/html"
218+
name: task-pv-storage
219+
```
220+
191221
### Allowed Topologies
192222

193223
When a cluster operator specifies the `WaitForFirstConsumer` volume binding mode, it is no longer necessary

0 commit comments

Comments
 (0)