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.
'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.
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.
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.
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:
'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
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With