Files
floci/docs
Priamo Germosen 252bfe85a2 feat(lambda): mint EKS bearer tokens natively for the kubernetes executor (#2981)
* docs(lambda): qualify which kubeconfig auth methods the Kubernetes executor supports

#2919 replaced the Fabric8 Kubernetes client with a plain REST client that
only understands static-token and client-certificate kubeconfig auth. The
Kubernetes executor section still said Floci "uses your local kubeconfig"
without qualification, which reads as full kubectl parity. exec and
auth-provider credential plugins (aws eks get-token, gcloud) fail with a
named error instead, so an EKS or GKE user following the doc as-is would
be surprised.

Follow-up noted on hectorvent's approval of #2919.

* feat(lambda): mint EKS bearer tokens natively for the kubernetes executor

#2919 dropped the Fabric8 Kubernetes client, whose kubeconfig handling
covered exec-credential plugins like `aws eks get-token` as a side effect
of shelling out to them via client-go. The replacement REST client
rejected that shape outright, so kubeconfigs generated by
`aws eks update-kubeconfig` (the common case for a real EKS cluster)
stopped working.

Adds EksTokenMinter, which recognizes the `aws eks get-token
--cluster-name <name>` exec shape and mints the bearer token itself:
a presigned sts:GetCallerIdentity URL with x-k8s-aws-id bound into the
signature, base64url-encoded and prefixed with k8s-aws-v1., matching
what aws-iam-authenticator's webhook expects and what the AWS CLI's
own `aws eks get-token` produces. No subprocess is spawned and no SDK
dependency is added, keeping KubernetesApiClient as it was after #2919.

Recognition scans for "eks", "get-token" as a consecutive pair
anywhere in the exec args, rather than requiring them first: confirmed
against the AWS CLI's own update_kubeconfig.py, a generated kubeconfig
always puts the global --region ahead of the subcommand and --output
json after it, so a strictly-positional check would have rejected
every kubeconfig that tool actually produces.

Credentials are resolved from AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/
AWS_SESSION_TOKEN, falling back to the shared credentials file
(AWS_PROFILE, default ~/.aws/credentials). Both are read from the
kubeconfig exec block's own `env` entries first: `aws eks
update-kubeconfig --profile <p>` threads the profile through exec.env
precisely because the plugin has no other reason to see it. An
AWS_PROFILE the exec block names explicitly is honored ahead of static
keys that merely happen to be ambient in Floci's own process, rather
than falling out of plain env-var-beats-profile precedence: those
ambient keys weren't necessarily meant for this resolution, so letting
them silently outrank a profile the kubeconfig specifically asked for
would authenticate as the wrong principal. A lone access key or secret
key, at either the exec.env or ambient-env tier, is rejected outright
rather than silently falling through to the next source, matching
botocore's own PartialCredentialsError instead of quietly picking a
different identity than whatever was actually intended. A session
token is only ever combined with the access/secret key pair from the
same source (exec.env or ambient) it came from, never mixed across
the two, since a session token is only valid for the specific key
pair STS issued it alongside.

STS is signed against the region's actual partition suffix, sourced
from the AWS SDKs' own public partition metadata (botocore's
partitions.json): amazonaws.com for the commercial aws partition and
aws-us-gov, amazonaws.com.cn for aws-cn, and the classified
ISO/ISOB/ISOE/ISOF partitions each under their own distinct domain.
Previously this always assumed the commercial partition, so a
non-standard-partition cluster would get a token signed for a host
that isn't its real STS endpoint.

Role assumption is rejected explicitly, in every form get-token's own
--role-arn flag can actually reach this code as: not just the long
form and the abbreviated --role that update_kubeconfig.py writes when
--role-arn was passed to update-kubeconfig, but every unambiguous
prefix in between (--role-a, --role-ar) that AWS CLI's own argument
parser equally accepts, since role-arn is the only get-token option
starting with "role", plus all of those flags' --flag=value spellings.
Missing any of these would silently mint a token under ambient or
profile credentials instead of the identity the kubeconfig asked for.
Any other exec command or an auth-provider plugin still fails with a
named error rather than being silently mishandled;
SSO/IMDS/container-credentials/IRSA are not implemented.

mint's signing timestamp now takes an injectable Clock (defaulting to
Clock.systemUTC() for every existing caller) instead of calling
Instant.now() directly, so a test can pin it and assert on the exact
resulting signature. Added such a test: the signature for fixed
credentials, cluster, region and timestamp is checked against a value
computed by a from-scratch Python re-implementation of the SigV4 spec,
not ported from this code, so the two can't share a bug. Every other
test up to now only checked the token's shape (right host, right
query keys, a signature that looks like a signature); this is the
first one that proves the actual bytes are what the spec says they
should be.

Also updates docs/services/lambda.md's Kubernetes executor section,
which still said the aws eks get-token exec plugin was unsupported.
2026-09-04 18:05:00 -05:00
..
2026-03-15 17:43:56 -05:00