How to export kubeconfig file from existing cluster?

5/15/2020

Is there an easy way to export kubeconfig file from existing cluster so i can use it in CI/CD ?

-- Raad Altaie
google-kubernetes-engine
kubectl
kubernetes

2 Answers

5/15/2020

You can use gcloud to generate a kubeconfig entry, given that you have at least clusterViewer IAM role:

gcloud container clusters get-credentials cluster-name

For reference:

-- Thomas Portwood
Source: StackOverflow

5/17/2020

What kind of cluster is it? A managed(AKS,EKS or GKE etc) one, where is it deployed? Can you ssh in to master node, if yes, please

cat /etc/kubernetes/admin.conf or cat ~/.kube/config

and copy the file, which is the kubeconfig for your cluster.

Other ways to create the kubeconfig, Run the following command

kubectl config view --minify, it will display all the info except for the client ca certificate and client key. The location of those keys depends on how the cluster is setup.

-- redzack
Source: StackOverflow