...

Text file src/edge-infra.dev/hack/scripts/gcloud-clusters-fzf.sh

Documentation: edge-infra.dev/hack/scripts

     1#!/usr/bin/env bash
     2#
     3# This script aims to reduce the amount of time you have to spend in
     4# the GCP console by allowing you to search through the current
     5# project's k8s clusters and select one to add it to your kubeconfig
     6# and make it active. You can use kubectx to do the same thing for
     7# clusters you already have in your kubeconfig but this goes to gcloud
     8# and finds them for you. Must have gcloud and fzf installed. Kubectx
     9# is also a third party utility you can install that is much faster
    10# than dialing out to gcloud if you have already done that before.
    11
    12gcloud container clusters list 2>/dev/null | \
    13    tail -n+2 | \
    14    awk '{print $1, "\t", $2}' | \
    15    fzf | \
    16    awk '{print "gcloud container clusters get-credentials", $1, "--zone ", $2}' | \
    17    sh -s

View as plain text