Eldad Assis
Eldad Assis

Reputation: 11055

Kubernetes helm - Running helm install in a running pod

I want to spin up a single installer pod with helm install that once running, will apply some logic and install other applications into my cluster using helm install.

I'm aware of the helm dependencies, but I want to run some business logic with the installations and I'd rather do it in the installer pod and on the host triggering the whole installation process.

I found suggestions on using the Kubernetes REST API when inside a pod, but helm requires kubectl installed and configured.

Any ideas?

Upvotes: 4

Views: 6955

Answers (3)

Noksa
Noksa

Reputation: 11

Not sure if it is still actual but I've written a helm plugin which does exactly what is described in the question: https://github.com/noksa/helm-in-pod/

The plugin runs any command in a pod (helm install/kubectl get/etc)

Upvotes: 1

Eldad Assis
Eldad Assis

Reputation: 11055

It seems this was a lot easier than I thought...

On a simple pod running Debian, I just installed kubectl, and with the default service account's secret that's already mounted, the kubectl was already configured to the cluster's API.

Note that the configured default namespace is the one that my installer pod is deployed to.

Verified with

$ kubectl cluster-info
$ kubectl get ns

I then installed helm, which was already using the kubectl to access the cluster for installing tiller.

Verified with

$ helm version
$ helm init

I installed a test chart

$ helm install --name my-release stable/wordpress

It works!!

I hope this helps

Upvotes: 8

jayme
jayme

Reputation: 1316

You could add kubectl to your installer pod.

"In cluster" credentials could be provided via service account in "default-token" secret: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/

Upvotes: 2

Related Questions