---
title: "Kubernetes"
description: "Let pods call Limrun with their service account token instead of a stored API key."
canonical_url: "https://docs.limrun.com/docs/access/workload-identity-federation/kubernetes"
markdown_url: "https://docs.limrun.com/docs/access/workload-identity-federation/kubernetes.md"
last_updated: "2026-11-26"
x_farming_labs_generated_preamble: true
---

# Kubernetes
URL: /docs/access/workload-identity-federation/kubernetes
LLM index: /llms.txt
Description: Let pods call Limrun with their service account token instead of a stored API key.

# Authenticate Kubernetes workloads with workload identity federation

A pod can mount a service account token for the audience `limrun` and exchange it for a short-lived Limrun access token. The kubelet rotates the token file, and the CLI and SDKs read it again whenever they renew, so no Limrun API key is stored in the cluster.

## Before you start

You need:

- The `admin` role in your Limrun organization.
- `kubectl` access to the cluster, and permission to edit the workload's pod spec.
- The namespace and service account the workload runs as.

## Find your cluster's issuer and keys

Limrun verifies tokens against your cluster's public signing keys, so it needs the issuer and the key set's URL. Print both from the cluster's discovery document:

```bash
kubectl get --raw /.well-known/openid-configuration
```

Copy `issuer` and `jwks_uri` exactly. The key path differs by platform; on EKS, for example, it is `/keys` under the issuer.

Limrun must be able to fetch `jwks_uri` from the internet without credentials:

- **EKS** serves each cluster's discovery document and keys publicly and anonymously.
- **GKE** serves the cluster's keys from `container.googleapis.com`. Check that `jwks_uri` answers an anonymous `curl` before you continue.
- **Other clusters** often serve the keys only through the API server. Publish them at a public HTTPS URL and point the API server's `--service-account-jwks-uri` flag at it. If the API server itself is reachable from the internet, you can instead let anonymous users read the discovery endpoints by binding the `system:service-account-issuer-discovery` ClusterRole to `system:unauthenticated`.

## Create the provider

Your cluster signs tokens for every pod in it, so the provider condition limits trust to the workloads that should reach Limrun.

1. Open [console.limrun.com](https://console.limrun.com), go to **Settings**, then **Workload identity federation**, and click the **+** button next to **Identity providers**.
2. In **Issuer**, choose **Kubernetes**.
3. Enter a provider name, paste `issuer` as the **Issuer URL** and `jwks_uri` as the **JWKS URL**.
4. Keep **Token audience** as `limrun`. The pod mounts its token with this audience.
5. In **Provider condition (CEL)**, name the service account:

   ```text
   assertion.sub == 'system:serviceaccount:NAMESPACE:SERVICE_ACCOUNT'
   ```

   To trust every service account in one namespace and choose among them in bindings, use `assertion.sub.startsWith('system:serviceaccount:NAMESPACE:')` instead.
6. Click **Create provider**. Limrun fetches the keys before it saves the provider, so a key URL it cannot reach fails here.

## Create a binding

1. In the provider's card, click the **+** button next to **Bindings**.
2. Enter a name and a **Claim condition (CEL)**, such as `assertion.sub == 'system:serviceaccount:builds:ci'`. Kubernetes also adds a `kubernetes.io` claim with the namespace, service account, and pod. Its name contains a dot, so read it by index, for example `assertion['kubernetes.io'].namespace == 'builds'`.
3. Enter the permissions the workload needs, one per line, such as `xcode:*:all`.
4. Click **Create binding**, expand **Setup**, and copy the binding ID.

## Mount the token in the pod

Add a projected service account token with the audience `limrun`, and point the workload at it:

```yaml
apiVersion: v1
kind: Pod
metadata:
  name: limrun-client
  namespace: builds
spec:
  serviceAccountName: ci
  containers:
    - name: client
      image: node:22
      command: ["sh", "-c", "npm install --global lim && lim whoami && sleep infinity"]
      env:
        - name: LIMRUN_WORKLOAD_IDENTITY_TOKEN_FILE
          value: /var/run/secrets/limrun/token
        - name: LIMRUN_WORKLOAD_IDENTITY_BINDING_ID
          value: binding_REPLACE_WITH_BINDING_ID
      volumeMounts:
        - name: limrun-token
          mountPath: /var/run/secrets/limrun
          readOnly: true
  volumes:
    - name: limrun-token
      projected:
        sources:
          - serviceAccountToken:
              audience: limrun
              expirationSeconds: 3600
              path: token
```

`audience` must match the provider's audience. `expirationSeconds` must be at least 600; the kubelet replaces the file once the token is 80% through its lifetime. Mount the volume as a directory, not with `subPath`, because a `subPath` mount never sees the rotated file. The pod's logs show `lim whoami` printing your organization and the binding's permissions. The SDKs read the same environment variables.

## Things to know

- **Avoid the default service account token.** The token Kubernetes mounts by default carries the API server's audience, so it is also a credential for your cluster. You can still use it by setting the provider's audience to match, but Limrun then receives a token your API server accepts.
- **Tokens outlive their pods.** Limrun verifies tokens offline, so a token from a deleted pod works until it expires. Keep `expirationSeconds` as short as your workload allows.
- **Clusters that rotate keys.** EKS rotates its signing key every seven days. Limrun refreshes stored keys about every 48 minutes; see [Signing key refresh](/docs/access/workload-identity-federation#signing-key-refresh).

See [Kubernetes service account token projection](https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#launch-a-pod-using-service-account-token-projection) for the Kubernetes side.

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
Docs-scoped sitemap: [/docs/sitemap.md](/docs/sitemap.md).
Well-known sitemap: [/.well-known/sitemap.md](/.well-known/sitemap.md).
