Pip installing a package inside of a Kubernetes cluster

8/1/2018

I have installed Apache Superset from its Helm Chart in a Google Cloud Kubernetes cluster. I need to pip install a package that is not installed when installing the Helm Chart. If I connect to the Kubernetes bash shell like this:

kubectl exec -it superset-4934njn23-nsnjd /bin/bash

Inside there's no python available, no pip and apt-get doesn't find most of the packages.

I understand that during the container installation process the packages are listed in the Dockerfile, I suppose that I need to fork the docker container, modify the Dockerfile, register the container to a container registry and make a new Helm Chart that will run this container.

But all this seems too complicated for a simple pip install, is there a simpler way to do this?

Links:

Docker- https://hub.docker.com/r/amancevice/superset/

Helm Chart - https://github.com/helm/charts/tree/master/stable/superset

-- Ben Gosub
google-cloud-platform
kubernetes
kubernetes-helm

3 Answers

8/1/2018

Docker file seems to be installing python3 package. Try 'python3' or "pip3" instead of 'python'/'pip'

-- Murli
Source: StackOverflow

8/1/2018

As @Murli mentioned, you should use pip3. However, one thing you should remember is, helm is for managing k8s, i.e. what goes into the cluster should be traceable. So I recommend you the following:

$ helm get stable/superset

modify the values.yaml. In my case, I added jenkins-job-builder to pip3:

initFile: |-
  pip3 install jenkins-job-builder
  /usr/local/bin/superset-init --username admin --firstname admin --lastname user --email admin@fab.org --password admin
  superset runserver

and just pass the values.yaml to helm install.

$ helm install --values=values.yaml stable/superset

Thats it.

 $ kubectl exec -it doltish-gopher-superset-696448b777-8b9c6 which jenkins-jobs
 /usr/local/bin/jenkins-jobs
 $
-- Maniankara
Source: StackOverflow

8/1/2018

Make the container, a little more dev work and many fewer alerts from pager duty

-- ms4720
Source: StackOverflow