Thursday, May 31, 2018

How to get kubeconfig from google k8s cluster

1. Run the command showing from clicking on the connect button. This will create file in ~/.kube/config file. However this file can not be used directly by kubectl.
2. Run the following command:
   kubectl get pods
   The above command somehow changed the ./kube/config file adding the access-token and expiry-key. then that file ~/.kube/config


the above will be using access token in the kubeconfig.

You could also use user name and password.

edit the ~/.kube/config file, add the following in the users section of the file

- name: tong
  user:
    password: xxxxxx
    username:xxxxx

The user name and password should come from k8s cluster endpoint show credentials button.
Then in the contexts -> context -> user, use user tong. This will also work.

No comments:

Post a Comment