Search code examples
kuberneteskubectlkubeconfig

How to add token_id to .kube/config file directly


The official documentation of kubernetes (https://kubernetes.io/docs/reference/access-authn-authz/authentication/) states at some point: "3. Call Kubectl with --token being the id_token OR add tokens to .kube/config" (just search for mentioned phrase in the provided doc url to get the context).

kubernetes doc

Can anyone give me example where can I "add tokens to .kube/config" directly?

I am in a scenario, when it is needed for me, I can access my cluster with --token inline option but I need to go with adding it to .kube/config.

I am trying to do sth like this but doesn't work (still need to add --token inline option, doesn't work without it):

users:
  - user:
      token: >-
        ey...........

Solution

  • Yeah... yellow duck works... 5 sec after posting question I noticed that the "context" stuff is the key factor here, so the user of clyster need to match the name of user in users (I was missing the "name" filed for my user, matching the correct cluster context...), e.g.:

    users:
      - name: shoot-x
        user:
          token: >-
            ey