Workload identity
SPIFFE
1.Why SPIFFE ?
SPIFFE is an open standard, not software. Every workload gets a name (SPIFFE ID) and a short-lived ID card (SVID). Services prove who they are without static secrets or IP addresses.
- Problem : how does service A know the caller is really service B ?
- IPs change and Pods are short-lived, so network identity breaks
- Static secrets (API keys, long-lived certs) leak and are rarely rotated
- Fix : one name format, one document format, one local API
- Zero trust : authenticate by cryptographic identity, not by network position
2.The Pieces
SPIFFE is the spec. SPIRE is the main implementation of it. Do not mix them up. Both are CNCF graduated.
- CSI driver : spiffe-csi v0.3.0 (the spire 0.30.4 chart still installs 0.2.7)
- Libraries : go-spiffe, java-spiffe, spiffe-helper
- SPIFFE IDThe name.
spiffe://<domain>/<path>, path meaning is up to the admin. - Trust domainIdentity boundary and root of trust. Lowercase, max 255 bytes, self-registered.
- SVIDThe document carrying the ID : X.509, JWT or WIT.
- Trust bundleJWKS of a domain's public keys.
- Workload APILocal gRPC API, Unix socket, no auth handshake.
3.Anatomy of an Identity
Scheme + trust domain + path = SPIFFE ID. No query, no fragment. Path / is a Kubernetes convention, not required.
| X.509-SVID | JWT-SVID | WIT-SVID | |
|---|---|---|---|
| Format | Certificate | Signed token | JWS compact, WIMSE |
| ID in | URI SAN | sub | sub |
| Replay | Low, proves key | Bearer, until exp | Low, key proof |
| Best for | mTLS | L7 hops, proxies | WIMSE use cases |
| Stable ? | Yes | Yes | Incubating |
| Check | Chain to bundle | Audience + exp | Possession proof |
1.Getting an Identity
The Pod never holds a secret to ask for its identity. The platform vouches for it.
Agent streams SVID + bundle back to the Pod and pushes again on rotation.
2.mTLS and Federation
Two workloads present X.509-SVIDs and check each other with the right trust bundle. Different trust domains swap bundles at a bundle endpoint.
https_web: Web PKIhttps_spiffe: authenticated with an SVID- Refresh on
spiffe_, the producer's interval in seconds (5 min if it is absent, and SPIRE's default)refresh_ hint - Short TTL means few revocation lists
3.In a Pod
The spiffe-csi driver (csi.spiffe.io) mounts the socket read-only, so the Pod needs no hostPath. Libraries find the socket through SPIFFE_.
volumeMounts:
- name: spiffe-workload-api
mountPath: /spiffe-workload-api
readOnly: true
env:
- name: SPIFFE_ENDPOINT_SOCKET
value: unix:///spiffe-workload-api/spire-agent.sock
volumes:
- name: spiffe-workload-api
csi:
driver: "csi.spiffe.io"
readOnly: true
1.Who is Who
SPIFFE is the spec. Other tools implement it, reuse its IDs, or get replaced by it.
| Thing | Issues SVIDs ? | Attests ? |
|---|---|---|
| SPIRE | Yes | Yes, node + workload |
| Istio / Consul | Yes, own CA | Partial (SA / ACL token) |
| cert-manager | SPIFFE-style certs | No, policy only |
| Pod Certificates | If its signer puts the ID in | API server checks node, Pod, SA |
| SA token | No, K8s API JWT | No |
| Static secret | No | No, holder wins |
2.Commands
| Command | Description | Example |
|---|---|---|
kubectl apply -f csidriver.yaml | Register the spiffe-csi driver | kubectl get csidriver csi.spiffe.io |
kubectl exec <pod> -- ls / | Check the socket is mounted | shows spire-agent.sock |
kubectl exec <pod> -- env | grep SPIFFE | Libraries find the socket here | SPIFFE_ |
spire-agent api fetch x509 -socketPath <sock> | Fetch an X.509-SVID like a workload (SPIRE CLI) | socket path from above |
openssl x509 -in svid.pem -noout -text | Inspect the URI SAN | URI:spiffe:// |
kubectl logs -n <ns> ds/ | Debug mount failures (name depends on install) | add -c spiffe-csi-driver |
first ? that fails
3.Gotchas
- SPIFFE is a spec, you install an implementation (SPIRE)
- SPIFFE has no CRDs. ClusterSPIFFEID comes from spire-controller-manager (check apiVersion first)
- SPIFFE ID is identity, not authorization. You still need policy
- Trust domains are lowercase and self-registered, so use one you own
- Write the trust domain in lowercase (the spec says MUST). Scheme and trust domain compare case-insensitively, the path case-sensitively
- Share the socket dir by hostPath between agent and CSI driver, or a driver restart breaks mounts
- The CSI driver itself needs a privileged namespace (hostPath). Pods that mount its volume still pass
restricted - Broken CSI driver means Pods fail to terminate fully
- JWT-SVIDs are bearer tokens : check audience, keep TTL short
- Clock skew or failed rotation shows up as sudden TLS errors