Skip to content
Workload and AI agent identity · Chapter 7 of 20 Day 6: Registration and SVIDs – personnel file, staff badge and gate pass

Day 6: Registration and SVIDs – personnel file, staff badge and gate pass

Goal: Create registration entries, have the first SVIDs issued, and read and verify both forms – X.509 and JWT · Duration: about 90 min · Prerequisite: Day 5 completed

Where we start

# on id1
sudo -u spire /opt/spire/bin/spire-server agent list -socketPath /run/spire-server/api.sock

Expected: Found 2 attested agents:.

# on id1
kubectl get pods -n laden

Expected (excerpt): the pods werkstatt (on id2) and werkstatt-id1 (on id1), both Running.

# on id1
kubectl logs -n laden werkstatt --tail=1

Expected:

rpc error: code = PermissionDenied desc = no identity issued

Introduction

Yesterday the gatekeeper took a close look at the workshop and noted a list of attributes – and still did not give it a badge. The personnel file was missing: a rule that says which attributes belong to which staff number. You create it today.

After that, the workshop gets its staff badge in two forms. The X.509-SVID is a certificate with a private key; a service uses it to identify itself in a TLS connection. The JWT-SVID is a short gate pass for exactly one audience; you send it along where TLS does not get through, for example through a proxy. You verify both without asking SPIRE, using only the bundle – as on Day 3.

Today you will learn:

  • what a registration entry is and what the parent entry is for,
  • how to create a node alias so that an entry applies to all agents of the cluster,
  • how to fetch an X.509-SVID, unpack it and verify it against the bundle,
  • how to fetch a JWT-SVID and verify it with the trust domain’s JWKS,
  • why two pods with the same ServiceAccount get the same identity,
  • how an entry with a misspelled selector fails – without SPIRE warning you.

Background

The picture for today: personnel file, chip badge and gate pass

The HR department keeps a personnel file for every position. It does not name a person; it holds a description: “Whoever works in the laden department and has the werkstatt employment contract gets the staff number laden/werkstatt.” And: “This file applies on all floors of the labor building.”

When someone comes to the gatekeeper, the gatekeeper compares their observations with all files that apply to their floor. If one matches, they hand out the badge. If two match, they hand out two.

The staff badge comes in two forms:

  • The chip card (X.509-SVID): the chip holds a secret key. Whoever shows the card proves with the chip that it belongs to them. Valid for one hour.
  • The gate pass (JWT-SVID): a stamped slip “Valid for the lager door”, valid for five minutes. No chip – whoever holds it gets through. That is why it is so short.

The terms

Term Meaning in the picture
Registration entry Rule: these selectors result in this SPIFFE ID personnel file
Parent ID (parentID) whose agents may hand out the entry which floors the file applies to
Node entry (-node) entry that gives agents themselves an additional ID – here as an alias for all agents of the cluster “all gatekeepers in the labor building”
X.509-SVID certificate with the SPIFFE ID as URI SAN plus private key chip card
JWT-SVID signed JWT with sub = SPIFFE ID and one audience gate pass for one door
Bundle (X.509) CA certificates for verifying X.509-SVIDs specimen card for cards
Bundle (JWKS) public keys for verifying JWT-SVIDs specimen card for gate passes

Remember: A registration entry describes attributes, not people. Anyone who has the attributes gets the staff number.

Drill 1: The first personnel file

Where you are: on id1.

What you have afterwards: a node alias for the cluster labor, an entry for the workshop and a workshop that has received its staff badge.

Step 1 – working folder.

# on id1
mkdir -p ~/kurs/06

Step 2 – “all gatekeepers in the labor building”. A workload entry needs a parent ID: only agents with this ID hand it out. You could use the ID of a single agent, but then the entry would apply on only one node, and after the node is reinstalled not at all. A better choice is an alias that matches every agent of the cluster:

# on id1
sudo -u spire /opt/spire/bin/spire-server entry create -node -spiffeID spiffe://gebaeude.test/knoten/labor -selector k8s_psat:cluster:labor -socketPath /run/spire-server/api.sock
Option Value Meaning
-node entry for agents, not for programs
-spiffeID spiffe://gebaeude.test/knoten/labor the additional ID every matching agent gets
-selector k8s_psat:cluster:labor matches every agent that came in via k8s_psat from the cluster labor

