Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Helm command with kubeconfig inline

I am trying to execute helm commands on VSTS release definition using Run command VSTS extension but the problem is it is not able to find the kubeconfig file on the custom build agent i have configured. I think this is coz the build steps defined run in a separate process. When i run

kubectl config view

It gives me an empty config file. Just wanted to know if i can provide the kubeconfig file inline when m executing helm commands something like

helm init --kubeconfig=kubeconfigpath

Or is there any way i can set the kubeconfig file before running the helm commands in vsts release process?

Appreciate any help. Thanks.

like image 413
narcs Avatar asked Mar 17 '17 04:03

narcs


People also ask

How to find Kubernetes cluster's configuration using helm?

'helm init' command discovers your Kubernetes cluster's configuration by reading $KUBECONFIG variable (default '~/.kube/config') and using the default Kubernetes context. If you are using a different config file then you have to change $KUBECONFIG value so that helm gets info about your cluster from the correct config file.

How do I use kubeconfig?

Use kubeconfig files to organize information about clusters, users, namespaces, and authentication mechanisms. The kubectl command-line tool uses kubeconfig files to find the information it needs to choose a cluster and communicate with the API server of a cluster.

Where does kubectl look for Kube config files?

By default, kubectl looks for a file named config in the $HOME/.kube directory. You can specify other kubeconfig files by setting the KUBECONFIG environment variable or by setting the --kubeconfig flag.

Why is kubectl using the kubeconfig environment variable?

If the KUBECONFIG environment variable does exist, kubectl uses an effective configuration that is the result of merging the files listed in the KUBECONFIG environment variable. To see your configuration, enter this command:


2 Answers

'helm init' command discovers your Kubernetes cluster's configuration by reading $KUBECONFIG variable(default '~/.kube/config') and using the default Kubernetes context. If you are using a different config file then you have to change $KUBECONFIG value so that helm gets info about your cluster from the correct config file.

Change the $KUBECONFIG value

export KUBECONFIG=/path_to_your_kubeconfig_file

To be on safe side use the --kube-contex flag to specify the current context

helm init --kube-context CONTEXT_NAME --upgrade

Check helm client and tiller version using

helm version

like image 72
zaman sakib Avatar answered Nov 11 '22 14:11

zaman sakib


Try to specify kubeconfig file through kubectl command.

kubectl config SUBCOMMAND

Options

-h, --help=false: help for config
      --kubeconfig="": use a particular kubeconfig file

On the other hand, you can try to change build agent account (e.g. your account) and check whether it can find the kubeconfig file (permission issue)

like image 26
starian chen-MSFT Avatar answered Nov 11 '22 15:11

starian chen-MSFT