A small utility to generate a kubectl configuration file for all clusters you have access to in GKE.

gke-config-helper

A small utility to generate a kubectl configuration file for all clusters you have access to in GKE.

Usage

$ gke-config-helper

The basic invocation will check each project you have access to, list clusters and output a kubeconfig with a cluster and a context entry for each of them to stdout.

Multiple config files

Since you might call this utility on a semi-regular basis, when there are new clusters to interact with, it is suggested to store the output in a separate configuration file if you also connect to non-GKE clusters (eg minikube). kubectl supports merging multiple configuration files by using the KUBECONFIG environment variable:

$ gke-config-helper > ~/.kube/gke-config
$ export KUBECONFIG=~/.kube/config:~/.kube/gke-config

In this way, other cluster, context and user configurations are not affected by updating the GKE configuration. kubectl also stores written values in the first of the files, meaning that current-context will remain in the default file and be preserved when regenerating the gke-config file.

Restricting projects

If you have access to a lot of projects, iterating over all of them might be slow. The flag --search-root allows you to restrict the search to projects that are children of a folder.

$ gke-config-helper --search-root my-folder

This works to any depth, not only direct decendants of my-folder.

Controlling the context name

By default, the name of each context will be <projectId>-<clusterName>. You can control this with the --context-name-template flag, which takes a Go template as an argument. Both the built-in Go functions as well as the sprig library functions are available.

The properties available for templating are:

  • ProjectId: The project id
  • Name: Name of the cluster
  • Location: Region name

For example:

$ gke-config-helper --context-name-template '{{ slice (.Name | splitList "-") 0 2 | join "-" }}_{{ .Location | substr 0 2 }}'

With a cluster foo-bar-baz in europe-west3, this would generate a context name of foo-bar_eu.

Similar Resources

This repo contains example on how to consume secrets from Google Secret Manager from GKE

GKE Secret Manager. Environment setup This repo contains examples of how to consume secrets from Google Secret Manager (GSM) from Google Kubernetes En

Dec 5, 2022

Install hubble-ui on GKE Dataplane V2

GKE Hubble Export This is a grpc server wrapper that re-export the cilium agent's observer service and peer service from the local domain socket. And

Jan 2, 2023

Simple tool to generate dockerconfigjon. This use snippets from kubectl.

gen-dockercfg Simple tool to generate dockerconfigjon. This use snippets from kubectl. Usage: gen-dockercfg -email string Registry email -pas

Jan 7, 2022

A pain of glass between you and your Kubernetes clusters.

kube-lock A pain of glass between you and your Kubernetes clusters. Sits as a middle-man between you and kubectl, allowing you to lock and unlock cont

Oct 20, 2022

Kubectl plugin to ease sniffing on kubernetes pods using tcpdump and wireshark

Kubectl plugin to ease sniffing on kubernetes pods using tcpdump and wireshark

ksniff A kubectl plugin that utilize tcpdump and Wireshark to start a remote capture on any pod in your Kubernetes cluster. You get the full power of

Jan 4, 2023

colorizes kubectl output

colorizes kubectl output

kubecolor Colorize your kubectl output get pods describe pods something wrong You can change color theme for light-backgrounded environment What's thi

Jan 8, 2023

kubectl plugin for signing Kubernetes manifest YAML files with sigstore

kubectl plugin for signing Kubernetes manifest YAML files with sigstore

k8s-manifest-sigstore kubectl plugin for signing Kubernetes manifest YAML files with sigstore ⚠️ Still under developement, not ready for production us

Nov 28, 2022

A kubectl plugin for finding decoded secret data with productive search flags.

kubectl-secret-data What is it? This is a kubectl plugin for finding decoded secret data. Since kubectl only outputs base64-encoded secrets, it makes

Dec 2, 2022

A 'kubectl' plugin for interacting with Clusternet.

kubectl-clusternet A kubectl plugin for interacting with Clusternet. Installation Install With Krew kubectl-clusternet can be installed using Krew, pl

Aug 14, 2022
Go-gke-pulumi - A simple example that deploys a GKE cluster and an application to the cluster using pulumi

This example deploys a Google Cloud Platform (GCP) Google Kubernetes Engine (GKE) cluster and an application to it

Jan 25, 2022
An operator for managing ephemeral clusters in GKE

Test Cluster Operator for GKE This operator provides an API-driven cluster provisioning for integration and performance testing of software that integ

Oct 22, 2022
kubectl-fzf provides a fast and powerful fzf autocompletion for kubectl
kubectl-fzf provides a fast and powerful fzf autocompletion for kubectl

Kubectl-fzf kubectl-fzf provides a fast and powerful fzf autocompletion for kubectl. Table of Contents Kubectl-fzf Table of Contents Features Requirem

Nov 3, 2021
Kubectl golang - kubectl krew template repo

kubectl krew template repo There's a lot of scaffolding needed to set up a good

Jan 11, 2022
A golang tool to list out all EKS clusters with active nodegroups in all regions in json format

eks-tool A quick and dirty tool to list out all EKS clusters with active nodegro

Dec 18, 2021
Flux is a tool for keeping Kubernetes clusters in sync with sources of configuration, and automating updates to configuration when there is new code to deploy.
Flux is a tool for keeping Kubernetes clusters in sync with sources of configuration, and automating updates to configuration when there is new code to deploy.

Flux is a tool for keeping Kubernetes clusters in sync with sources of configuration (like Git repositories), and automating updates to configuration when there is new code to deploy.

Jan 8, 2023
kubectl plugin for generating nginx-ingress compatible basic-auth secrets on kubernetes clusters

kubectl-htpasswd kubectl plugin for easily generating hashed basic auth secrets. Supported hash algorithms bcrypt Examples Create the secret on the cl

Jul 17, 2022
KinK is a helper CLI that facilitates to manage KinD clusters as Kubernetes pods. Designed to ease clusters up for fast testing with batteries included in mind.
KinK is a helper CLI that facilitates to manage KinD clusters as Kubernetes pods. Designed to ease clusters up for fast testing with batteries included in mind.

kink A helper CLI that facilitates to manage KinD clusters as Kubernetes pods. Table of Contents kink (KinD in Kubernetes) Introduction How it works ?

Dec 10, 2022
PolarDB Stack is a DBaaS implementation for PolarDB-for-Postgres, as an operator creates and manages PolarDB/PostgreSQL clusters running in Kubernetes. It provides re-construct, failover swtich-over, scale up/out, high-available capabilities for each clusters.
PolarDB Stack is a DBaaS implementation for PolarDB-for-Postgres, as an operator creates and manages PolarDB/PostgreSQL clusters running in Kubernetes. It provides re-construct, failover swtich-over, scale up/out, high-available capabilities for each clusters.

PolarDB Stack开源版生命周期 1 系统概述 PolarDB是阿里云自研的云原生关系型数据库,采用了基于Shared-Storage的存储计算分离架构。数据库由传统的Share-Nothing,转变成了Shared-Storage架构。由原来的N份计算+N份存储,转变成了N份计算+1份存储

Nov 8, 2022
A very simple, silly little kubectl plugin / utility that guesses which language an application running in a kubernetes pod was written in.

A very simple, silly little kubectl plugin / utility that guesses which language an application running in a kubernetes pod was written in.

Mar 9, 2022