Expected:

Entry ID                : 49211066-0d8e-4cdc-bc47-d0a77a018b8b
SPIFFE ID               : spiffe://gebaeude.test/knoten/labor
Parent ID               : spiffe://gebaeude.test/spire/server
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s_psat:cluster:labor

What you see: The parent ID of a node entry is the server itself. An agent’s selectors come from node attestation: k8s_psat provides, among other things, the cluster name.

Step 3 – the workshop’s file.

# on id1
sudo -u spire /opt/spire/bin/spire-server entry create -parentID spiffe://gebaeude.test/knoten/labor -spiffeID spiffe://gebaeude.test/laden/werkstatt -selector k8s:ns:laden -selector k8s:sa:werkstatt -socketPath /run/spire-server/api.sock
Option Value Meaning
-parentID the alias from step 2 every agent in the cluster labor may hand out this badge
-spiffeID spiffe://gebaeude.test/laden/werkstatt the staff number
-selector (twice) k8s:ns:laden, k8s:sa:werkstatt both must match

Expected:

Entry ID                : f95f5c2a-2a3f-415b-ab78-8a117a57bd2e
SPIFFE ID               : spiffe://gebaeude.test/laden/werkstatt
Parent ID               : spiffe://gebaeude.test/knoten/labor
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:ns:laden
Selector                : k8s:sa:werkstatt

You write the selectors exactly the way the gatekeeper wrote them to the log yesterday: type k8s, value ns:laden and sa:werkstatt respectively.

Step 4 – the files at a glance.

# on id1
sudo -u spire /opt/spire/bin/spire-server entry show -socketPath /run/spire-server/api.sock

Expected: Found 2 entries and the two entries from steps 2 and 3.

Step 5 – has the workshop noticed? Since yesterday it has kept asking with api watch. The agent syncs its files with the server every few seconds:

# on id1
kubectl logs -n laden werkstatt --tail=12

Repeat the command until Received appears.

Expected (excerpt – the time after after depends on how long the workshop has been waiting):

rpc error: code = PermissionDenied desc = no identity issued
Received 1 svid after 5m25.649481968s

SPIFFE ID:      spiffe://gebaeude.test/laden/werkstatt
SVID Valid After:   2026-12-01 11:03:46 +0000 UTC
SVID Valid Until:   2026-12-01 12:03:56 +0000 UTC
CA #1 Valid After:  2026-12-01 10:56:49 +0000 UTC
CA #1 Valid Until:  2026-12-02 10:56:59 +0000 UTC
Line Meaning
SPIFFE ID the staff number from the file
SVID Valid After/Until one hour plus ten seconds of lead time (default_x509_svid_ttl)
CA #1 the HR department’s CA from Day 5, valid until tomorrow

What you see: The workshop has its first staff badge. It did not present anything for it, no password, no token – it only asked, and the gatekeeper recognized it.

Remember: The pod brings nothing along, and still it gets a badge: the gatekeeper recognizes it, and the file says which number it is entitled to.

Save your progress? Sign up for free

Drill 2: The chip card – X.509-SVID

Where you are: on id1.

What you have afterwards: the workshop’s certificate as a file, read and verified against the bundle.

Step 1 – fetch it once. api fetch x509 fetches the SVID and exits:

# on id1
kubectl exec -n laden werkstatt -- /opt/spire/bin/spire-agent api fetch x509 -socketPath /run/spire/sockets/agent.sock

Expected:

Received 1 svid after 38.50789ms

SPIFFE ID:      spiffe://gebaeude.test/laden/werkstatt
SVID Valid After:   2026-12-01 11:03:46 +0000 UTC
SVID Valid Until:   2026-12-01 12:03:56 +0000 UTC
CA #1 Valid After:  2026-12-01 10:56:49 +0000 UTC
CA #1 Valid Until:  2026-12-02 10:56:59 +0000 UTC

