I am trying to create a single Persistent Volume (PV) and Persistent Volume Claim (PVC) that can be accessed by all the pods running in the same namespace on Google Kubernetes Engine (GKE). I attempted to use an NFS server, but when I deployed a StatefulSet, my pods did not run. Here is the configuration I used:
yaml
Copy code
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-pv
spec:
capacity:
storage: 10Gi
accessModes:
– ReadWriteMany
nfs:
path: /path/to/nfs
server: nfs-server.example.com
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nfs-pvc
spec:
accessModes:
– ReadWriteMany
resources:
requests:
storage: 10Gi
volumeName: nfs-pv
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: example-statefulset
spec:
selector:
matchLabels:
app: example
serviceName: “example-service”
replicas: 3
template:
metadata:
labels:
app: example
spec:
containers:
– name: example
image: example/image
volumeMounts:
– mountPath: “/mnt/nfs”
name: nfs-storage
volumeClaimTemplates:
- metadata:
name: nfs-storage
spec:
accessModes: [ “ReadWriteMany” ]
storageClassName: “”
resources:
requests:
storage: 10Gi
However, my pods are not starting. What am I doing wrong? How can I correctly set up a PV and PVC that can be accessed by all pods in the same namespace?
Any help would be appreciated. Thank you!
Avni Chauhan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.