I wonder how to mount all pod to only pvc with statefulset below picture: Picture
CodePudding user response:
It is not supported. each pod can have separate PVC which binds specific persistent volume.
CodePudding user response:
While you can achieve this, remember in this case the scheduler will bound all your StatefulSet pods to the same node where the volume is attached. Any reason that the pod cannot be deployed on the same node will put your pod into pending state. There's nothing special about the spec to use a single PVC/PV:
apiVersion: apps/v1
kind: StatefulSet
metadata:
...
spec:
serviceName: <name>
replicas: <count>
selector:
matchLabels:
...
template:
metadata:
labels:
...
spec:
volumes:
- name: <volume name>
persistentVolumeClaim:
claimName: <your pvc> # <-- all pods will use this pvc
containers:
- name: ...
...
volumeMounts:
- name: <volume name> # <-- mount the volume
mountPath: /path/in/container