Why the path does not get mount?

11/2/2019

I've created the manifest file, that looks as follows:

apiVersion: v1
kind: Pod
metadata:
  name: kuard
spec:
  volumes:
    - name: "kuard-data"
      hostPath:
        path: "/home/developer/kubernetes/exercises"
  containers:
    - image: gcr.io/kuar-demo/kuard-amd64:1
      name: kuard
      volumeMounts:
        - mountPath: "/data"
          name: "kuard-data"
      ports:
        - containerPort: 8080
          name: http
          protocol: TCP

As you can see, the hostpath is:

path: "/home/developer/kubernetes/exercises"

and the mountPath is:

mountPath: "/data"

I've created a hello.txt file in the folder /home/developer/kubernetes/exercises and when I enter into the pod via kubectl exec -it kuard ash I can not find the file hello.txt.

enter image description here

Where is the file?

-- zero_coding
kubernetes

1 Answer

11/2/2019

kind is using Docker containers to simulate Kubernetes nodes. So when you are creating files on your host (your ubuntu machine) the containers will not automatically have access to them. (This gets even more complicated when using macos or windows and docker is running in a separate virtual machine...)

I assume that there are some shared folders visible inside the kind-docker-nodes, but I could not find it documented.

You can verify the filesystem content of the docker node from inside the container using docker exec -it kind-control-plane /bin/sh and then work with the usual tools.

If you need to make content from your development machine available you might want to have a look at ksync: https://github.com/vapor-ware/ksync

-- Thomas
Source: StackOverflow