So I have a ROX PVC and PV that I am mounting on a pod.
While mounting on a pod, I am setting readOnly to false:
Volumes:
test-volume:
Type: PersistentVolumeClaim
ClaimName: pvc-1
ReadOnly: false
When I try to write to this pod by doing kubectl exec command
, it goes through while I expect it to fail as the PV is created with AccessMode ROX.
Can someone please explain how is this possible?
As per kubernetes official documentation:
In your case you might have not mentioned ReadOnlyMany in your accessModes of your PVC, or using some pre-existing volume as a result the restrictions are not applied to the volume and you were able to perform write operations.
As per this documentation on ROX volumes provided by Google:
Clone an existing volume which contains the data or create a new dynamic volume, populate the data and convert that volume into readOnly In your PV and PVC manifest files configure the accessModes as ReadOnlyMany
By following the above steps you will be able to achieve the desired ROX functionality. Refer to below example manifest taken from Google documentation: