How to use kubernetes helm from a CI/CD pipeline hosted outside the k8s cluster

4/23/2017

I am using kubernetes helm to deploy apps to my cluster. Everything works fine from my laptop when helm uses the cluster's kube-config file to deploy to the cluster.

I want to use helm from my CI/CD server (which is separate from my cluster) to automatically deploy apps to my cluster. I have created a k8s service account for my CI/CD server to use. But how do I create a kube-config file for the service account so that helm can use it to connect to my cluster from my CI/CD server??

Or is this not the right way to use Helm from a CI/CD server?

-- Nithin
continuous-deployment
continuous-integration
kubectl
kubernetes
kubernetes-helm

4 Answers

5/1/2017

In this case you will want to install kubectl on whichever slave or agent you have identified for use by your CI/CD server, OR install kubectl on-the-fly in your automation, AND then make sure you have OR are able to generate a kubeconfig to use.

To answer the question:

But how do I create a kube-config file for the service account ...

You can set new clusters, credentials, and contexts for use with kubectl in a default or custom kubeconfig file using kubectl config set-cluster, kubectl config set-credentials, and kubectl config set-context. If you have KUBECONFIG env variable set and pointing to a kubeconfig file, that works or when setting new entries simply pass -kubeconfig to point to a custom file.

Here's the relevant API documentation for v1.6.

-- Murad Korejo
Source: StackOverflow

3/7/2018

We created helmsman which provides you with declarative syntax to manage helm charts in your cluster. It configures kubectl (and therefore helm) for you wherever you run it. It can also be used from a docker container.

-- Sami
Source: StackOverflow

4/26/2017

Helm works by using the installed kubectl to talk to your cluster. That means that if you can access your cluster via kubectl, you can use helm with that cluster.

Don't forget to make sure you're using to proper context in case you have more than one cluster in you kubcfg file. You can check that by running kubectl config current-context and comparing that to the cluster details in the kubecfg.

You can find more details in Helm's docs, check the quick start guide for more information.

-- Merlin
Source: StackOverflow

5/22/2018

why not just run your CI server inside your kubernetes cluster then you don't have to manage secrets for accessing the cluster? We do that on Jenkins X and it works great - we can run kubectl or helm inside pipelines just fine.

-- James Strachan
Source: StackOverflow