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

5

8

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?

Catechumen answered 30/3, 2017 at 7:35 Comment(1)
Did you figure out an answer for this? I am facing the similar error after configuring oidc with k8sNorry
C
8

You have to run:

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

Docs here.

Catechumen answered 30/3, 2017 at 7:35 Comment(0)
T
0

$gcloud config set compute/zone [zone]

$gcloud container clusters get-credentials [clustername]

Trichinize answered 24/4, 2017 at 8:34 Comment(0)
H
0

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?

Hekker answered 5/6, 2017 at 17:3 Comment(0)
D
0

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

Daphinedaphna answered 8/9, 2017 at 5:52 Comment(0)
C
0

The same error appears if you run kubectl get commands on the cloud shell after creating the azure AKS cluster.

It's because you need to set the cluster context first. For that you can, Go to the cluster on AKS -> Overview -> Connect and run the two commands.

  • 1st command is to set the cluster subscription
  • 2nd command is to download the cluster credentials.

enter image description here

Now the kubectl get commands would work. You can test it by running kubectl get all

Choler answered 6/4 at 13:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.