This time 38 milliseconds: the agent already had the badge ready in memory.

Step 2 – out as JSON. The image has no shell and no cat; so you have the SVID printed as JSON and catch it on id1:

# on id1
kubectl exec -n laden werkstatt -- /opt/spire/bin/spire-agent api fetch x509 -socketPath /run/spire/sockets/agent.sock -output json > ~/kurs/06/werkstatt-x509.json
# on id1
jq '.svids[0] | keys' ~/kurs/06/werkstatt-x509.json

Expected:

[
  "bundle",
  "hint",
  "spiffe_id",
  "x509_svid",
  "x509_svid_key"
]

What you see: x509_svid_key – the private key, the card’s chip. In the workshop it lives only in memory. Now it sits in a file on id1. For the exercise you only need the certificate; as soon as you have extracted it, the file goes away.

Step 3 – extract the certificate.

# on id1
jq -r '.svids[0].x509_svid' ~/kurs/06/werkstatt-x509.json > ~/kurs/06/werkstatt.b64
# on id1
base64 -d ~/kurs/06/werkstatt.b64 > ~/kurs/06/werkstatt.der
# on id1
rm ~/kurs/06/werkstatt-x509.json

In the JSON the certificate is stored as Base64-encoded DER, the binary format of X.509. base64 -d turns it into the binary file.

Step 4 – read it.

# on id1
step certificate inspect ~/kurs/06/werkstatt.der

Expected (excerpt):

        Issuer: C=US,O=SPIFFE,SERIALNUMBER=334354091552211381909400678287410649314
        Validity
            Not Before: Dec 1 11:03:46 2026 UTC
            Not After : Dec 1 12:03:56 2026 UTC
        Subject: C=US,O=SPIRE
        Subject Public Key Info:
            Public Key Algorithm: ECDSA
                Public-Key: (256 bit)
                Curve: P-256
        X509v3 extensions:
            X509v3 Key Usage: critical
                Digital Signature, Key Encipherment, Key Agreement
            X509v3 Extended Key Usage:
                Server Authentication, Client Authentication
            X509v3 Basic Constraints: critical
                CA:FALSE
            X509v3 Subject Alternative Name:
                URI:spiffe://gebaeude.test/laden/werkstatt
Field Value Meaning
Issuer O=SPIFFE, serial number the SPIRE server’s CA (you know its serial number from the bundle)
Subject C=US,O=SPIRE meaningless; the identity is not here
Subject Alternative Name URI:spiffe://…/laden/werkstatt this is where the identity is
Extended Key Usage server and client the same card works for both sides of a TLS connection
CA:FALSE this card cannot be used to issue further cards

What you see: A perfectly normal TLS certificate. Every program that speaks TLS can handle it – that is the trick of SPIFFE. Only the name sits in an unusual place: as a URI in the SAN, not in the Subject.

Step 5 – verify against the specimen card. step certificate verify wants the text format PEM:

# on id1
step certificate format ~/kurs/06/werkstatt.der > ~/kurs/06/werkstatt.crt
# on id1
head -2 ~/kurs/06/werkstatt.crt

Expected:

-----BEGIN CERTIFICATE-----
MIICITCCAcagAwIBAgIRAN6b/t85R+mWVVBhPcOVpPcwCgYIKoZIzj0EAwIwUDEL
# on id1
step certificate verify ~/kurs/06/werkstatt.crt --roots ~/kurs/05/bundle.crt

Expected: no output. No message means here: valid.

And against the wrong specimen card – the cluster’s CA:

# on id1
step certificate verify ~/kurs/06/werkstatt.crt --roots ~/cluster-ca.crt

Expected:

failed to verify certificate: x509: certificate signed by unknown authority

Remember: An X.509-SVID is a normal certificate with the SPIFFE ID in the SAN. Anyone who has the trust domain’s bundle can verify it – no more and no less.

Save your progress? Sign up for free

Drill 3: The gate pass – JWT-SVID

Where you are: on id1.

What you have afterwards: a gate pass of the workshop for the lager door, verified offline with the trust domain’s JWKS.

Step 1 – order a gate pass. Unlike the card, a gate pass is always issued for a specific door:

