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

Quote from moshe on 20/07/2022, 8:44 pmProblem
User gets the following error when trying to connect to cluster "error: You must be logged in to the server (Unauthorized)"
even after running the following command to update the EKS configuration
aws eks update-kubeconfig --name eks-cluster --region eu-west-1
Solution
Authenticate with AWS CLI and run the following command to get your user configuration
aws sts get-caller-identity
The owner of the EKS Cluster ( the one who created the cluster ) need to add your IAM user or role to aws-auth ConfigMap.
kubectl edit configmap aws-auth --namespace kube-system
Add an IAM user or IAM role, complete one of the following steps.
IAM user
mapUsers: |
- userarn: arn:aws:iam::XXXXXXXXXXXX:user/MYUSERNAME
username: MYUSERNAME
groups:
- system:mastersIAM role
mapRoles: |
- rolearn: arn:aws:iam::XXXXXXXXXXXX:role/MYROLE
username: MYROLE
groups:
- system:masters
Problem
User gets the following error when trying to connect to cluster "error: You must be logged in to the server (Unauthorized)"
even after running the following command to update the EKS configuration
aws eks update-kubeconfig --name eks-cluster --region eu-west-1
Solution
Authenticate with AWS CLI and run the following command to get your user configuration
aws sts get-caller-identity
The owner of the EKS Cluster ( the one who created the cluster ) need to add your IAM user or role to aws-auth ConfigMap.
kubectl edit configmap aws-auth --namespace kube-system
Add an IAM user or IAM role, complete one of the following steps.
IAM user
mapUsers: |
- userarn: arn:aws:iam::XXXXXXXXXXXX:user/MYUSERNAME
username: MYUSERNAME
groups:
- system:masters
IAM role
mapRoles: |
- rolearn: arn:aws:iam::XXXXXXXXXXXX:role/MYROLE
username: MYROLE
groups:
- system:masters