The python gcloud has always sucked. It's slow, takes up a ~100MB of disk space, and annoying to install in CI/CD environments. But I've always tolerated it because it worked just well enough. That has changed recently with some super annoying changes (1, 2). So let's fix it by reimplementing gcloud in go!
This implementation of gcloud is incrementally adoptable, meaning that it will automatically fallback to python gcloud if we have not implemented a specific subcommand. My initial goal is to implement things I personally need for CI/CD in Linux environments. Contributions are welcome for other features and environments.
Regardless of your installation method, you need to make sure that this gcloud is higher in your $PATH than the python gcloud.
A good $PATH looks like this (where this gcloud is in /home/alex/go/bin):
echo $PATH
/home/alex/go/bin:/opt/google-cloud-sdk/bin/
If you do not install via the release, you must manually install scripts/docker-credential-gcloud.
curl -L https://github.com/gartnera/gcloud/releases/download/v0.0.7/gcloud_0.0.7_linux_amd64.tar.gz | tar xz -C /usr/local/bin
or
wget -O - https://github.com/gartnera/gcloud/releases/download/v0.0.7/gcloud_0.0.7_linux_amd64.tar.gz | tar xz -C /usr/local/bin
go install github.com/gartnera/gcloud@latest
-
gcloud auth application-default login(code flow) -
gcloud auth application-default print-access-token -
gcloud auth print-access-token -
gcloud auth print-identity-token -
gcloud auth configure-docker -
gcloud auth docker-helper -
gcloud container clusters get-credentials -
gcloud config config-helper --format=client.authentication.k8s.io/v1(used bygcloud container clusters get-credentials)
gcloud auth autologin(login only if needed)
- service account impersonation via
GOOGLE_IMPERSONATE_SERVICE_ACCOUNT