What setting up a new Kubernetes endpoint and clicking "Verify Connection" the error message: "The Kubconfig does not contain user field. Please check the kubeconfig. " - is always displayed.
Have tried multiple ways of outputting the config file to no avail. I've also copy and pasted many sample config files from the web and all end up with the same issue. Anyone been successful in creating a new endpoint?
I had the same problem on VSTS.
Here is my workaround to get a Service Connection working (in my case to GCloud):
Switched Authentication to "Service Account"
Run the two commands told by the info icon next to the fields Token and Certificate: "Token to authenticate against Kubernetes. Use the ‘kubectl get serviceaccounts -o yaml’ and ‘kubectl get secret -o yaml’ commands to get the token."
kubectl get secret -o yaml > kubectl-secret.yaml
Search inside the the file kubectl-secret.yaml the values ca.crt and token
Enter the values inside VSTS to the required fields
The generated config I was using had a duplicate line, removing this corrected the issue for me.
users:
- name: cluster_stuff_here
- name: cluster_stuff_here
This is followed by TsuyoshiUshio/KubernetesTask issue 35
I try to reproduce, however, I can't do it.
I'm not sure, however, I can guess it might the mismatch of the version of the cluster/kubectl which you download by the downloadtask/kubeconfig
.
Workaround might be like this:
- kubectl version in your local machine and check the current server/client version
- specify the same version as the server on the download task. (by default it is 1.5.2)
- See the log of your release pipeline which is fail, you can see which
kubectl
command has been executed, do the same thing on your local machine with fitting your local pc's environment.The point is, before go to the VSTS, download the kubectl by yourself.
Then, put the kubeconfg on the default folder like~/.kube/config
or set environment variablesKUBECONFIG
to the binary.
Then execute kubectl get nodes and make sure if it works.My kubeconfig is different format with yours. If you use AKS,
az aks install-cli
command andaz aks get-credentials
command.
Please refer https://docs.microsoft.com/en-us/azure/aks/kubernetes-walkthrough .If it works locally, the config file must work on the VSTS task environment. (or this task or VSTS has a bug)