apiVersion: 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-pvc
Using kubectl apply to create PVC and Pod.
After the creation, you should be able to see that pod is running, PVC is bound.
root@420f435c39833406727a02f08bc4a7b6 [ ~/daniel-tests ]# kubectl-gc get pvc daniel-pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
daniel-pvc Bound pvc-bee5e54e-62ef-4abf-a40f-b6d3aa461d2f 1Gi RWO gcstorage 10m
root@420f435c39833406727a02f08bc4a7b6 [ ~/daniel-tests ]# kubectl-gc get pod daniel-pod
NAME READY STATUS RESTARTS AGE
daniel-pod 1/1 Running 0 10m
Modify the access mode under PVC
Modify the access mode under PVC to ReadOnlyMany
The PersistentVolumeClaim "daniel-pvc" is invalid: spec: Forbidden: is immutable after creation except resources.requests for bound claims
Modify the access mode under PV(which is dynamically created)
apiVersion: 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 && while true ; do sleep 2 ; done"]
volumeMounts:
- name: gc-persistent-storage
mountPath: /data/persistent
volumes:
- name: gc-persistent-storage
persistentVolumeClaim:
claimName: daniel-pvc
Modify the access mode under PVC
root@420f435c39833406727a02f08bc4a7b6 [ ~/daniel-tests ]# kubectl-gc apply -f static-provision-pvc.yaml
The PersistentVolumeClaim "daniel-pvc" is invalid: spec: Forbidden: is immutable after creation except resources.requests for bound claims
Modify the access mode under PV (Statically created)