Created
July 10, 2025 07:42
-
-
Save Ark-kun/cb04c51e7caa8f39bc3dc84fb2ae49cc to your computer and use it in GitHub Desktop.
gke-gcloud-auth-plugin.py replacement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Python-based replacement for gke-gcloud-auth-plugin | |
# Author: Alexey Volkov | |
import json | |
import google.auth.transport.requests | |
import google.oauth2.credentials | |
if __name__ == "__main__": | |
credentials: google.oauth2.credentials.Credentials = google.auth.default()[0] | |
credentials.refresh(google.auth.transport.requests.Request()) | |
exec_credential_dict = { | |
"kind": "ExecCredential", | |
"apiVersion": "client.authentication.k8s.io/v1beta1", | |
"spec": {"interactive": False}, | |
"status": { | |
"expirationTimestamp": credentials.expiry.isoformat(timespec="seconds") + "Z", | |
"token": credentials.token, | |
}, | |
} | |
print(json.dumps(exec_credential_dict, indent=4)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment