I am trying to create a Kubernetes pod and mounting a volume from local hostpath. I am using Azure Kubernetes cluster. Following is my yaml for creating pod
apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
volumeMounts:
- mountPath: /opt/myfolder
name: test-volume
volumes:
- name: test-volume
hostPath:
# directory location on host
path: /Users/kkadam/minikube/myfolder
# this field is optional
I have few files under myfolder
which I want to use inside container. Files are present in local volume but not inside container.
What could be an issue?
aks-agentpool-29453832-vmss000000
and copy your data to that hostPath on aks node .. in short host path on your local laptop will not be mounted on AKS .. also note every time your pod is rebuild it can choose a different node and hostPath is node specific .. so if you are looking for persistent data across restarts of container you need to use nfs kind of solution .. – DT.