# on id1
kubectl exec -n laden werkstatt -- /opt/spire/bin/spire-agent api fetch jwt -audience lager -socketPath /run/spire/sockets/agent.sock -output json > ~/kurs/06/werkstatt-jwt.json
  • -audience lager – the audience; mandatory for JWT-SVIDs,
  • -output json – token and bundle as JSON instead of text.
# on id1
jq -r '.[0].svids[0].svid' ~/kurs/06/werkstatt-jwt.json > ~/kurs/06/werkstatt.jwt

Step 2 – read it.

# on id1
step crypto jwt inspect --insecure < ~/kurs/06/werkstatt.jwt

Expected:

{
  "header": {
    "alg": "ES256",
    "kid": "cekS4loWO9C1NoD4PUhYoGmXFYxB0BW3",
    "typ": "JWT"
  },
  "payload": {
    "aud": [
      "lager"
    ],
    "exp": 1796123441,
    "iat": 1796123141,
    "sub": "spiffe://gebaeude.test/laden/werkstatt"
  },
  "signature": "95PT7xnjpYomQCSEHuZBnj9pXV20NdaVzdB7CN2IGCk8J9eb30M02IVHhF92VgC6E6bGgOTDWxxZkYj4ehd1LA"
}

What you see: Compare it with a building badge from Day 2. Shorter, sub is the SPIFFE ID, exp - iat = 300 seconds. You know the kid from the server log of Day 5 (JWT key activated … local_authority_id=cekS4loW…). And something is missing: iss. A JWT-SVID names no issuer; the trust domain is contained in sub.

Step 3 – the specimen card for gate passes. The bundle is also available in SPIFFE format, a JWKS with both kinds of keys:

# on id1
sudo -u spire /opt/spire/bin/spire-server bundle show -format spiffe -socketPath /run/spire-server/api.sock > ~/kurs/06/bundle.jwks
# on id1
jq '.keys[] | {use, kty, kid}' ~/kurs/06/bundle.jwks

Expected:

{
  "use": "x509-svid",
  "kty": "EC",
  "kid": null
}
{
  "use": "jwt-svid",
  "kty": "EC",
  "kid": "cekS4loWO9C1NoD4PUhYoGmXFYxB0BW3"
}

What you see: One key for cards (the CA, without kid), one for gate passes – with the kid from the token.

Step 4 – verify offline. As on Day 3, but otherwise step demands an issuer:

# on id1
step crypto jwt verify --jwks ~/kurs/06/bundle.jwks --aud lager < ~/kurs/06/werkstatt.jwt

Expected:

flag '--iss' is required unless the '--subtle' flag is provided
# on id1
step crypto jwt verify --jwks ~/kurs/06/bundle.jwks --aud lager --subtle < ~/kurs/06/werkstatt.jwt
  • --subtle – allow checks that step otherwise considers incomplete, here: without iss.

Expected: the token as in step 2 – signature, audience and time match.

If you run this check more than five minutes after step 1, the gate pass has expired. Fetch a new one in that case.

Step 5 – wrong door, wrong specimen card.

# on id1
step crypto jwt verify --jwks ~/kurs/06/bundle.jwks --aud kasse --subtle < ~/kurs/06/werkstatt.jwt

Expected:

validation failed: invalid audience claim (aud)
# on id1
step crypto jwt verify --jwks ~/kurs/03/jwks.json --aud lager --subtle < ~/kurs/06/werkstatt.jwt

Expected:

cannot find key with kid cekS4loWO9C1NoD4PUhYoGmXFYxB0BW3 on /home/ubuntu/kurs/03/jwks.json

What you see: The cluster’s specimen card does not know the HR department’s stamp. Two issuers, two specimen cards.

Remember: A JWT-SVID is a gate pass for exactly one door and five minutes. It has no chip: whoever intercepts it can use it. So use the card (X.509) where possible, the gate pass only where necessary.

Save your progress? Sign up for free

Drill 4: Same contract, same badge

Where you are: on id1.

What you have afterwards: proof that the identity is tied to the ServiceAccount, not to the pod.

