I'm new to kubernetes and I'm trying to add a PVC in my statefulset
.
PV and PVC are shown here:
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
neo4j-backups 5Gi RWO Retain Bound default/backups-claim manual 1h
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
backups-claim Bound neo4j-backups 5Gi RWO manual 51m
Basically I want all pods of the statefulset to see the contents of that volume as backup files are stored there.
Statefulset used can be found here
Minikube version:
minikube version: v0.25.2
Kubernetes version: GitVersion:"v1.9.4"
If you use
volumeClaimTemplates
inStatefulSet
k8s will do dynamic provisioning & create one PVC and corresponding PV for each pod, so each one of them gets their own storage.What you want is to create one PV & one PVC and use it in all replicas of Statefulset.
Below is example on Kubernetes 1.10 how you can do it, where
/var/www/html
will be shared by all three Pods, just change/directory/on/host
to some local directory on your machine. Also I ran this example on minikube v0.26.0Ofcourse below is just an example to illustrate the idea, but in a real example processes in Pod should be aware of syncronizing access to shared storage.