I've successfully managed to create an NFS Persistent Volume and a Persistent Volume claim which when I run my deployment does what it's supposed to and mounts my apps data folder on the NFS volume. All good.
In docker there is the ability to run
-v <host dir>:<container dir>
How do I tell Kubernetes in my deployment not to use /kubernetes but to use /kubernetes/ for example?
The current working code is: nfs-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-pv
spec:
capacity:
storage: 10Gi
volumeMode: Filesystem
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Recycle
storageClassName: nfs
mountOptions:
- hard
nfs:
path: /Dev1Partition1/kubernetes
server: 192.168.40.202
nfs-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nfs-pvc
spec:
storageClassName: nfs
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
The above works when I run the following deployment the data I expect appears in the Kubernetes folder I specified.
The Deployment looks like this deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: n8n-server
name: n8n-deployment
spec:
replicas: 1
selector:
matchLabels:
run: n8n-deployment
template:
metadata:
labels:
run: n8n-deployment
spec:
volumes:
- name: n8n-pv-storage
persistentVolumeClaim:
claimName: nfs-pvc
containers:
- image: 192.168.40.43:8081/dockercontainers/library/n8n:latest
name: n8n-server
volumeMounts:
- mountPath: "/root/.n8n"
name: n8n-pv-storage
imagePullSecrets:
- name: progercred
I tried adding under volumes:
hostPath: path: n8n (and /n8n)
type: Directory
This throws up
spec.template.spec.volumes[0].persistentVolumeClaim: Forbidden: may not specify more than 1 volume type
spec.template.spec.containers[0].volumeMounts[0].name: Not found: "n8n-pv-storage"
I'm guessing because hostPath is for emptyDir?
Help?
Am i thinking about this right?
type: Directory
? In the PersistentVolume definition? If I understand well, you created a PersistentVolume mapped to a directory. And in your Deployment you want tell your pod to use another folder than the one mapped by the PersistentVolume ? – Flo