Skip to content

Latest commit

 

History

History
45 lines (31 loc) · 1.34 KB

README.md

File metadata and controls

45 lines (31 loc) · 1.34 KB

kubectl gke

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 gcloud having to fetch new credentials each time?

If your answer is yes to either of those questions, kubectl gke might be for you!

Example usage

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!=foo

Installation

Using Go 1.16:

go install github.com/fsommar/kubectl-gke@latest

To verify that it's working as expected, run kubectl gke --help.