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
Before Service A API key in Secret leaked, copied, never rotated With SPIFFE Service A SVID (short TTL) rotated automatically identity = what you can prove, not where you sit (IP, network)

2.The Pieces

SPIFFE is the spec. SPIRE is the main implementation of it. Do not mix them up. Both are CNCF graduated.

SPIFFEthe spec, no tagged release
SPIREimplementation, v1.15.5
  • 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
Key Terms
  • 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 /ns/<ns>/sa/<sa> is a Kubernetes convention, not required.

spiffe:// prod.example.org /ns/payments/sa/api scheme trust domain path whole ID X.509-SVIDsingle URI SAN JWT-SVIDsub claim verify with bundle
X.509-SVIDJWT-SVIDWIT-SVID
FormatCertificateSigned tokenJWS compact, WIMSE
ID inURI SANsubsub
ReplayLow, proves keyBearer, until expLow, key proof
Best formTLSL7 hops, proxiesWIMSE use cases
Stable ?YesYesIncubating
CheckChain to bundleAudience + expPossession proof
Name vs DocumentThe SPIFFE ID is only a name. The SVID is the signed document that carries it, and the trust bundle is what a peer checks it against.
ID = who, SVID = proof, bundle = whom to trust
In short : SPIFFE gives every workload a name (SPIFFE ID) and a short-lived, auto-rotated ID card (SVID). SPIRE is the implementation.

1.Getting an Identity

The Pod never holds a secret to ask for its identity. The platform vouches for it.

Workload API flow
PodCalls FetchX509SVID, sends no credentials.
Workload API socketUnix domain socket.
Agent (e.g. SPIRE)Identifies the caller out of band (PID, cgroup, kubelet info).
Control plane / CAMatches registered identities, signs SVID.

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 PKI
  • https_spiffe : authenticated with an SVID
  • Refresh on spiffe_refresh_hint, the producer's interval in seconds (5 min if it is absent, and SPIRE's default)
  • Short TTL means few revocation lists
CarefulNever merge bundles from different trust domains.
Trust domain A own keys, own root Workload A verify B with bundle B Bundle Aendpoint Trust domain B own keys, own root Workload B verify A with bundle A Bundle Bendpoint mTLS X.509-SVIDs swap bundles

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_ENDPOINT_SOCKET.

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
Node spire-agent socket dir spiffe-csi shared hostPath (agent + CSI) mounts Pod /spiffe-workload-api spire-agent.sock SPIFFE_ENDPOINT_SOCKET read-only socket, no Secret mounted
In short : The Pod asks the local Workload API for its SVID with no credentials, peers verify X.509-SVIDs with trust bundles, and spiffe-csi mounts the socket so the Pod needs no hostPath.

1.Who is Who

SPIFFE is the spec. Other tools implement it, reuse its IDs, or get replaced by it.

ThingIssues SVIDs ?Attests ?
SPIREYesYes, node + workload
Istio / ConsulYes, own CAPartial (SA / ACL token)
cert-managerSPIFFE-style certsNo, policy only
Pod CertificatesIf its signer puts the ID inAPI server checks node, Pod, SA
SA tokenNo, K8s API JWTNo
Static secretNoNo, holder wins
SPIFFEID, SVID, API SPIREimplements Istio / Consuluse SPIFFE IDs cert-managerno attestation Static secretwhat it replaces SPIFFE-style replaces

2.Commands

CommandDescriptionExample
kubectl apply -f csidriver.yamlRegister the spiffe-csi driverkubectl get csidriver csi.spiffe.io
kubectl exec <pod> -- ls /spiffe-workload-apiCheck the socket is mountedshows spire-agent.sock
kubectl exec <pod> -- env | grep SPIFFELibraries find the socket hereSPIFFE_ENDPOINT_SOCKET=unix:///...
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 -textInspect the URI SANURI:spiffe://prod.example.org/ns/payments/sa/api
kubectl logs -n <ns> ds/spiffe-csi-driverDebug mount failures (name depends on install)add -c spiffe-csi-driver
Debug order
CSIDriverregistered ?
Socketmounted ?
Envvar set ?
FetchSVID back ?
URI SANright ID ?
stop at the
first ? that fails

3.Gotchas

The model
  • 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
In the cluster
  • 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
In short : Debug from the socket outward (driver, mount, env, fetch, URI SAN). SPIFFE is identity, not authorization, and needs an implementation such as SPIRE.