kubectl error: "You must be logged in to the server (the server has asked for the client to provide credentials)"

3/30/2017

I'm running the following command and getting an error:

$ kubectl get nodes
error: You must be logged in to the server (the server has asked for the client to provide credentials)

What's going on?

-- Petko M
kubernetes

4 Answers

6/5/2017

Re-setting the compute/zone seems to do the trick. Using this command

gcloud container clusters list

I got

NAME  ZONE            MASTER_VERSION  MASTER_IP      MACHINE_TYPE   NODE_VERSION  NUM_NODES  STATUS
k0    europe-west1-d  1.6.4           35.187.164.84  n1-standard-1  1.6.4         3          RUNNING

So the zone seemed to configured, but it was only after re-executing

gcloud config set compute/zone europe-west1-d

did things start working again.

So the real question is: why has is the compute zone config suddenly no longer valid?

-- Mark Chassy
Source: StackOverflow

3/30/2017

You have to run:

$ gcloud container clusters get-credentials [cluster-name]

Docs here.

-- Petko M
Source: StackOverflow

4/24/2017

$gcloud config set compute/zone [zone]

$gcloud container clusters get-credentials [clustername]

-- Yogesh BG
Source: StackOverflow

9/8/2017

I got the similar issue in Minikube environment.I restarted minikube and it was working as expected. So if the issue is occurring in Minikube environment Please restart it

-- kartick shaw
Source: StackOverflow