问题
I am trying to setup the kubectl tool in my machine to remotely manage Kubernetes cluster and also to use Helm. I am trying in Ubuntu 16.04 machine.
I am following the official Kubernetes documentation from the following link,
https://kubernetes.io/docs/tasks/tools/install-kubectl/
I ran the following commands,
sudo apt-get update && sudo apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl
And after when I am running the 'kubectl version' command to verify the installation , I am getting the following ,
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.1",
GitCommit:"b7394102d6ef778017f2ca4046abbaa23b88c290", GitTreeState:"clean",
BuildDate:"2019-04-08T17:11:31Z", GoVersion:"go1.12.1", Compiler:"gc",
Platform:"linux/amd64"}
Error from server (Forbidden): <html><head><meta http-equiv='refresh'
content='1;url=/login?from=%2Fversion%3Ftimeout%3D32s'/>
<script>window.location.replace('/login?from=%2Fversion%3Ftimeout%3D32s');
</script></head><body style='background-color:white; color:white;'>
Authentication required
<!--
You are authenticated as: anonymous
Groups that you are in:
Permission you need to have (but didn't): hudson.model.Hudson.Read
... which is implied by: hudson.security.Permission.GenericRead
... which is implied by: hudson.model.Hudson.Administer
-->
And also not finding the '~/.kube/config' file in machine.
Why do I get this authentication error when checking the kubectl version?
回答1:
You have to manually copy .kube/ directory from you cluster node into your local ~/.kube
If you don't have .kube/ on the master node, copy it from /etc/kubernetes/kube.conf
mkdir $HOME/.kube
scp root@<master-public-ip>:/etc/kubernetes/kubelet.conf $HOME/.kube/config
You can also define the filepath of kubeconfig by passing in --kubeconfig parameter, i.e.
kubectl version --kubeconfig ~/.kube/config
来源:https://stackoverflow.com/questions/55725477/authenticated-as-anonymous-groups-that-you-are-in-error-when-checking-kubectl