How to build a sidecar container for passing files from a machine outside of the Kubernetes cluster?

11/12/2015

I have a noob question. If I'm using a docker image that uses a folder located in the host to do something, Where should be located the folder in the kubernetes cluster? I'm ok doing this with docker since I know where is my host filesystem but I get lost when I'm on a kubernetes cluster.

Actually, I don't know if this is the best approach. But what I'm trying to do is build a development environment for a php backbend. Since what I want is that every person can run a container environment with their own files (which are on their computers), I'm trying to build a sidecar container so when launching the container I can pass the files to the php container.

The problem is that I'm running kubernetes to build development environment for my company using a vagrant (coreos + kubernetes) solution since we don't have a cloud service right now so I can't use a persiten disk. I try NFS but it seems be too much for what I want (just pass some information to the pod regardless of the PC where I am). Also I try to use hostPAth in Kubernetes but the problem is that the machines where I want connect to the containers are located outside of the kubernetes cluster (Vagrant + CoreOS + Kubernetes so I-m trying to expose some container to public IPs but I can not figure out how to past the files (located in the machines outside of the cluster) to the containers.

Thanks for your help, I appreciate your comments.

-- Luis Yonaldo Nuñez Gomez
backend
coreos
docker
kubernetes
php

1 Answer

11/17/2015

Not so hard, actually. Check my gists may give you some tips:

https://gist.github.com/resouer/378bcdaef1d9601ed6aa

See, do not try to consume files from outside, just package them in a docker image, and consume them by sidecar mode.

-- harryz
Source: StackOverflow