Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dpkirchner/42f97f6d6df57fc552009743944fe779 to your computer and use it in GitHub Desktop.
Save dpkirchner/42f97f6d6df57fc552009743944fe779 to your computer and use it in GitHub Desktop.
execProviderConfig example
{
"execProviderConfig": {
"apiVersion": "client.authentication.k8s.io/v1beta1",
"args": [
"-c",
"import urllib.request, json, datetime; obj = json.loads(urllib.request.urlopen(urllib.request.Request(\"http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token\", headers={\"Metadata-Flavor\":\"Google\"})).read()); delta = datetime.timedelta(seconds=int(obj[\"expires_in\"])); out = {\"apiVersion\":\"client.authentication.k8s.io/v1beta1\",\"kind\":\"ExecCredential\",\"status\":{\"token\":obj[\"access_token\"],\"expirationTimestamp\":(delta + datetime.datetime.utcnow()).strftime(\"%Y-%m-%dT%H:%M:%SZ\")}}; print(json.dumps(out))"
],
"command": "/usr/bin/python3"
},
"tlsClientConfig": {
"caData": "xxx",
"insecure": false
}
}
@dpkirchner
Copy link
Author

Output looks like this:

{"apiVersion": "client.authentication.k8s.io/v1beta1", "kind": "ExecCredential", "status": {"token": "ya29.c.xxx", "expirationTimestamp": "2021-06-25T20:30:17Z"}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment