S
S
serg8012021-01-23 21:50:24
linux
serg801, 2021-01-23 21:50:24

How to mount persistence volume to multiple pods in Kubernetes?

There is an example from the article.

pvc hangs in Pending status:

ks get pvc
NAME      STATUS    VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
nfs-pvc   Pending                                      standard       1m17s


pod hangs in Pending status:
ks get po
NAME            READY   STATUS    RESTARTS   AGE
nginx-nfs-pod   0/1     Pending   0          1m58s


What's wrong? Or how else can you mount one partition to multiple pods?

apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs-pv
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  nfs:
    path: /opt/nfs
    server: nfs.f22
    readOnly: false
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nfs-pvc
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Gi
---
apiVersion: v1
kind: Pod
metadata:
  name: nginx-nfs-pod
  labels:
    name: nginx-nfs-pod
spec:
  containers:
    - name: nginx-nfs-pod
      image: fedora/nginx
      ports:
        - name: web
          containerPort: 80
      volumeMounts:
        - name: nfsvol
          mountPath: /usr/share/nginx/html
  securityContext:
    supplementalGroups: [100003]
  volumes:
    - name: nfsvol
      persistentVolumeClaim:
        claimName: nfs-pvc

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question