Post Image

Kubernetes NFS PVC

 

 

Create Persistent volume

apiVersion: v1
kind: PersistentVolume
metadata:
  name: nginx
  labels:
    pv: nginxpv
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  nfs:
    path: /var/nfs/
    server: 10.204.255.47
    readOnly: false

 

Create Persistent Volume Claim for the pod to use

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nginxpvc
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 3Gi
  selector:
    matchLabels:
      pv: nginxpv

 

 

Create Volume in your pod deployment

This will be added in your deployments spec.template.spec 

volumes:
- name: data-dir
   persistentVolumeClaim:
     claimName: nginxpvc

 

Create mount point for volume in container

This will be added in your deployments spec.templates.spec.containers 

volumeMounts:
- name: data-dir
  mountPath: "/data"
  subPath: "general"

 

 

 



Comments (0)
Leave a Comment