The second workshop from the Day 5 challenge runs on id1, with the same ServiceAccount.

# on id1
kubectl logs -n laden werkstatt-id1 --tail=7

Expected:

SPIFFE ID:      spiffe://gebaeude.test/laden/werkstatt
SVID Valid After:   2026-12-01 11:03:45 +0000 UTC
SVID Valid Until:   2026-12-01 12:03:55 +0000 UTC
CA #1 Valid After:  2026-12-01 10:56:49 +0000 UTC
CA #1 Valid Until:  2026-12-02 10:56:59 +0000 UTC

What you see: The same SPIFFE ID, issued one second earlier, by the agent on id1. It received the entry as well, because it belongs to the alias knoten/labor. To every verifier, the workshop on id1 and the one on id2 are the same person.

# on id1
kubectl logs -n spire daemonset/spire-agent --since=10m

Expected (excerpt – look for Creating X509-SVID):

time="2026-12-01T11:03:55Z" level=debug msg="Entry created" entry=f95f5c2a-2a3f-415b-ab78-8a117a57bd2e selectors_added=2 spiffe_id="spiffe://gebaeude.test/laden/werkstatt" subsystem_name=cache_manager
time="2026-12-01T11:03:55Z" level=info msg="Creating X509-SVID" entry_id=f95f5c2a-2a3f-415b-ab78-8a117a57bd2e spiffe_id="spiffe://gebaeude.test/laden/werkstatt" subsystem_name=manager

What you see: The agent created the badge as soon as the entry reached it – even before the workshop asked the next time.

Remember: Whoever has the contract gets the number. If you want to tell two pods apart, give them different ServiceAccounts – or add an attribute that distinguishes them.

Save your progress? Sign up for free

Diagnosis task

A colleague sets up everything for a new application inventur: ServiceAccount inventur, a pod modeled on the workshop on id1, and a personnel file:

# on id1
sudo -u spire /opt/spire/bin/spire-server entry show -spiffeID spiffe://gebaeude.test/laden/inventur -socketPath /run/spire-server/api.sock

Expected:

Found 1 entry
Entry ID                : 5473a239-6422-4b43-904a-3ce32b26e550
SPIFFE ID               : spiffe://gebaeude.test/laden/inventur
Parent ID               : spiffe://gebaeude.test/knoten/labor
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:ns:laden
Selector                : k8s:serviceaccount:inventur

Even after minutes the pod gets no badge:

# on id1
kubectl exec -n laden inventur -- /opt/spire/bin/spire-agent api fetch x509 -socketPath /run/spire/sockets/agent.sock

Expected:

rpc error: code = PermissionDenied desc = no identity issued
command terminated with exit code 1

What is wrong?

Solution path:

  1. “no identity issued” means: the gatekeeper recognized the pod but found no matching file. So compare what it observes with what the file requires. The pod runs on id1, so check the log of the agent there (name from kubectl get pods -n spire -o wide):

    # on id1
    kubectl logs -n spire spire-agent-5c4sd --since=1m

    Expected (excerpt – start of the selector list):

    level=debug msg="PID attested to have selectors" pid=139081 selectors="[type:\"k8s\" value:\"sa:inventur\" type:\"k8s\" value:\"ns:laden\" type:\"k8s\" value:\"node-name:id1\" …
  2. The gatekeeper writes sa:inventur. The file requires serviceaccount:inventur. The key serviceaccount does not exist in the k8s plugin, so the file matches nobody. SPIRE still created the entry without a warning – the server does not check whether a selector is ever produced.

  3. Solution: Correct the entry. entry update needs all options, not only the changed one:

    # on id1
    sudo -u spire /opt/spire/bin/spire-server entry update -entryID 5473a239-6422-4b43-904a-3ce32b26e550 -parentID spiffe://gebaeude.test/knoten/labor -spiffeID spiffe://gebaeude.test/laden/inventur -selector k8s:ns:laden -selector k8s:sa:inventur -socketPath /run/spire-server/api.sock

    Expected (excerpt):

    Revision                : 1
    Selector                : k8s:ns:laden
    Selector                : k8s:sa:inventur
  4. After a few seconds, the command from the beginning returns Received 1 svid with spiffe://gebaeude.test/laden/inventur.

