...
The PVC will remain in the pending state until the folder is created within the <exported_path>, according to the pathPattern parameter. In our case, the folder name must be equal to <namespace>-<PVC_name>, that is nfs-test-test-claim. In read-write mode, the folder is created automatically.
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
$ k apply -f test-claim.yaml -n nfs-test # The PVC is in pending state $ k get pvc -n nfs-test NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE test-claim Pending nfs-sc 60s # Create the folder and a test file inside it $ mkdir <exported_path>/nfs-test-test-claim $ touch file_test.txt # PVC is in bound state now $ k get pvc -n nfs-test NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE persistentvolumeclaim/test-claim Bound pvc-10663683-eece-46ca-b83d-53f88a1cabc9 5Mi ROX nfs-sc 4m3s |
Use PVC in a trial application
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mystate
spec:
serviceName: mysvc
selector:
matchLabels:
app: myapp
replicas: 3
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: mycontainer
image: nginx
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 80
volumeMounts:
- name: mydata
mountPath: /usr/share/nginx/html
# Create another PVC to mount a different folder inside the Pod
# - name: mydata2
# mountPath: /data
volumes:
- name: mydata
persistentVolumeClaim:
claimName: test-claim
# - name: mydata2
# persistentVolumeClaim:
# claimName: test-claim2 |
Create the Pods and verify that the volume is properly mounted within them