This kubectl plugin effectively replaces the gcloud container clusters get-credentials command, allowing for more
choice while avoiding annoyances such as changing the current context when adding new contexts. It also uses its own
authentication mechanism for kubectl, removing the dependency on gcloud altogether.
Why would I use this plugin?
- Do you have a lot of GKE clusters in the same Google Cloud Platform project?
- Do you dislike the verbosity of the Kubernetes contexts generated by
gcloud? - Do you want to update your cluster details independent of your contexts?
- Do you switch between contexts often, and are encumbered by
gcloudhaving to fetch new credentials each time?
If your answer is yes to either of those questions, kubectl gke might be for you!
kubectl gke get-credentials $PROJECT \
--selector env=production,tier!=foo \
--format '{{ .Cluster.Name }}'or equivalently
kubectl gke get-credentials $PROJECT -lenv=production,tier!=foo -f'{{ .Cluster.Name }}'or equivalently
export KUBECTL_GKE_CONTEXT_FORMAT='{{ .Cluster.Name }}'
kubectl gke get-credentials $PROJECT -lenv=production,tier!=fooUsing Go 1.16:
go install github.com/fsommar/kubectl-gke@latestTo verify that it's working as expected, run kubectl gke --help.