I am attempting to build a pod in kubernetes that has files mounted to the pod from my local system, in a similar way to mounting volumes in docker-compose files
I have tried the following, in an attempt to mount the local folder ./test and files to the pod under the /blah/ folder. However kubernetes is complaining that MountVolume.SetUp failed for volume "config-volume" : hostPath type check failed: ./test/ is not a directory
Here is my yaml file. Am I missing something?
kind: Service
metadata:
name: vol-test
labels:
app: vol-test
spec:
type: NodePort
ports:
- port: 8200
nodePort: 30008
selector:
app: vol-test
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: vol-test
spec:
replicas: 1
selector:
matchLabels:
app: vol-test
template:
metadata:
labels:
app: vol-test
spec:
containers:
- name: vol-test
image: nginx
imagePullPolicy: "IfNotPresent"
volumeMounts:
- name: config-volume
mountPath: /blah/
ports:
- containerPort: 8200
volumes:
- name: config-volume
hostPath:
path: ./test/
type: Directory