Kubernetes Init Containers pip install

8/21/2018

I am not sure I am understanding Kubernetes Init containers properly. What i want to do is run an initialization on the pod so that it pip installs some additional libraries that are not in my app container image. Specifically I am wanting to install the Azure storage queue such that i can use it with the standard TensorFlow image.

I set up my init container with the command "pip install azure-storage-queue" and that ran fine however my app container tells me "No module named azure"

Is this not how an init container can be used?

NOTE: I realize i could create a new image with all my prerequisites installed however this is just for development purposes

-- user1371314
docker
kubernetes

1 Answer

8/21/2018

That's not really how init containers work... Init containers are meant to initialize the pod and the image isn't really shared with other containers that will later run on that pod.

The best solution is to create a new container image including the Python modules you need.

An alternative is to use a command to run in your container that first installs the modules using pip and later runs the script that needs them, that way you can avoid creating a new container image.

-- filbranden
Source: StackOverflow