Kubectl: error: You must be logged in to the server (Unauthorized)

Hi All,

I have an EKS cluster created by another IAM user which I need access to. So, I am trying to edit the Configmap “aws-auth” and add the relevant rolearn and userarn in the mapRoles and mapUsers section resp.

But when I run the kubectl apply -f configmap aws-auth or for that matter run any kubectl command, I am getting this error:

$ kubectl cluster-info

To further debug and diagnose cluster problems, use ‘kubectl cluster-info dump’.
error: You must be logged in to the server (Unauthorized)

I have also updated the kubeconfig with the relevant cluster details but nothing seems to be working. A little nudge here will definitely help.


Hello kunal,
Can you check this link https://aws.amazon.com/premiumsupport/knowledge-center/eks-api-server-unauthorized-error/? we hope to help you with troubleshooting this issue.

Yes, I was able to connect to the cluster by updating the aws-auth config map with the user.