How does Helm keep track of which Kubernetes cluster it installs to?

5/8/2020

If I am using kubectx and switch kube config contexts into another cluster e.g. "Production" and run a helm uninstall, how does Helm know which cluster I am referring to?

If I run the helm list command is it only referring to what's installed on my local machine and not per Kubernetes cluster?

-- Wunderbread
kubernetes
kubernetes-helm

1 Answer

5/8/2020

Helm will default to using whatever your current Kubernetes context is, as specified in the $HOME/.kube/config file.

There is standard support in the Kubernetes API libraries to read data out of this file (or an alternative specified by a $KUBECONFIG environment variable). If you're writing Go, see the documentation for the k8s.io/client-go/tools/clientcmd package. While kubectx does a bunch of things, its core uses that API to do essentially the same thing as running kubectl config use-context ....

If you want Helm to use a non-default context, there is a global option to specify it:

kubectx production
helm list

kubectx development
helm --kube-context production list
-- David Maze
Source: StackOverflow