The lesson: selectors are strings. Do not write them from memory; copy them from the agent’s DEBUG log.

Challenge

The workshop on id1 should additionally get its own identity spiffe://gebaeude.test/laden/werkstatt/id1, the workshop on id2 should not. Create the entry and find out what the workshop on id1 gets afterwards. Write down the command before you read the solution.

Solution: A third selector narrows it down to the node:

# on id1
sudo -u spire /opt/spire/bin/spire-server entry create -parentID spiffe://gebaeude.test/knoten/labor -spiffeID spiffe://gebaeude.test/laden/werkstatt/id1 -selector k8s:ns:laden -selector k8s:sa:werkstatt -selector k8s:node-name:id1 -socketPath /run/spire-server/api.sock

Expected (excerpt – note the Entry ID):

Entry ID                : dd2af677-5844-4fe9-a150-e2354f3424da
SPIFFE ID               : spiffe://gebaeude.test/laden/werkstatt/id1
# on id1
kubectl exec -n laden werkstatt-id1 -- /opt/spire/bin/spire-agent api fetch x509 -socketPath /run/spire/sockets/agent.sock

Expected:

Received 2 svids after 36.112341ms

SPIFFE ID:      spiffe://gebaeude.test/laden/werkstatt/id1
SVID Valid After:   2026-12-01 11:07:30 +0000 UTC
SVID Valid Until:   2026-12-01 12:07:40 +0000 UTC
CA #1 Valid After:  2026-12-01 10:56:49 +0000 UTC
CA #1 Valid Until:  2026-12-02 10:56:59 +0000 UTC

SPIFFE ID:      spiffe://gebaeude.test/laden/werkstatt
SVID Valid After:   2026-12-01 11:03:45 +0000 UTC
SVID Valid Until:   2026-12-01 12:03:55 +0000 UTC
CA #1 Valid After:  2026-12-01 10:56:49 +0000 UTC
CA #1 Valid Until:  2026-12-02 10:56:59 +0000 UTC

The workshop on id2 still gets only one badge (Received 1 svid). Two files match, so there are two badges – SPIRE does not choose. Which one a program uses is up to the program. That is rarely what you want; so you remove the entry again before Day 7:

# on id1
sudo -u spire /opt/spire/bin/spire-server entry delete -entryID dd2af677-5844-4fe9-a150-e2354f3424da -socketPath /run/spire-server/api.sock

Expected:

Deleted entry with ID: dd2af677-5844-4fe9-a150-e2354f3424da


Deleted 1 entries successfully

Save your progress? Sign up for free

Checkpoint

# on id1
sudo -u spire /opt/spire/bin/spire-server entry count -socketPath /run/spire-server/api.sock

Expected:

3 registration entries
# on id1
kubectl exec -n laden werkstatt -- /opt/spire/bin/spire-agent api fetch x509 -socketPath /run/spire/sockets/agent.sock

Expected: Received 1 svid with SPIFFE ID: spiffe://gebaeude.test/laden/werkstatt.

Test yourself

  1. Why is the workshop’s entry tied to the alias knoten/labor and not to the SPIFFE ID of an agent?
  2. Where is the SPIFFE ID in an X.509-SVID – and where is it not?
  3. What distinguishes a JWT-SVID from a ServiceAccount token from Day 2?
  4. You want to prove the workshop’s identity to a service that does not speak TLS. Card or gate pass, and why with misgivings?
  5. An entry has the selectors k8s:ns:laden and k8s:sa:werkstatt. Which pods get the identity?
  6. SPIRE accepts an entry with the selector k8s:serviceaccount:inventur without an error. Why is that more dangerous than it looks?

