I tried to define a PVC:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: master-pvc
spec:
accessModes:
- ReadWriteOnce
- ReadOnlyMany
resources:
requests:
storage: 1Gi
The nodes that need readonly access should define:
volumeMounts:
- name: mastervol
mountPath: /data/master/
readOnly: true
The master that needs to read and write, should define:
volumeMounts:
- name: mastervol
mountPath: /data/master/
Is this a valid way to achieve what i want?
CodePudding user response:
It is not a node that requests a volumeMount
, but a container inside a Pod (many Pods may run in same node).
A PVC is 1-1 bound to a PV using a single access mode (even it supports many) at a time (see also access modes). So, you cannot have a PVC operating at the same time as ReadWriteOnce
(for some Pods) and ReadOnlyMany
(for some other Pods).
If you want to support 1 writer and many readers, one solution is to let them use a ReadWriteOnce
volume and ensure that all Pods run on the same node the volume is mounted (e.g by using node affinity constraints).