1
0
Fork 0
mirror of https://github.com/imjasonh/gke-auth synced 2026-07-07 00:23:18 +00:00
No description
Find a file
dependabot[bot] fbe798ff67
Bump the all group across 1 directory with 2 updates
Bumps the all group with 2 updates in the / directory: [actions/checkout](https://github.com/actions/checkout) and [actions/setup-go](https://github.com/actions/setup-go).


Updates `actions/checkout` from 4.1.6 to 4.1.7
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](a5ac7e51b4...692973e3d9)

Updates `actions/setup-go` from 5.0.1 to 5.0.2
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](cdcb360436...0a12ed9d6a)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-10 16:47:55 +00:00
.github Bump the all group across 1 directory with 2 updates 2024-07-10 16:47:55 +00:00
.gitignore add goreleaser.yaml 2022-03-09 17:07:42 -05:00
.goreleaser.yaml add goreleaser.yaml 2022-03-09 17:07:42 -05:00
action.yaml allow unset vars 2022-03-11 14:40:46 -05:00
go.mod bump deps and update 2024-05-21 14:23:35 -07:00
go.sum bump deps and update 2024-05-21 14:23:35 -07:00
LICENSE initial commit 2022-03-09 16:16:14 -05:00
main.go Use clientcmd LoadingRules 2022-06-16 16:28:56 -06:00
README.md add note about gke-gcloud-auth-plugin 2022-06-17 09:34:11 -04:00
setup.txt container.developer to see stuff in the cluster 2022-03-11 14:35:35 -05:00

Auth to GKE without gcloud

Test

Installation

go install github.com/imjasonh/gke-auth@latest

Use

Once you've installed the Go binary, run it:

gke-auth --project=[MY_PROJECT] \
    --location=[REGION_OR_ZONE] \
    --cluster=[CLUSTER_NAME]

Now you have auth and kubeconfigs set up to use the cluster.

Or, using GitHub Actions:

- uses: imjasonh/gke-auth@v0.1.0
  with:
    project: [MY_PROJECT]
    location: [REGION_OR_ZONE]
    cluster: [CLUSTER_NAME]

You probably want to set up Workload Identity between your GitHub Actions workflow and your GCP project.

Test it with:

kubectl get pods

Why?

gcloud is great. It's like a Swiss army knife for the cloud, if a knife could do anything to a cloud.

It does so much. It does soooo much!

Too much.

This leads it to be really huge. Hundreds of megabytes of sweet delicious Python. Python that has to be interpreted before it can even start running anything.

If you're downloading and installing and running gcloud just to execute gcloud container clusters get-credentials so you can switch to using kubectl -- especially in a CI environment -- you're wasting a lot of time.

Installing gcloud can take minutes, compared to just a few seconds with gke-auth, even if you have to build it from source.

The example GitHub Actions workflow sets up Workload Identity auth to GKE and lists pods in a cluster in about seven seconds. Compare that to the equivalent using gcloud, which takes 33 seconds.

gke-gcloud-auth-plugin

gcloud itself includes a K8s auth plugin very similar to gke-auth, called gke-gcloud-auth-plugin.

For more information about this plugin, see this GCP blog post.

Like gke-auth, this plugin can be configured to be used by kubectl and client-go to get auth credentials.

Unlike gke-auth, the plugin is installed using gcloud components add gke-gcloud-auth-plugin, and configured to be used with gcloud container get-credentials, so while it's still better than having kubectl invoke gcloud every time it needs new credentials, it still seems to mostly require gcloud to install and use it, at least as recommended in documentation.

gke-auth should be more or less equivalent to gke-gcloud-auth-plugin in core functionality, but gke-auth doesn't need or recommend gcloud at all to install or configure it.