Experiment on Persistent Volume Access Mode
If Dynamic provisioning
Create PVC and Pod
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: daniel-pvc
annotations:
volume.beta.kubernetes.io/storage-class: gcstorage
spec:
accessModes:
- ReadOnlyMany
resources:
requests:
storage: 1Gi
storageClassName: gcstorageapiVersion: v1
kind: Pod
metadata:
name: daniel-pod
spec:
restartPolicy: Never
containers:
- name: hello
image: "wcp-docker-ci.artifactory.eng.vmware.com/vmware/photon:1.0"
# The script continously writes some text into the mounted persistent volume. This will ensure the pod is running and the persistent volume is accessible.
command: ["/bin/sh", "-c", "echo 'hello' > /data/persistent/index.html && chmod o+rX /data /data/persistent/index.html && while true ; do sleep 2 ; done"]
volumeMounts:
- name: gc-persistent-storage
mountPath: /data/persistent
volumes:
- name: gc-persistent-storage
persistentVolumeClaim:
claimName: daniel-pvcModify the access mode under PVC
Modify the access mode under PV(which is dynamically created)
Strange thing happens under the PVC spec, that spec and status are inconsistent:
However, CLI get returns the correct value:
After changing the access mode to ReadOnlyMany:
Conclusion:
If static provisioning
Create PV, PVC and Pod
Modify the access mode under PVC
Modify the access mode under PV (Statically created)
Conclusion:
PreviousK8S storage e2e experiment under VMware vSphereNextDesign: Storage in Cluster-API architecture
Last updated