Skip to content
Opod

Security

Worker identity

How workers prove who they are to their leader — HMAC-signed commands, join tokens, and per-worker certificates you can revoke while the pod still runs.

Inside an endpoint, three things protect the hop between the leader and its workers.

MechanismWhat it does
HMAC per nodeevery command from a leader to a worker is signed with a per-node secret
Join tokenthe shared secret a worker presents to register with its leader; scoped to one endpoint
Worker certificatea named, revocable identity: a certificate signed by the endpoint's own CA, with a SPIFFE URI SAN naming the worker

Engine ports bind to 127.0.0.1 inside the worker container; the worker agent is the only exposed surface.

In short

A worker proves to its leader that it belongs to the endpoint. By default it does so with the endpoint's join token, a shared secret, and every command the leader sends it is HMAC-signed. With certificates on, each worker also gets its own certificate, signed by a CA that belongs to that one endpoint. You can then revoke one worker by name, and the leader refuses it at once, while its pod still runs. On 0.2.1 that holds only for a worker that connected after certificates were turned on: one that was already connected keeps its old connection and is not refused. From 0.3.0, turning certificates on closes each worker's join connection once, so it reconnects with its certificate and a revocation reaches it.

When you need it

  • You must be able to cut off one worker without touching the others, for example after a node is compromised.
  • Your security review asks for a per-workload identity rather than a shared secret.
  • You want workers to join with no shared secret at all: workers.mtls=require.

Do it

  1. Check the current mode

    curl -s -H "$H" https://cp.example.com/api/v1/endpoints/<id>/worker-identities | jq '{mtls, identities: [.identities[].nodeId]}'

    allow is the default: a worker with a certificate uses it, one without uses its join token.

  2. Give the workers their certificates

    Roll out each endpoint once. The rollout mints the endpoint's CA and one certificate per worker slot, and restarts the workers onto them.

    curl -s -H "$H" https://cp.example.com/api/v1/endpoints/<id>/plan > plan.json
    curl -s -H "$H" -H 'Content-Type: application/json' -X POST \
      "https://cp.example.com/api/v1/endpoints/<id>/rollouts?note=worker%20certificates" -d @plan.json
  3. Revoke one worker

    curl -s -H "$H" -X POST https://cp.example.com/api/v1/endpoints/<id>/worker-identities/n_3f9a1c_0_node-a/revoke

    The leader refuses the old certificate at once. The worker is out of service until the next rollout moves its pod onto the new certificate.

  4. Require certificates, optionally

    After every endpoint has rolled once on allow:

    helm upgrade opodcp oci://ghcr.io/opod-io/charts/opodcp -n opodcp --reset-then-reuse-values --set workers.mtls=require

Check it worked

curl -s -H "$H" https://cp.example.com/api/v1/endpoints/<id>/worker-identities | jq '.identities[] | {nodeId, revoked}'

A good answer lists one identity per single-replica worker row, and the revoked serial under revoked for the worker you revoked. The event endpoint.worker-identity-revoked names the node, both serials and who acted; the Activity page shows it.

If it fails

Symptom or codeCauseFix
A worker row is missing from identitiesthe row has replicas; replicas share one template and join by tokenone row per node, if it needs its own identity
400 invalid on revokethe node id is not in the plan, or workers.mtls is offcopy the id from GET …/worker-identities; use allow or require
E-MTLS-REPLICASrequire and a worker row with more than one replica, or autoscale.max above 1one row per node and max: 1, or allow
E-MTLS-GANGrequire and an active gangallow, or single workers
Workers stop joining after requirethey have not rolled onto a keypair yetset allow, roll every endpoint, then require
--set workers.mtls=off still behaves as allowthe 0.2.1 chart does not render off (see the warning below)the chart after 0.2.1; on 0.2.1, set OPODCP_WORKER_MTLS=off through extraEnv

Certificate posture: workers.mtls

ValueEffect
allow (default)a worker that presents a certificate this endpoint's CA signed is authenticated by it; one that does not falls back to its join token
offthe join token alone identifies a worker
requirea join or heartbeat without a certificate is refused, and a worker pod is rendered with no join token at all

With certificates on, the control plane mints a node CA per endpoint and one certificate per worker slot. The leader reads the worker's identity from the certificate. A certificate is valid at one leader only.

workers.mtls reaches the control plane as OPODCP_WORKER_MTLS. Change it with helm upgrade --set workers.mtls=require.

workers.mtls=off through the 0.2.1 chart

