Give a workload an API key

Give a workload an API key

Declare a Credential resource and the operator mints an API key into a Secret for your workload.

A Credential resource gives one workload its own API key for a Nova cluster that runs auth.mode: jwt. You declare the key's scope, the cluster mints the key, and the operator writes it to a Secret beside the resource. The workload loads the Secret as its environment, and every Nova client reads the key from NOVA_API_KEY. Nobody copies a secret by hand, and deleting the resource revokes the key.

Mint a key

The example keeps the workload in its own namespace, apps. Create it, and let the cluster trust it, before you start:

values.yaml, the cluster's auth
constellation:
  spec:
    auth: { mode: jwt, credentialNamespaces: [apps] }
kubectl create namespace apps
helm upgrade nova deploy/helm/nova --namespace nova --values values.yaml

Declare the credential

credential.yaml
apiVersion: nova.dev/v1alpha1
kind: Credential
metadata:
  name: orders
  namespace: apps
spec:
  constellation: { name: nova, namespace: nova }
  scope: "nova:append:demo:* nova:read:demo:*"
kubectl apply -f credential.yaml
kubectl -n apps get credentials
NAME     KEY                STATE
orders   900e1f14e3cbee6f   Active

KEY is the key's public id. The credential is named <namespace>/<name> inside Nova, here apps/orders. A Credential in another namespace than the cluster's needs that namespace listed in the cluster's auth.credentialNamespaces; the cluster's own namespace always may ask.

Load it in the workload

The operator writes the key to the Secret <name>-credential, under NOVA_API_KEY:

The workload's container
envFrom:
  - secretRef:
      name: orders-credential

The Go and TypeScript SDKs and the nova CLI trade the key for a short-lived token on their own. Through a port-forwarded Gateway:

NOVA_API_KEY=… nova --addr http://localhost:8422 read nova://demo/events --from 0
0	2026-11-22T19:24:08+01:00	hello
1	2026-11-22T19:24:08+01:00	world

The scope

The scope is a list of grants, each nova:<action>:<bucket>:<key>. A trailing * on the bucket or the key matches every name that starts with what comes before it. The actions are append, read, list, create, delete and trim. A scope can go as high as nova:admin, which is why each cluster lists the namespaces it trusts. Two scopes are refused for any workload: nova:node, the identity of the cluster's own nodes, and nova:gateway, the Gateway's.

A request outside the scope is refused. This key cannot list the bucket:

novactl: rpc error: code = PermissionDenied desc = dataplane: no grant covers list on bucket "demo"

Edit the scope and the key's grants change in place, under the same key id. After adding nova:list:demo:*, the same key lists the bucket:

ADDRESS             CLASS     PRODUCER
nova://demo/events  standard  any

Rotate and revoke

You doThe operator does
Delete the CredentialRevokes the key and deletes its Secret
Delete only the SecretMints a new key into a new Secret and revokes the old key
Edit scopeChanges the grants of the standing key

A revoked key fails at once:

novactl: http dataplane: credential: client: api-key exchange: rpc error: code = PermissionDenied desc = exchange: the credential is revoked

To rotate a key, delete the Secret. The workload must restart to read the new one.

When a Credential is refused

A Credential that can never be served shows Refused, and one that waits shows Pending. status.message says why:

kubectl get credentials -A
NAMESPACE   NAME     KEY                STATE
apps        orders   900e1f14e3cbee6f   Active
apps        peer                        Refused
other       stray                       Refused
MessageCauseWhat to do
constellation nova/nova does not list namespace other in auth.credentialNamespacesThe Credential's namespace is not trustedAdd the namespace to auth.credentialNamespaces, or move the Credential
scope: nova:node is peer identity, never a workload'sThe scope asks for a node's identityGrant the actions the workload needs instead
scope: malformed tokens [nova:list:demo]A grant does not follow nova:<action>:<bucket>:<key>Fix the grant; here nova:list:demo:*
constellation nova/nova does not authenticate (auth mode is not jwt): a credential would mean nothingThe cluster runs with auth offTurn on auth.mode: jwt
the Secret predates the single api key; delete the Credential to re-mintThe Secret holds the old NOVA_KEY_ID and NOVA_SECRET pairDelete the Credential and apply it again

Fixing the spec retries at once.

See also

On this page