Is it possibile to mount home directory (~) in a Kubernetes Pod?

6/7/2019

I'm trying to run a simple Kubernetes Pod, and I want to mount the home of the host where the pod is scheduled into the /hosthome directory.

I'm using Kubernetes Python API to deploy those pods on a remote cluster (so I can't use something like os.path.expanduser('~') because it'll parse the "client" host home, not the remote one).

When I try to deploy the pod with this volume definition:

...
volumes:
  - name: hosthome
    hostPath:
      path: ~
...

The pod creation fails with this error: create ~: volume name is too short, names should be at least two alphanumeric characters. So I can't use the ~ shortcut to mount it.

So, my question is: is there any way to mount the home directory of the host where the pod is scheduled using only the YAML definition (without replaces or Python functions)?

Thanks.

-- Skazza
docker
kubernetes
linux

1 Answer

6/7/2019

No, I think this is not possible. Only absolute paths are allowed for a host volumne mount.

-- Gabe
Source: StackOverflow