A Kubernetes authentication helper to expose per-user credentials as Image Pull Secrets for Google Container Registry
cargo install k8s-gcr-auth-helper
NOTE: On Windows, if you are having trouble building with native TLS you can switch to rustls, e.g.
cargo install k8s-gcr-auth-helper --no-default-features --features rustls-tls
The docker image also needs to be built and available to your Kubernetes cluster if you want to use the add
mode. For example to test your local changes using k3d
```
k3d create --name auth-test export KUBECONFIG=$(k3d get-kubeconfig --name auth-test)
docker build --tag k8s-gcr-auth-helper:local .
cargo run -- add --controller-image k8s-gcr-auth-helper:local --service-account default gcr-secret
cargo run -- remove --service-account default gcr-secret
k3d delete --name auth-test ```
To install in the current namespace of your current Kubernetes cluster:
k8s-gcr-auth-helper add gcr-pull-secret-name
To install and add to the default service account
k8s-gcr-auth-helper add --service-account default gcr-pull-secret-name
To install and add to the all service accounts in the namespace
k8s-gcr-auth-helper add --all-service-accounts gcr-pull-secret-name
NOTE: You can specify multiple --service-account
arguments to install in multiple service accounts. To install in multiple namespaces run the command multiple times (with --namespace
if you want to avoid changing namespace)
The first time the command is run it will open a browser to get an OAuth2 refresh token which will be stored in the cluster. A refresh service deployment will be created that listens for auth failures and refreshes the access token secret as required.
To remove use the same command with add
replaced by remove
, e.g.:
k8s-gcr-auth-helper remove gcr-pull-secret-name
NOTE: If you have manually added an imagePullSecrets
reference to additional service accounts you can specify them with --service-account ...
or you can just purge the secret reference from all accounts with --all-service-accounts
. If you forget you can always edit the service accounts manually.