Skip to content

Add new oidc subtype for Kubernetes joining#57538

Merged
timothyb89 merged 15 commits intomasterfrom
timothyb89/kubernetes-jwks-uri
Aug 7, 2025
Merged

Add new oidc subtype for Kubernetes joining#57538
timothyb89 merged 15 commits intomasterfrom
timothyb89/kubernetes-jwks-uri

Conversation

@timothyb89
Copy link
Copy Markdown
Contributor

@timothyb89 timothyb89 commented Aug 5, 2025

This adds a new oidc subtype for the Kubernetes join method. This differs from static_jwks in that it fetches the /.well-known/openid-configuration endpoint at the issuer and subsequently fetches the JWKS keys from the configured URL. This works around a common issue with static_jwks on providers like EKS that rotate keys frequently, since we'll fetch the key set as needed.

Note that caching (#49213) was deferred for now but as it reuses our existing OIDC machinery, it should be trivial to swap in a caching HTTP client in a follow-up PR.

changelog: Add new oidc joining mode for Kubernetes delegated joining to support providers that can be configured to provide public OIDC endpoints, like EKS, AKS, and GKE.

Fixes #39170


To use, you'll need a Kubernetes cluster that issues OIDC tokens from an issuer with a public OpenID-compatible endpoint, like Amazon EKS. To check and resolve the right issuer value, run this command:

$ curl $(kubectl get --raw /.well-known/openid-configuration | jq -r '.issuer')/.well-known/openid-configuration | jq -r '.issuer'
https://oidc.eks.us-west-2.amazonaws.com/id/my-cluster

This attempts to resolve the issuer from your local machine; providers like EKS will return an OIDC config pointing to internal URLs when used on an internal network. If your provider's OIDC endpoint isn't available, the curl call will fail, in which case this method won't work.

Once you've determined the issuer, create a join token:

kind: token
metadata:
  name: kubernetes-oidc-example
spec:
  bot_name: kubernetes-oidc-example
  join_method: kubernetes
  kubernetes:
    allow:
    - service_account: default:example
    oidc:
      issuer: https://oidc.eks.us-west-2.amazonaws.com/id/my-cluster
    type: oidc
  roles:
  - Bot
version: v2

You'll need to configure your Kubernetes pod to project a token with the Teleport cluster name as the configured audience, in this case we'll assume example.teleport.sh.

To project an additional token, add this to your pod spec:

spec:
  containers:
  - name: example
    # ...
    volumeMounts:
    - mountPath: /var/run/secrets/teleport-token
      name: teleport-token
  volumes:
  - name: teleport-token
    projected:
      defaultMode: 420
      sources:
      - serviceAccountToken:
          audience: example.teleport.sh
          expirationSeconds: 600
          path: token

When joining a client (Teleport agent, tbot, etc) make sure KUBERNETES_TOKEN_PATH is set to the token in the projected mount path, e.g. /var/run/secrets/teleport-token/token.

This adds a new `oidc` subtype for Kubernetes joining, which allows
workloads to join using a Kubernetes service account token (JWT)
as usual, but verifies it using an OIDC flow rather than a static JWKS
keyset. This should better support platforms like EKS where the JWKS
keyset is rotated regularly.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 5, 2025

Amplify deployment status

Branch Commit Job ID Status Preview Updated (UTC)
timothyb89/kubernetes-jwks-uri c92abb4 6 ✅SUCCEED timothyb89-kubernetes-jwks-uri 2025-08-06 22:57:23

Comment thread api/proto/teleport/legacy/types/types.proto
@timothyb89 timothyb89 added this pull request to the merge queue Aug 7, 2025
Merged via the queue into master with commit 8a53c6d Aug 7, 2025
47 checks passed
@timothyb89 timothyb89 deleted the timothyb89/kubernetes-jwks-uri branch August 7, 2025 01:31
@backport-bot-workflows
Copy link
Copy Markdown
Contributor

@timothyb89 See the table below for backport results.

Branch Result
branch/v17 Failed
branch/v18 Failed

timothyb89 added a commit that referenced this pull request Aug 7, 2025
* MWI: Add `oidc` subtype for Kubernetes joining

This adds a new `oidc` subtype for Kubernetes joining, which allows
workloads to join using a Kubernetes service account token (JWT)
as usual, but verifies it using an OIDC flow rather than a static JWKS
keyset. This should better support platforms like EKS where the JWKS
keyset is rotated regularly.

* Validate OIDC subtype properly

* Initialize OIDC validator at startup

* Fix OIDC claims implementation

* Force use of cluster name as audience

* Remove authorized party workaround

* Reintroduce kubernetes claims check

* Remove unused constant

* Update generated operator resources

* Update generated TF docs

* Add validator tests

* Improve proto docs, enforce HTTP issuers, and add insecure override

* Update autogenerated docs
github-merge-queue bot pushed a commit that referenced this pull request Aug 8, 2025
* MWI: Add `oidc` subtype for Kubernetes joining

This adds a new `oidc` subtype for Kubernetes joining, which allows
workloads to join using a Kubernetes service account token (JWT)
as usual, but verifies it using an OIDC flow rather than a static JWKS
keyset. This should better support platforms like EKS where the JWKS
keyset is rotated regularly.

* Validate OIDC subtype properly

* Initialize OIDC validator at startup

* Fix OIDC claims implementation

* Force use of cluster name as audience

* Remove authorized party workaround

* Reintroduce kubernetes claims check

* Remove unused constant

* Update generated operator resources

* Update generated TF docs

* Add validator tests

* Improve proto docs, enforce HTTP issuers, and add insecure override

* Update autogenerated docs
timothyb89 added a commit that referenced this pull request Aug 12, 2025
* MWI: Add `oidc` subtype for Kubernetes joining

This adds a new `oidc` subtype for Kubernetes joining, which allows
workloads to join using a Kubernetes service account token (JWT)
as usual, but verifies it using an OIDC flow rather than a static JWKS
keyset. This should better support platforms like EKS where the JWKS
keyset is rotated regularly.

* Validate OIDC subtype properly

* Initialize OIDC validator at startup

* Fix OIDC claims implementation

* Force use of cluster name as audience

* Remove authorized party workaround

* Reintroduce kubernetes claims check

* Remove unused constant

* Update generated operator resources

* Update generated TF docs

* Add validator tests

* Improve proto docs, enforce HTTP issuers, and add insecure override

* Update autogenerated docs
github-merge-queue bot pushed a commit that referenced this pull request Aug 22, 2025
* [v18] Add new `oidc` subtype for Kubernetes joining (#57538) (#57683)

* MWI: Add `oidc` subtype for Kubernetes joining

This adds a new `oidc` subtype for Kubernetes joining, which allows
workloads to join using a Kubernetes service account token (JWT)
as usual, but verifies it using an OIDC flow rather than a static JWKS
keyset. This should better support platforms like EKS where the JWKS
keyset is rotated regularly.

* Validate OIDC subtype properly

* Initialize OIDC validator at startup

* Fix OIDC claims implementation

* Force use of cluster name as audience

* Remove authorized party workaround

* Reintroduce kubernetes claims check

* Remove unused constant

* Update generated operator resources

* Update generated TF docs

* Add validator tests

* Improve proto docs, enforce HTTP issuers, and add insecure override

* Update autogenerated docs

* Partially backport OIDC changes to fix build, include #57789

This partially backports various dependencies of the original change.
Note that this is not a clean backport, and minor code and
organizational changes were made to facilitate this backport,
including copying some OIDC code directly into the token validator.

Additionally, caching support from #57789 was integrated directly. It
inherently depends on the same OIDC code that required modification,
so it has been pulled in directly.

* Remove caching support from the backport

I've abandoned the caching approach in #57789, so this PR will proceed
without caching, as in branch/v18.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Kubernetes join subtype which fetches JWKS from a known endpoint

3 participants