fsommar / kubectl-gke

A kubectl plugin that replaces the get-credentials part of gcloud, allowing for more choice while avoiding annoyances such as changing the current context when adding new contexts.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

A kubectl plugin that replaces the get-credentials part of gcloud, allowing for more choice while avoiding annoyances such as changing the current context when adding new contexts.

License:MIT License


Languages

Language:Go 100.0%