Llim.run

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:

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:

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:

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, 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:

    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:

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

See Kubernetes service account token projection for the Kubernetes side.