0

I have a NFS server, It can access nfs server with kubernetes Storageclass. I want to write and read File from my Spring Boot project to nfs server. how can I do that?

pv.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: fileserver-nfs-pv
spec:
  capacity:
    storage: 2Gi
  accessModes:
    - ReadWriteMany
  claimRef:
    apiVersion: v1
    kind: PersistentVolumeClaim
    name: fileserver-nfs-pvc
  nfs:
    server: 10.0.75.1
    path: /export/k8s-data/fileserver

pvc.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: fileserver-nfs-pvc
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 2Gi

My spring boot project deployment yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: authentication
  name: authentication
  namespace: auth
spec:
  selector:
    matchLabels:
      app: authentication
  strategy:
    rollingUpdate:
      maxSurge: 15%
      maxUnavailable: 0
    type: RollingUpdate
  replicas: 1
  template:
    metadata:
      labels:
        app: authentication
    spec:
      containers:
        - name: authentication
          image: ip:8080/authentication:0.0.0
          imagePullPolicy: Always
          ports:
            - containerPort: 8080
          resources:
            limits:
              cpu: "0.9"
              memory: 1Gi
            requests:
              cpu: "0.6"
              memory: 512Mi
   

My spring boot project is kubernetese deploy. I want to read and write to nfs server using java.nio package. How should I define my deployment.yaml file?

zoroglur
  • 395
  • 2
  • 18
  • 1
    volume mount is missing in deployment , see following answer https://stackoverflow.com/questions/60533371/how-to-mount-a-persistent-volume-on-a-deployment-pod-using-persistentvolumeclaim – Shakeel Hussain Aug 21 '23 at 17:51

0 Answers0