// zero trust · CI

GitHub Actions to Kubernetes, without a secret

A deploy job has to reach the cluster, and the quick way is a kubeconfig pasted into the repository’s secrets: shared by every workflow, rotated by nobody, and valid long after the job that needed it. kubelatch gives each run a credential of its own instead, and keeps nothing in GitHub.

// the exchange

An OIDC token in, a one-hour credential out

  1. GitHub signs a token for the run

    The workflow asks GitHub for the OIDC token it signs for that run, with the repository, the ref and the environment in it.

  2. kubelatch checks it against a trust rule

    A trust rule ties a repository, by its numeric ids, to a bot, and optionally to one branch or one environment.

  3. The job gets its credential

    If a rule matches, kubelatch answers once with that bot’s credential and its kubeconfig, for 1 hour by default.

Each OIDC token can be exchanged only once, so one captured after the job used it is worthless.

// the workflow

One step in the job

permissions:
  id-token: write   # lets the job request the OIDC token
  contents: read

steps:
  - uses: picaportelabs/kubelatch-action@v1
    with:
      url: https://kubelatch.example.com
  - run: kubectl get pods -n default

The full example ships in the docs, and an administrator gets it filled in with your address after creating the trust rule. There’s more detail on the Picaporte Labs blog.

// on record

Every kubectl call the job makes, in the audit

The job acts on the cluster as its bot, and every request is in the audit under that name. The credential’s note carries the repository, the ref, the run and who triggered it, so a change in production leads back to the workflow run that made it.

// questions

Questions about CI without secrets

Does it work with GitHub Enterprise Server?

Yes. The exchange works with GitHub Actions on github.com and on GitHub Enterprise Server. The runners must reach kubelatch over https, so a kubelatch on a laptop won’t do.

What about other CI systems, or Argo CD?

They use a bot’s credential issued by hand. It expires in 90 days at most and lives in that tool’s secret store.

Give every permission an end date.

Free for small teams. Fifteen minutes to try it.