Skip to content
Tutorials Center
My learning

Topics

Lesson 16 of 36 ยท Security and mTLS

Workload Identity and Certificates

How Istio gives each workload a SPIFFE identity, issues short-lived X.509 certificates through SDS, rotates them, and lets you plug in your own root CA.

Encryption is only half of zero-trust. The other half is identity: knowing which workload is on the other end. IP addresses are useless for this because pods move and get new addresses constantly. Istio instead ties identity to the Kubernetes service account and proves it with a certificate.

Cluster commands are read-only. The Python stand-ins parse and check identities as text; they do not do real cryptography.

The SPIFFE identity

Istio names workloads using the SPIFFE standard (Secure Production Identity Framework For Everyone). An identity is a URI:

TEXT
spiffe://cluster.local/ns/shop/sa/catalog

Read it as: trust domain cluster.local, namespace shop, service account catalog. This string is placed in the certificate's Subject Alternative Name (SAN). Any workload running with the catalog service account in shop gets this identity, so use separate service accounts for separate roles; two services sharing the default account share an identity and cannot be told apart by policy.

The trust domain (default cluster.local) is the mesh's identity namespace. For multi-cluster or multi-mesh setups, give each mesh its own trust domain or federate them.

How a certificate is issued

sequenceDiagram
    participant A as pilot-agent (in pod)
    participant D as istiod CA
    participant K as Kubernetes API
    participant E as Envoy
    A->>A: create private key and CSR
    A->>D: CSR + service account JWT (over TLS)
    D->>K: validate the token
    D-->>A: signed certificate
    A->>E: deliver key + cert via SDS

The private key is generated inside the pod and never leaves it; only the signing request travels.

  1. At start-up pilot-agent generates a private key in memory and a certificate signing request (CSR).
  2. It authenticates to istiod with the pod's Kubernetes service account token.
  3. istiod verifies the token, then signs a certificate for the identity matching that account.
  4. The agent hands the key and certificate to Envoy over SDS, the secret discovery service, using a local socket.

Certificates are short-lived (24 hours by default). Before expiry, the agent repeats the process and Envoy swaps in the new certificate without dropping connections. Short lifetimes limit the damage of a stolen key, and automatic rotation means nobody manages certificates by hand.

Roots of trust

istiod acts as its own certificate authority (CA). By default it creates a self-signed root on first start and stores it as a Secret. For production you usually want a root that you control:

  • Plug in a CA: provide your own intermediate CA certificate and key in a Secret named cacerts, signed by your corporate root.
  • cert-manager istio-csr: delegate signing to cert-manager, which can use Vault or a cloud CA.
  • External CA: integrate with a service speaking the CSR APIs.

Using one shared root across clusters lets workloads in different clusters trust each other.

Looking at identities

On a real cluster you can inspect (read-only commands):

Terminal
istioctl proxy-config secret web-7d9c.shop
istioctl x describe pod web-7d9c -n shop

The first shows the workload certificate and the root, with validity dates. In an authorization policy, the identity appears as a principal: cluster.local/ns/shop/sa/web (no spiffe:// prefix). Policies on it are explained in Authorization Policies.

Stand-ins

Python Stand-in: parse a SPIFFE identity

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Python Stand-in: when does a certificate rotate?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Do not put several unrelated services under one service account for convenience. Policy cannot distinguish them, and a compromise of one is a compromise of all.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does the SPIFFE ID spiffe://cluster.local/ns/shop/sa/catalog identify?

    Istio's identity is built from trust domain, namespace and service account.
  2. 2. Where is the workload's private key generated?

    Only the CSR is sent to istiod; the key stays in the pod's memory.
  3. 3. Why are workload certificates short-lived?

    Short lifetimes plus rotation make credential theft much less valuable.
  4. 4. What is the risk of two services sharing one service account?

    Identity follows the service account; sharing it merges their privileges.

Summary

  • Istio identity is a SPIFFE URI built from trust domain, namespace and service account.
  • pilot-agent creates a key and CSR, istiod's CA signs it after validating the service account token.
  • Certificates last 24 hours by default and rotate through SDS without dropping connections.
  • Use your own root or cert-manager for production trust.
  • Give each role its own service account.

Next: Authorization Policies