Answers:

  1. An entry with an agent’s ID would apply only on that agent’s node, and the ID is tied to the node UID. If the node is reinstalled, the entry is orphaned. The alias matches every agent from the cluster labor, including future ones.
  2. In the Subject Alternative Name as a URI. The Subject (C=US,O=SPIRE) says nothing about the identity.
  3. It has no iss; the trust domain is contained in sub (spiffe://gebaeude.test/…). It is signed with the SPIRE server’s JWT key (ES256), not with the cluster’s, and here it is valid for five minutes. And: the kubelet puts the building badge in place, while the program fetches the gate pass itself.
  4. Gate pass (JWT-SVID), because the card can prove its chip only in a TLS connection. Misgivings, because a gate pass is a bearer token – whoever intercepts it can use it until it expires. Hence a short lifetime and exactly one audience.
  5. Every pod in the namespace laden with the ServiceAccount werkstatt, on every node of the cluster labor – no matter how many there are.
  6. Because SPIRE does not check selectors, nobody notices a typo. Here it stands out because the entry matches nobody. The reverse case is the dangerous one: whoever drops a selector entirely while correcting and leaves only k8s:ns:laden gives the identity to every pod in the namespace – and SPIRE accepts that without a warning too. So always check entries against the agent log.

Interview note

“What is a registration entry in SPIRE?” – Good answer: A rule made of SPIFFE ID, parent ID and selectors. The parent ID determines which agents may hand out the entry; a node alias instead of individual agent IDs is common. The selectors describe attributes the agent determines during workload attestation, such as k8s:ns, k8s:sa, an image digest. All of them must match. The SVID comes as X.509 with the ID in the URI SAN – for mTLS – or as a JWT with exactly one audience and a short lifetime. If they dig deeper: in Kubernetes you usually do not create entries by hand; you let the SPIRE Controller Manager generate them from ClusterSPIFFEID resources.

Enterprise note

Entries by hand fit the lab, not a cluster with a hundred applications. The SPIRE Controller Manager runs in the cluster and creates entries from Kubernetes resources (ClusterSPIFFEID with a template like spiffe://{{ .TrustDomain }}/ns/{{ .PodMeta.Namespace }}/sa/{{ .PodSpec.ServiceAccountName }}). That way identities are automatically tied to namespace and ServiceAccount, and nobody types selectors from memory.

For programs that do not speak the Workload API themselves there is the spiffe-helper: it fetches the SVID, writes certificate and key to files and renews them. Convenient, but then the key is on disk after all – in an emptyDir with medium: Memory at least only in memory. And instead of a hostPath socket, in production you use the SPIFFE CSI driver, which brings the socket into the pod without privileged volumes.

Summary

  • A registration entry links selectors to a SPIFFE ID; the parent ID determines which agents hand it out.
  • A node entry with k8s_psat:cluster:labor is an alias for all agents of the cluster.
  • The X.509-SVID is a normal certificate (EC P-256, 1 h) with the SPIFFE ID in the URI SAN; verifiable with the bundle, not with the cluster CA.
  • The JWT-SVID (ES256, 5 min) has sub = SPIFFE ID, one audience and no iss; verifiable with the bundle in SPIFFE format.
  • The same namespace and ServiceAccount result in the same identity on every node.
  • If two entries match, there are two SVIDs.
  • A misspelled selector is accepted without a warning and matches nobody.

Commands at a glance

Command What for
spire-server entry create -node -spiffeID <id> -selector k8s_psat:cluster:<name> node alias for all agents of a cluster
spire-server entry create -parentID <alias> -spiffeID <id> -selector k8s:ns:<ns> -selector k8s:sa:<sa> entry for a ServiceAccount
spire-server entry show [-spiffeID <id>] show entries
spire-server entry update -entryID <id> … change an entry (all options again)
spire-server entry delete -entryID <id> delete an entry
spire-server entry count count entries
spire-server bundle show -format spiffe bundle as JWKS with X.509 and JWT keys
spire-agent api fetch x509 -socketPath <sock> [-output json] fetch an X.509-SVID
spire-agent api fetch jwt -audience <aud> -socketPath <sock> JWT-SVID for one audience
base64 -d <datei> decode Base64
step certificate format <der> convert DER to PEM
step certificate verify <crt> --roots <bundle> verify a certificate against a CA
step crypto jwt verify --jwks <jwks> --aud <aud> --subtle verify a JWT without iss offline

Contents

More