Cannot connect to eks cluster via kubectl

9/16/2019

I am finding it impossible to connect to my k8s cluster on eks.

I am getting the error

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

However,

I have multiple clusters:

$ kubectl config get-clusters
NAME
hilarious-unicorn-1568659474.eu-west-1.eksctl.io
arn:aws:eks:eu-west-1:<redacted>:cluster/derp

These also appear when I do

$ kubectl config get-contexts

My issue is, if I switch to my eu-west cluster/context by running kubectl config use-context <my context>

And then do kubectl cluster-info I get

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

I have ran

$ aws eks update-kubeconfig --name myCluster

And this has updated in my ~/.kube/config file but to no avail.

I am literally at a loss as to why this is not working because it was previously working, and I can authenticate on another cluster.

Edits due to Comments

  1. @Eduardo Baitello

    • I have aws-iam-authenticator installed. Although we also use awsmfa.

Here is the contents of my .kube/config

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: redacted
    server: redacted
  name: arn:aws:eks:eu-west-1:redacted:cluster/savvy
- cluster:
    certificate-authority-data: redacted
    server: redacted
  name: hilarious-unicorn-1568659474.eu-west-1.eksctl.io
contexts:
- context:
    cluster: arn:aws:eks:eu-west-1:redacted:cluster/savvy
    user: arn:aws:eks:eu-west-1:redacted:cluster/savvy
  name: arn:aws:eks:eu-west-1:redacted:cluster/savvy
- context:
    cluster: hilarious-unicorn-1568659474.eu-west-1.eksctl.io
    user: karl@hilarious-unicorn-1568659474.eu-west-1.eksctl.io
  name: karl@hilarious-unicorn-1568659474.eu-west-1.eksctl.io
current-context: arn:aws:eks:eu-west-1:redacted:cluster/savvy
kind: Config
preferences: {}
users:
- name: arn:aws:eks:eu-west-1:redacted:cluster/savvy
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1alpha1
      args:
      - --region
      - eu-west-1
      - eks
      - get-token
      - --cluster-name
      - savvy
      command: aws
- name: karl@hilarious-unicorn-1568659474.eu-west-1.eksctl.io
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1alpha1
      args:
      - token
      - -i
      - hilarious-unicorn-1568659474
      command: aws-iam-authenticator
      env: null
  1. @shogan

Running kubectl describe configmap -n kube-system aws-auth says I am (Unauthorized)

-- Karl Taylor
amazon-web-services
aws-eks
kubernetes

0 Answers