The 0.2.1 chart renders OPODCP_WORKER_MTLS only when the value is not off, and the binary reads an unset variable as allow. So on 0.2.1, --set workers.mtls=off behaves as allow: set the variable yourself, extraEnv: [{ name: OPODCP_WORKER_MTLS, value: "off" }]. The chart after 0.2.1 renders every value, off included.

What the control plane mints

ItemWhereDetails
Node CAthe endpoint's auth Secret (opodcp-ep-…-auth), items node-ca.crt and node-ca.keyECDSA P-256, valid 5 years, one per endpoint. Its public half goes to the leader in the auth snapshot
Worker certificatethe same Secret, items node-<node id>.crt and .keyECDSA P-256, client authentication only, valid for endpoints.tls.certDays (default 3650 days). Exactly one identity: the URI SAN spiffe://<cell>.opod/opod/node/<node id>. No DNS name
Node idthe worker pod's OPOD_NODE_IDn_<short endpoint id>_<worker index>_<node>, stable across restarts and unique in the endpoint

The worker pod mounts its keypair at /etc/opod-node/tls.crt and tls.key (OPOD_NODE_CERT, OPOD_NODE_KEY). Both mounts are optional, so a pod whose Secret has no keypair starts as before. The pod template carries the certificate's serial in the annotation opod.io/node-cert-serial, so a re-minted certificate is a template change and the next rollout rolls the pod onto it.

The CA is per endpoint, not per cell. A cell CA would make every worker certificate valid at every leader, and revoking one endpoint's CA would touch the others.

The first apply of an endpoint mints the CA and the certificates before it renders the pods. An endpoint created before certificates were on gets them at its next rollout.

What a certificate does that a shared token cannot:

  • it names the worker, so one worker cannot register as another;
  • it can be revoked, and the revocation lands while the pod still runs;
  • a worker joins with no shared secret at all.

Revoke a worker

curl -s -H "$H" https://cp.example.com/api/v1/endpoints/<id>/worker-identities
{
  "mtls": "allow",
  "identities": [
    { "nodeId": "n_3f9a1c_0_node-a", "node": "node-a", "worker": 0, "revoked": [] }
  ]
}

A worker row with replicas holds no identity and is not listed: it joins by its token. revoked lists every serial the endpoint's leader refuses.

curl -s -H "$H" -X POST https://cp.example.com/api/v1/endpoints/<id>/worker-identities/n_3f9a1c_0_node-a/revoke

Revoking is an operator action, like revoking a key: it stops one worker and starts nothing. What happens:

  1. The control plane mints a new certificate for the slot into the Secret and records the old serial against the endpoint.
  2. It pushes the auth snapshot to the leader at once. From then on the leader refuses the old serial, so the running worker can no longer heartbeat, while its pod is still up.
  3. The event endpoint.worker-identity-revoked records the node, the revoked and new serials, and who did it.
  4. The next rollout rolls the pod onto the new certificate. Until then, that worker is out of service.

A node id that is not in the plan, or an install with workers.mtls=off, is 400 invalid with the reason.

The limit

Every replica of one worker row shares one pod template, and so one certificate; a gang's LeaderWorkerSet has one template per role. Under allow such a slot simply joins by its token and holds no certificate. Under require it is refused by name rather than issued:

  • E-MTLS-REPLICAS — a worker row with more than one replica. Use one worker row per node.
  • E-MTLS-GANG — an active gang. Use allow, or single workers.

Moving to require

The mode reaches a leader at once through the auth snapshot, but a worker only gets its keypair when its pod template rolls. An install that ran on off must set allow and roll every endpoint first; require before those rollouts would strand every worker that has not moved. An upgrade from a release whose default was off rolls each endpoint's workers once onto their keypair, through the normal template-drift path.

The join token and HMAC

The join token is item join-token of the endpoint's auth Secret, opodcp-ep-<name>-<id suffix>-auth, and reaches each worker pod as OPOD_JOIN_TOKEN from a Secret reference. It is per endpoint: a worker of one endpoint cannot join another. Under workers.mtls=require the worker pod gets no join token at all. The leader signs every command it sends a worker with a per-node HMAC secret. The control plane itself never calls a worker's API.

HMAC only on a worker's API

workers.rejectBearer=true makes a worker's API accept HMAC-signed calls only. Leave it false unless your worker images are recent enough to load their model in-process; an older worker image's entrypoint loads its model over the bearer path and would never serve. It reaches a running worker only through a rollout.

Last updated · Source: content/docs/control-plane-security/worker-identity.mdx · View as Markdown