Creating Kubernetes Endpoint in VSTS generates err

2019-04-09 20:32发布

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?

3条回答
Juvenile、少年°
2楼-- · 2019-04-09 20:50

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
查看更多
唯我独甜
3楼-- · 2019-04-09 21:01

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 download task/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 variables KUBECONFIG 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 and az 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)

查看更多
可以哭但决不认输i
4楼-- · 2019-04-09 21:05

I had the same problem on VSTS.

Here is my workaround to get a Service Connection working (in my case to GCloud):

  1. Switched Authentication to "Service Account"

    1. 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

    2. Search inside the the file kubectl-secret.yaml the values ca.crt and token

    3. Enter the values inside VSTS to the required fields

查看更多
登录 后发表回答