Service-to-service security comes down to two ideas: encrypting traffic in transit and giving every workload a cryptographic identity, so it proves which service it is rather than which IP it happens to hold. mTLS delivers both at once, and service meshes let you roll it out without touching application code.

needsmake meshmake spire

Orientation

competency 5.1 · secure service-to-service communication

If your laptop complains about memory, run make mesh (a second cluster under context kind-mesh) and make spire (on the main cluster) one at a time; they don't depend on each other. Conceptually, though, they're two halves of the same question: how does a workload prove who it is cryptographically? Both derive that answer straight from its ServiceAccount.

Why identity beats network location

A NetworkPolicy says "traffic from pods carrying these labels may reach these pods". mTLS-based authorization says "only a caller presenting a valid certificate for this ServiceAccount may call this service". The second survives pod IP churn, works across cluster boundaries, and can't be spoofed just by scheduling a pod in the right namespace. That's the zero-trust argument in a nutshell, and it upgrades every ServiceAccount from section 5.1 into a network-level identity.

Istio ambient, how it fits together

ztunnel · HBONE · waypoints

The mesh cluster runs Istio in ambient mode, with zero sidecars. A per-node proxy called ztunnel (deployed as a DaemonSet) intercepts traffic for enrolled namespaces and tunnels it inside mTLS over HBONE (HTTP/2 CONNECT on port 15008), using per-workload certificates minted by istiod. Enrolling a namespace takes a single label (istio.io/dataplane-mode=ambient), and the lab pre-enrolls default on kind-mesh for you.

client pod ──plaintext──▶ ztunnel (node A) ══mTLS/HBONE══▶ ztunnel (node B) ──plaintext──▶ backend pod
                                 │                                │
                       identity: spiffe://cluster.local/ns/default/sa/client
                                                       L4 policy enforced here
                    ┌──────── optional waypoint proxy for L7 rules (paths, methods, headers) ────────┐

Those certificates carry SPIFFE IDs shaped like spiffe://cluster.local/ns/<namespace>/sa/<serviceaccount>. Notice what's baked right into that URI: the Kubernetes ServiceAccount is the workload's identity.

The two policy objects

KindDecidesKey fields
PeerAuthenticationAuthn: is mTLS required?mtls.mode: STRICT | PERMISSIVE | DISABLE, scoped mesh-wide (root namespace), per namespace, or per workload
AuthorizationPolicyAuthz: who can call what?action: ALLOW|DENY|AUDIT|CUSTOM, rules with from.source.principals (SPIFFE IDs) and to.operation (methods, paths; L7, needs a waypoint)
Permissive by default

Simply installing a service mesh does not mean every packet is encrypted. Istio defaults to PERMISSIVE, accepting both mTLS and plaintext so teams can onboard incrementally. To actually require mTLS, you have to apply STRICT and prove it by watching a plaintext client get refused (exercise 2 below).

L4 rules (which identity may connect at all) run directly in ztunnel. L7 rules (HTTP methods, paths, headers) require a waypoint proxy, ambient's opt-in L7 tier deployed per namespace or per service account. Sidecar mode is the older architecture: one Envoy container per pod, with richer per-pod controls and higher memory overhead. Both are Istio, so always confirm which mode a cluster runs before tracing its data path.

Istio, field by field

waypoints, PeerAuthentication scope, AuthorizationPolicy evaluation, verifying it

Ambient objects and labels

ThingWhat it does
istio.io/dataplane-mode=ambient (namespace or pod label)Enrolls workloads so ztunnel captures their traffic; set none on a pod to opt it out
Gateway with gatewayClassName: istio-waypointAn Envoy waypoint proxy for L7 rules, created via istioctl waypoint apply -n ns [--name x]; ready once Programmed=True
istio.io/waypoint-for on the GatewayDeclares which traffic the waypoint accepts: service (default), workload, all, or none
istio.io/use-waypoint=<name> on a namespace, Service, or podRoutes that scope's traffic through the waypoint (--enroll-namespace sets it automatically); a Service label overrides a namespace label
HBONE, port 15008The mTLS tunnel connecting ztunnels and waypoints; seeing PROTOCOL: HBONE in istioctl ztunnel-config workloads confirms capture

Keep in mind that use-waypoint only expresses routing intent: if the waypoint has no address or its waypoint-for doesn't match the traffic type, ztunnel sends traffic straight to the pod and bypasses your L7 policy. To guarantee traversal, add a ztunnel-enforced AuthorizationPolicy permitting only the waypoint's own identity (cluster.local/ns/<ns>/sa/<waypoint>) to reach the workload.

PeerAuthentication

Valid modes are UNSET (inherit), DISABLE, PERMISSIVE (the default when nothing is configured), and STRICT. Scope is determined by namespace and whether selector is set: in the root namespace (istio-system by default) with no selector, it's mesh-wide; in any other namespace with no selector, it covers that namespace; with a selector, it applies only to matching workloads (a selector in the root namespace is ignored). Most specific always wins. Use portLevelMtls (mapping container port numbers to modes; requires a selector) to carve out one legacy plaintext port under STRICT. Stick to at most one mesh-wide and one namespace-wide policy, since duplicates at the same scope trigger undefined behavior that Istio warns about.

AuthorizationPolicy

apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata: { name: orders-writers, namespace: shop }
spec:
  targetRefs:                       # waypoint enforcement (L7); use selector for ztunnel (L4)
    - kind: Service
      group: ""
      name: orders
  action: ALLOW
  rules:
    - from:
        - source:
            principals: ["cluster.local/ns/shop/sa/checkout"]
      to:
        - operation:
            methods: ["POST"]
            paths: ["/orders", "/orders/*"]
  • Evaluation order. Istio runs CUSTOM policies first (letting an external authorizer reject), then DENY (any match blocks immediately), and finally ALLOW. If no ALLOW policy targets a workload, everything not explicitly denied gets through; the moment even one ALLOW policy targets it, anything not matched by an ALLOW is rejected. An ALLOW policy with empty rules (allow-nothing) is the standard way to flip a namespace to deny-by-default before adding explicit allows. AUDIT logs matches without enforcing.
  • Where it runs. A policy using selector runs in ztunnel at L4 and can only check L4 fields (principals, namespaces, ipBlocks, ports). A policy using targetRefs pointing to a waypoint Gateway or Service attaches to the waypoint and unlocks L7 fields (methods, paths, hosts, request.headers, requestPrincipals). Crucially, putting an L7 field on a ztunnel-enforced policy isn't silently ignored: Istio fails safe and turns it into a DENY for matching traffic, which explains "everything started failing right after I added a paths clause".
  • Spotting which proxy denied you. An L4 denial resets the TCP connection outright: curl exits 56 (command terminated with exit code 56) with no HTTP status. An L7 denial from a waypoint or sidecar answers cleanly with 403 RBAC: access denied. That single clue tells you immediately which tier rejected the call.
  • Identity strings. principals omit the spiffe:// scheme: write cluster.local/ns/shop/sa/checkout (the trust domain comes from meshConfig.trustDomain). Use notPrincipals, notNamespaces, and notPaths for negations.
  • JWTs. RequestAuthentication (with jwtRules[].issuer and jwksUri or inline jwks) validates tokens and populates request.auth.principal (issuer/subject) and request.auth.claims. Watch the classic trap: it rejects invalid tokens, yet still lets requests with no token at all pass through. To require a token, pair it with an AuthorizationPolicy matching from.source.requestPrincipals: ["*"], and check specific claims via when: [{ key: request.auth.claims[groups], values: [admins] }]. Both require L7, meaning a waypoint in ambient mode.
  • Client-side TLS. A DestinationRule's trafficPolicy.tls.mode (DISABLE, SIMPLE, MUTUAL with custom certs, or ISTIO_MUTUAL) overrides automatic mTLS for that destination. A forgotten DISABLE rule is a classic culprit when STRICT mTLS suddenly breaks.

Proving it

In ambient mode, check istioctl ztunnel-config workloads (look at PROTOCOL and WAYPOINT), istioctl ztunnel-config certificates (one cert per ServiceAccount, ~24h lifetime rotated automatically by istiod), istioctl ztunnel-config policies, and ztunnel access logs showing src.identity, dst.identity, and dst.addr=...:15008. For metrics, look at istio_tcp_connections_opened_total{connection_security_policy="mutual_tls"} at L4 (the HTTP-level istio_requests_total series only appears once a waypoint is in the path). In sidecar mode, use istioctl proxy-status, istioctl x describe pod <pod>, and istioctl analyze. Under either mode, always start with kubectl get peerauthentication -A and kubectl get authorizationpolicy -A: half the time the culprit is a root-namespace policy you didn't realize existed.

SPIRE: identity without a mesh

SPIFFE · SVID · Workload API

SPIFFE is the open standard; SPIRE is its reference implementation. A SPIFFE ID is a URI naming a workload, an SVID is the cryptographic credential proving it (either an X.509 certificate or a JWT), and the Workload API is a local Unix socket the pod reads to fetch its SVID and trust bundle with zero network calls, zero mounted Secrets, and automatic rotation.

spire-server  (CA + registration entries)
     ▲ node attestation (which node is this?)
spire-agent (DaemonSet)
     ▲ workload attestation (which pod/SA/labels is this process?)
your pod ──reads──▶ /run/spire/sockets/agent.sock  (mounted via the csi.spiffe.io CSI driver)
                          receives: X.509-SVID + trust bundle, rotated automatically

Two separate attestation steps keep this trustworthy: first the agent proves the node to spire-server, then it identifies each calling workload locally by inspecting the process (its namespace, ServiceAccount, and labels). Registration entries map those selectors to SPIFFE IDs, and this lab deploys a ClusterSPIFFEID CR so the controller templates entries automatically instead of making you register every pod by hand.

When to reach for which

Choose a mesh (Istio or Linkerd) when you want transparent mTLS and policy for HTTP/gRPC traffic between services without changing app code. Choose standalone SPIRE when workloads need to authenticate to something outside the mesh (a managed database, a cloud API, or a partner service) using short-lived credentials and zero static secrets. Whenever a prompt says "authenticate to an external service with short-lived credentials and no mesh", it's pointing straight at SPIRE.

Linkerd, since the tool list names it

Same goal, different vocabulary: a sidecar data plane, automatic mTLS between meshed pods, ServiceAccount-based identities, authorization via Server and AuthorizationPolicy resources, and linkerd viz edges to verify which links are secured. The permissive-by-default warning carries straight over too: Linkerd's default inbound policy (all-unauthenticated) still accepts plaintext from unmeshed callers, so blocking plaintext means tightening proxy.defaultInboundPolicy or attaching an explicit Server policy. You can swap the lab over anytime with MESH=linkerd make mesh; all the concepts transfer intact, only the resource names change.

Linkerd and SPIRE, field by field

the CRDs, the CLI verbs, the attestation chain

Linkerd

  • Joining the mesh. Add linkerd.io/inject: enabled to a namespace or pod template (or pipe manifests through linkerd inject), then verify proxies and cert health with linkerd check --proxy -n ns. Identities come from the pod's ServiceAccount, signed by linkerd-identity using a trust anchor and issuer cert (in production, cert-manager rotates the issuer; an expired issuer is the classic linkerd check failure).
  • Default inbound policy. Set proxy.defaultInboundPolicy at install time or annotate namespaces/workloads with config.linkerd.io/default-inbound-policy: choices are all-unauthenticated (default), all-authenticated (meshed clients from any cluster), cluster-authenticated, cluster-unauthenticated, deny, and audit (allows while flagging in logs and request_total{authz_name="audit"}). Blocking plaintext requires all-authenticated at minimum.
  • Fine-grained policy. Server (policy.linkerd.io/v1beta1: podSelector, port name or number, proxyProtocol, and accessPolicy which defaults to deny) defines the protected port. An HTTPRoute with parentRefs pointing at that Server narrows rules to paths and methods. MeshTLSAuthentication (listing identities like web.emojivoto.serviceaccount.identity.linkerd.cluster.local or identityRefs to ServiceAccounts) and NetworkAuthentication (networks[].cidr) define who's allowed, and AuthorizationPolicy (policy.linkerd.io/v1alpha1) binds a targetRef (Server, HTTPRoute, or Namespace) to requiredAuthenticationRefs. Watch out for health checks: defining a Server on a port that serves kubelet probes without authorizing them (Linkerd auto-allows probes on the default route, not custom HTTPRoutes) is the classic way readiness probes break right after "locking down security".
  • Diagnostic verbs. linkerd viz authz -n ns deploy/x shows every policy allowing or denying traffic and its counts; linkerd viz edges deploy -n ns prints client and server identities per link (a - signals unmeshed or plaintext); linkerd viz tap streams live requests with a tls=true column; and linkerd viz stat summarizes success rates.

SPIFFE and SPIRE

TermExactly
SPIFFE IDspiffe://<trust-domain>/<path>; lowercase trust domain, no query or fragment. Istio and Linkerd both issue spiffe://cluster.local/ns/<ns>/sa/<sa>
X509-SVIDA leaf cert carrying exactly one URI SAN holding the SPIFFE ID; short-lived (SPIRE defaults: default_x509_svid_ttl 1h, CA ca_ttl 24h); validators reject multiple URI SANs
JWT-SVIDA JWT with sub = SPIFFE ID and your requested aud, built for systems that can't terminate mTLS
Trust bundleThe CA certificates for a trust domain; federated bundles hold another domain's CAs, fetched from its bundle endpoint
Workload APIA gRPC service over a local Unix socket (SPIFFE_ENDPOINT_SOCKET); FetchX509SVID streams updates automatically on rotation, with no caller credentials needed because the agent attests the caller
Node attestationHow the agent proves its node identity: k8s_psat (projected SA token) in Kubernetes, plus aws_iid, gcp_iit, azure_msi, join_token, x509pop, tpm_devid
Workload attestationHow the agent identifies a calling process; the k8s attestor queries the kubelet to produce selectors like k8s:ns:<ns>, k8s:sa:<sa>, k8s:pod-label:<k>:<v>, and k8s:container-image:...
Registration entryspire-server entry create -parentID <agent id> -spiffeID <id> -selector k8s:ns:x -selector k8s:sa:y [-ttl] [-dns] [-federatesWith]; maps selectors to an issued identity
ClusterSPIFFEIDThe spire-controller-manager CRD that auto-templates entries using spiffeIDTemplate (spiffe://{{ .TrustDomain }}/ns/{{ .PodMeta.Namespace }}/sa/{{ .PodSpec.ServiceAccountName }}), podSelector, namespaceSelector, dnsNameTemplates, ttl, federatesWith, and fallback
CSI drivercsi.spiffe.io mounts the agent socket as a read-only ephemeral inline volume so workloads don't need hostPath (forbidden under restricted PSS); only the agent DaemonSet itself uses hostPath
FederationEach server exposes a bundle endpoint (federation.bundle_endpoint) and lists trusted foreign domains; entries with -federatesWith receive those bundles so a workload in cluster A can verify one in cluster B

Upstream authorities (disk, cert-manager, vault, aws_pca, and others) let SPIRE's CA chain directly into your existing PKI. Two adjacent tools worth recognizing: Cilium's mutual authentication (beta) borrows SPIRE identities and performs the auth handshake out of band while WireGuard or IPsec encrypts packets (enabled per CiliumNetworkPolicy via authentication.mode: required), and cert-manager's trust-manager Bundle distributes private CA bundles into ConfigMaps across every namespace so apps trust internal CAs cleanly.

How this gets tested

Istio tasks follow a clear trio: "require mTLS in namespace X" (PeerAuthentication STRICT in X), "allow only service A to call B" (AuthorizationPolicy with principals), and "allow only GET" (waypoint plus targetRefs and to.operation.methods), always verified with one unmeshed failure and one meshed success. Linkerd tasks test the exact same trio using Server, MeshTLSAuthentication, and AuthorizationPolicy, verified with linkerd viz authz. SPIRE tasks usually ask you to read an entry or ClusterSPIFFEID and trace which pods get which ID.

Exercises

tick the dot when its check passes

Run all of these on kind-mesh (kubectx kind-mesh) except the SPIRE exercises.

Deploy two ordinary plaintext workloads in default and send a request between them:

kubectl create deploy backend --image=ghcr.io/nginxinc/nginx-unprivileged:1.27-alpine --port=8080
kubectl expose deploy backend --port=8080
kubectl run client --image=curlimages/curl:8.11.1 --restart=Never -- sh -c 'sleep 3600'
kubectl wait --for=condition=Available deploy/backend --timeout=120s
kubectl wait --for=condition=Ready pod/client --timeout=120s
kubectl exec client -- curl -s -o /dev/null -w '%{http_code}\n' http://backend:8080
outputcaptured 2026-11-18
$ kubectl create deploy backend --image=ghcr.io/nginxinc/nginx-unprivileged:1.27-alpine --port=8080
deployment.apps/backend created
$ kubectl expose deploy backend --port=8080
service/backend exposed
$ kubectl run client --image=curlimages/curl:8.11.1 --restart=Never -- sh -c 'sleep 3600'
pod/client created
$ kubectl wait --for=condition=Available deploy/backend --timeout=120s
deployment.apps/backend condition met
$ kubectl wait --for=condition=Ready pod/client --timeout=120s
pod/client condition met
$ kubectl exec client -- curl -s -o /dev/null -w '%{http_code}\n' http://backend:8080
200

Now back up the encryption claim with evidence: istioctl ztunnel-config workload lists both pods under protocol HBONE, and kubectl -n istio-system logs ds/ztunnel | grep -i backend | tail shows connections stamped with source and destination SPIFFE identities.

verify: HBONE shows up in ztunnel config and SPIFFE identities appear in the logs. Neither app changed a single line; the platform upgraded the transport transparently.

Turn on STRICT mTLS and test it from outside the mesh:

kubectl apply -f - <<'EOF'
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata: { name: default, namespace: default }
spec: { mtls: { mode: STRICT } }
EOF
kubectl create ns outsider   # not labelled ambient, therefore not in the mesh
kubectl -n outsider run intruder --image=curlimages/curl:8.11.1 --restart=Never -- \
  curl -s -m 5 -o /dev/null -w '%{http_code}' http://backend.default.svc:8080
kubectl -n outsider wait --for=jsonpath='{.status.phase}'=Failed pod/intruder --timeout=60s   # the refused curl exits non-zero
kubectl -n outsider logs intruder
outputcaptured 2026-11-18
$ kubectl apply -f - <<'EOF'
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata: { name: default, namespace: default }
spec: { mtls: { mode: STRICT } }
EOF
peerauthentication.security.istio.io/default created
$ kubectl create ns outsider   # not labelled ambient, therefore not in the mesh
namespace/outsider created
$ kubectl -n outsider run intruder --image=curlimages/curl:8.11.1 --restart=Never -- \
  curl -s -m 5 -o /dev/null -w '%{http_code}' http://backend.default.svc:8080
pod/intruder created
$ kubectl -n outsider wait --for=jsonpath='{.status.phase}'=Failed pod/intruder --timeout=60s   # the refused curl exits non-zero
pod/intruder condition met
$ kubectl -n outsider logs intruder
000
verify: the in-mesh client still gets 200 while the outsider's plaintext curl gets refused (000). Delete the PeerAuthentication and watch the outsider succeed again; that before/strict/after proof is exactly what this competency asks you to demonstrate. Put STRICT back on and clean up with kubectl delete ns outsider so the Failed intruder pod doesn't trip make validate.

With STRICT back in place, add an AuthorizationPolicy permitting only the client pod's ServiceAccount to call backend, then test from a second pod running under a different SA.

verify: the allowed SA gets 200 and the second SA fails (notice that an L4 deny shows up as a connection reset rather than an HTTP 403). You've just enforced network access based on who is calling instead of where they sit, which is the core zero-trust takeaway.

Switch back with kubectx kind-cnpe, then inspect SPIRE's live entries:

kubectl -n spire exec sts/spire-server -c spire-server -- \
  /opt/spire/bin/spire-server entry show
kubectl get clusterspiffeids
outputcaptured 2026-08-26
$ kubectl -n spire exec sts/spire-server -c spire-server -- \
  /opt/spire/bin/spire-server entry show
Found 82 entries
Entry ID                : cnpe.f689fd1b-3650-40a9-b286-2027082a0b0f
SPIFFE ID               : spiffe://lab.local/ns/argo-rollouts/sa/argo-rollouts
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/3e493a08-e750-4c41-b117-9792d6b3d3e2
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:62bcfbc0-50de-47d1-8d4c-03cea8a7ada1
Hint                    : default

Entry ID                : cnpe.a6e5b7b3-7045-4cc4-ab83-927be2e17912
SPIFFE ID               : spiffe://lab.local/ns/argo-rollouts/sa/argo-rollouts
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/9f10fbfe-1d5c-4ed1-af96-9a9e22e11c23
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:67550dfb-4b01-4853-8444-129e737f9de8
Hint                    : default

Entry ID                : cnpe.411a6117-8eff-49c5-88e5-26e3fe8169b2
SPIFFE ID               : spiffe://lab.local/ns/argo-rollouts/sa/argo-rollouts-dashboard
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/3e493a08-e750-4c41-b117-9792d6b3d3e2
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:1086be52-6ae4-473e-adc9-539fecd83956
Hint                    : default

Entry ID                : cnpe.7f673027-388e-4602-8bac-6372a6fbbcab
SPIFFE ID               : spiffe://lab.local/ns/argo/sa/argo-workflows-server
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/9f10fbfe-1d5c-4ed1-af96-9a9e22e11c23
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:934e7f1b-532a-4feb-b8dd-455a293461f5
Hint                    : default

Entry ID                : cnpe.b77b309f-d092-4410-8dd8-641efb487d17
SPIFFE ID               : spiffe://lab.local/ns/argo/sa/argo-workflows-workflow-controller
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/3e493a08-e750-4c41-b117-9792d6b3d3e2
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:e6b28c00-42d8-4682-b002-104ccee47f45
Hint                    : default

Entry ID                : cnpe.ee72b8b6-24e6-4b3c-8145-aa2424377815
SPIFFE ID               : spiffe://lab.local/ns/argocd/sa/argocd-application-controller
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/9f10fbfe-1d5c-4ed1-af96-9a9e22e11c23
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:6060093b-3490-4e57-a3dd-a313b25daddf
Hint                    : default

Entry ID                : cnpe.63659ff9-0b32-4544-8e81-d96af66c6a1f
SPIFFE ID               : spiffe://lab.local/ns/argocd/sa/argocd-applicationset-controller
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/9f10fbfe-1d5c-4ed1-af96-9a9e22e11c23
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:ead2e2f8-6cbe-421d-8ace-7c08dd84da4a
Hint                    : default

Entry ID                : cnpe.8e32612a-f03f-42ec-b3ee-d4cfb7f8e802
SPIFFE ID               : spiffe://lab.local/ns/argocd/sa/argocd-repo-server
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/9f10fbfe-1d5c-4ed1-af96-9a9e22e11c23
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:c9d1ee4f-d9c6-447f-a989-c1829d6ce30e
Hint                    : default

Entry ID                : cnpe.6eb6f835-5da3-4075-8c65-3abdf0843151
SPIFFE ID               : spiffe://lab.local/ns/argocd/sa/argocd-server
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/3e493a08-e750-4c41-b117-9792d6b3d3e2
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:003a3a4b-490a-4c3f-b0d9-dc75f07e3f64
Hint                    : default

Entry ID                : cnpe.f00bca44-ba66-4150-90b7-ebeaa9346e79
SPIFFE ID               : spiffe://lab.local/ns/argocd/sa/default
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/9f10fbfe-1d5c-4ed1-af96-9a9e22e11c23
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:b46f92c6-6e94-41d7-9987-ba9afef0f3dc
Hint                    : default

Entry ID                : cnpe.5b96f37c-b032-4c38-bfd7-9d260e71aa6f
SPIFFE ID               : spiffe://lab.local/ns/cnpg-system/sa/cnpg-cloudnative-pg
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/9f10fbfe-1d5c-4ed1-af96-9a9e22e11c23
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:83a82031-f4e4-4554-ace6-7313c9210bcf
Hint                    : default

Entry ID                : cnpe.794e5a7e-384b-4cca-bbfa-96b4b39c67b0
SPIFFE ID               : spiffe://lab.local/ns/crossplane-system/sa/crossplane
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/9f10fbfe-1d5c-4ed1-af96-9a9e22e11c23
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:4870669a-ff67-4200-bec7-4e4e35760c6d
Hint                    : default
… (596 lines omitted)
SPIFFE ID               : spiffe://lab.local/ns/trivy-system/sa/trivy-operator
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/3e493a08-e750-4c41-b117-9792d6b3d3e2
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:1ec71fc7-51f5-4293-922d-f82124fa3ce2
Hint                    : default

Entry ID                : cnpe.a7ad897d-5d41-49e6-875c-9eef9bd8b396
SPIFFE ID               : spiffe://lab.local/ns/vpa/sa/vpa-admission-controller
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/3e493a08-e750-4c41-b117-9792d6b3d3e2
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:a3f1bf4a-315c-4481-85ac-78593f50e011
Hint                    : default

Entry ID                : cnpe.3cad5033-b1a9-4682-892e-e1471e4c27a1
SPIFFE ID               : spiffe://lab.local/ns/vpa/sa/vpa-recommender
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/3e493a08-e750-4c41-b117-9792d6b3d3e2
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:f830581e-0fc4-4d85-b109-9a4701b47be8
Hint                    : default

Entry ID                : cnpe.458b7884-4ad1-4e3f-9885-9cb1fc3f1f9d
SPIFFE ID               : spiffe://lab.local/ns/vpa/sa/vpa-updater
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/3e493a08-e750-4c41-b117-9792d6b3d3e2
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:10b880f4-50bb-43db-a46f-96ea7e219d31
Hint                    : default

$ kubectl get clusterspiffeids
NAME                                  AGE
spire-spire-default                   46m
spire-spire-oidc-discovery-provider   46m
spire-spire-test-keys                 46m

Inspect the ClusterSPIFFEID CR and map its template straight to the entries it generated. If you want to trace the full loop, mount the CSI socket (csi.spiffe.io) into a pod and check the socket file: identities arrive locally over the filesystem with zero network calls, which is why SPIRE plugs cleanly into almost any stack.

verify: registration entries map SPIFFE IDs to Kubernetes selectors, and you can read one entry aloud: this ID is issued to workloads matching this namespace and ServiceAccount, attested by this parent agent.

Ambient mode gives you L4 identity automatically and adds L7 policy only where you deploy a waypoint. Enrolling a namespace and attaching a method-scoped rule is the whole anatomy of an L7 authorization task.

kubectl --context kind-mesh label ns default istio.io/dataplane-mode=ambient --overwrite
istioctl --context kind-mesh waypoint apply -n default --enroll-namespace --overwrite --wait
kubectl --context kind-mesh get gtw waypoint
kubectl --context kind-mesh -n default create deployment backend --image=ghcr.io/stefanprodan/podinfo:6.7.1 --dry-run=client -o yaml | kubectl --context kind-mesh apply -f -
kubectl --context kind-mesh -n default delete svc backend --ignore-not-found   # the first exercise exposed it on 8080
kubectl --context kind-mesh -n default expose deployment backend --port=80 --target-port=9898 --dry-run=client -o yaml | kubectl --context kind-mesh apply -f -
kubectl --context kind-mesh -n default create deployment client --image=curlimages/curl:8.11.1 --dry-run=client -o yaml -- sleep 86400 | kubectl --context kind-mesh apply -f -
kubectl --context kind-mesh -n default rollout status deploy/backend --timeout=180s
kubectl --context kind-mesh -n default rollout status deploy/client --timeout=180s
kubectl --context kind-mesh apply -f - <<'EOF'
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata: { name: backend-get-only, namespace: default }
spec:
  targetRefs:
    - { group: gateway.networking.k8s.io, kind: Gateway, name: waypoint }
  action: ALLOW
  rules:
    - from:
        - source:
            principals: ["cluster.local/ns/default/sa/default"]
      to:
        - operation:
            methods: [GET]
EOF
sleep 20
CLIENT=$(kubectl --context kind-mesh -n default get pod -l app=client -o jsonpath='{.items[0].metadata.name}')
kubectl --context kind-mesh -n default exec "$CLIENT" -- curl -s -o /dev/null -w '%{http_code}\n' http://backend/
kubectl --context kind-mesh -n default exec "$CLIENT" -- curl -s -X POST -o /dev/null -w '%{http_code}\n' http://backend/
kubectl --context kind-mesh -n default exec "$CLIENT" -- curl -s -X POST http://backend/ | head -2
outputcaptured 2026-11-18
$ kubectl --context kind-mesh label ns default istio.io/dataplane-mode=ambient --overwrite
namespace/default not labeled
$ istioctl --context kind-mesh waypoint apply -n default --enroll-namespace --overwrite --wait
✅ waypoint default/waypoint applied
✅ waypoint default/waypoint is ready!
✅ namespace default labeled with "istio.io/use-waypoint: waypoint"
$ kubectl --context kind-mesh get gtw waypoint
NAME       CLASS            ADDRESS       PROGRAMMED   AGE
waypoint   istio-waypoint   10.96.3.255   True         65s
$ kubectl --context kind-mesh -n default create deployment backend --image=ghcr.io/stefanprodan/podinfo:6.7.1 --dry-run=client -o yaml | kubectl --context kind-mesh apply -f -
Warning: resource deployments/backend is missing the kubectl.kubernetes.io/last-applied-configuration annotation which is required by kubectl apply. kubectl apply should only be used on resources created declaratively by either kubectl create --save-config or kubectl apply. The missing annotation will be patched automatically.
deployment.apps/backend configured
$ kubectl --context kind-mesh -n default delete svc backend --ignore-not-found   # the first exercise exposed it on 8080
service "backend" deleted from default namespace
$ kubectl --context kind-mesh -n default expose deployment backend --port=80 --target-port=9898 --dry-run=client -o yaml | kubectl --context kind-mesh apply -f -
service/backend created
$ kubectl --context kind-mesh -n default create deployment client --image=curlimages/curl:8.11.1 --dry-run=client -o yaml -- sleep 86400 | kubectl --context kind-mesh apply -f -
deployment.apps/client created
$ kubectl --context kind-mesh -n default rollout status deploy/backend --timeout=180s
Waiting for deployment "backend" rollout to finish: 1 old replicas are pending termination...
Waiting for deployment "backend" rollout to finish: 1 old replicas are pending termination...
deployment "backend" successfully rolled out
$ kubectl --context kind-mesh -n default rollout status deploy/client --timeout=180s
Waiting for deployment "client" rollout to finish: 0 of 1 updated replicas are available...
deployment "client" successfully rolled out
$ kubectl --context kind-mesh apply -f - <<'EOF'
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata: { name: backend-get-only, namespace: default }
spec:
  targetRefs:
    - { group: gateway.networking.k8s.io, kind: Gateway, name: waypoint }
  action: ALLOW
  rules:
    - from:
        - source:
            principals: ["cluster.local/ns/default/sa/default"]
      to:
        - operation:
            methods: [GET]
EOF
authorizationpolicy.security.istio.io/backend-get-only created
$ sleep 20
$ CLIENT=$(kubectl --context kind-mesh -n default get pod -l app=client -o jsonpath='{.items[0].metadata.name}')
$ kubectl --context kind-mesh -n default exec "$CLIENT" -- curl -s -o /dev/null -w '%{http_code}\n' http://backend/
200
$ kubectl --context kind-mesh -n default exec "$CLIENT" -- curl -s -X POST -o /dev/null -w '%{http_code}\n' http://backend/
403
$ kubectl --context kind-mesh -n default exec "$CLIENT" -- curl -s -X POST http://backend/ | head -2
RBAC: access denied
verify: GET succeeds with 200 while POST gets blocked with 403 and RBAC: access denied in the body.

An L7 rule attached via selector instead of a waypoint has no HTTP parser to inspect the method, so Istio fails safe and denies everything rather than guessing. Because ztunnel operates at L4, it can't return an HTTP 403; it drops the TCP connection outright and curl never sees a status code.

kubectl --context kind-mesh delete authorizationpolicy backend-get-only -n default --ignore-not-found
# the previous exercise left the namespace enrolled; take the waypoint away or there is nothing to prove
kubectl --context kind-mesh label ns default istio.io/use-waypoint- --overwrite
istioctl --context kind-mesh waypoint delete waypoint -n default
sleep 15
kubectl --context kind-mesh get gtw -n default
kubectl --context kind-mesh apply -f - <<'EOF'
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata: { name: selector-l7, namespace: default }
spec:
  selector:
    matchLabels: { app: backend }
  action: ALLOW
  rules:
    - to:
        - operation:
            methods: [GET]
EOF
sleep 20
CLIENT=$(kubectl --context kind-mesh -n default get pod -l app=client -o jsonpath='{.items[0].metadata.name}')
kubectl --context kind-mesh -n default exec "$CLIENT" -- curl -s -o /dev/null -w 'http_code=%{http_code}\n' -m 5 http://backend/; echo "curl exit $?"
kubectl --context kind-mesh delete authorizationpolicy selector-l7 -n default
# put the waypoint back: the later exercises on this page are L7 and need it
istioctl --context kind-mesh waypoint apply -n default --enroll-namespace --wait
kubectl --context kind-mesh get gtw waypoint -n default
outputcaptured 2026-09-12
$ kubectl --context kind-mesh delete authorizationpolicy backend-get-only -n default --ignore-not-found
$ # the previous exercise left the namespace enrolled; take the waypoint away or there is nothing to prove
$ kubectl --context kind-mesh label ns default istio.io/use-waypoint- --overwrite
namespace/default unlabeled
$ istioctl --context kind-mesh waypoint delete waypoint -n default
waypoint default/waypoint deleted
$ sleep 15
$ kubectl --context kind-mesh get gtw -n default
No resources found in default namespace.
$ kubectl --context kind-mesh apply -f - <<'EOF'
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata: { name: selector-l7, namespace: default }
spec:
  selector:
    matchLabels: { app: backend }
  action: ALLOW
  rules:
    - to:
        - operation:
            methods: [GET]
EOF
authorizationpolicy.security.istio.io/selector-l7 created
$ sleep 20
$ CLIENT=$(kubectl --context kind-mesh -n default get pod -l app=client -o jsonpath='{.items[0].metadata.name}')
$ kubectl --context kind-mesh -n default exec "$CLIENT" -- curl -s -o /dev/null -w 'http_code=%{http_code}\n' -m 5 http://backend/; echo "curl exit $?"
http_code=000
command terminated with exit code 56
curl exit 56
$ kubectl --context kind-mesh delete authorizationpolicy selector-l7 -n default
authorizationpolicy.security.istio.io "selector-l7" deleted from default namespace
$ # put the waypoint back: the later exercises on this page are L7 and need it
$ istioctl --context kind-mesh waypoint apply -n default --enroll-namespace --wait
✅ waypoint default/waypoint applied
✅ waypoint default/waypoint is ready!
✅ namespace default labeled with "istio.io/use-waypoint: waypoint"
$ kubectl --context kind-mesh get gtw waypoint -n default
NAME       CLASS            ADDRESS         PROGRAMMED   AGE
waypoint   istio-waypoint   10.96.191.232   True         8s
verify: the exact same GET that returned 200 through the waypoint now returns http_code=000 and curl exit 56 (a receive failure rather than a 403). Keep that tell handy: a 403 means an L7 proxy read your request and said no, while exit 56 means the connection was reset at L4. Make sure you know instinctively whether to reach for targetRefs or selector whenever a rule mentions paths or methods.

Strict mTLS everywhere is the end state, rarely day one. Port-level exceptions let you onboard a legacy service without loosening the entire namespace, and the exception stays visible in a single manifest.

# portLevelMtls is rejected without a selector, so this cannot be the namespace-wide policy
kubectl --context kind-mesh apply -f - <<'EOF'
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata: { name: backend-legacy-port, namespace: default }
spec:
  selector:
    matchLabels: { app: backend }
  mtls: { mode: STRICT }
  portLevelMtls:
    9898:
      mode: PERMISSIVE
EOF
sleep 15
kubectl --context kind-mesh get peerauthentication backend-legacy-port -n default -o jsonpath='{.spec}' | jq
kubectl --context kind-mesh -n default run outsider --image=curlimages/curl:8.11.1 --restart=Never --overrides='{"metadata":{"labels":{"istio.io/dataplane-mode":"none"}},"spec":{"containers":[{"name":"outsider","image":"curlimages/curl:8.11.1","command":["sh","-c","sleep 300"]}]}}'
kubectl --context kind-mesh -n default wait --for=condition=Ready pod/outsider --timeout=120s
BACKEND=$(kubectl --context kind-mesh -n default get pod -l app=backend -o jsonpath='{.items[0].status.podIP}')
kubectl --context kind-mesh -n default exec outsider -- curl -s -o /dev/null -m 5 -w 'permissive_port=%{http_code}\n' "http://$BACKEND:9898/"; echo "curl exit $?"
# now close the exception and nothing else changes
kubectl --context kind-mesh patch peerauthentication backend-legacy-port -n default --type merge -p '{"spec":{"portLevelMtls":{"9898":{"mode":"STRICT"}}}}'
sleep 15
kubectl --context kind-mesh -n default exec outsider -- curl -s -o /dev/null -m 5 -w 'strict_port=%{http_code}\n' "http://$BACKEND:9898/"; echo "curl exit $?"
kubectl --context kind-mesh -n default delete pod outsider
kubectl --context kind-mesh delete peerauthentication backend-legacy-port -n default
outputcaptured 2026-09-13
$ # portLevelMtls is rejected without a selector, so this cannot be the namespace-wide policy
$ kubectl --context kind-mesh apply -f - <<'EOF'
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata: { name: backend-legacy-port, namespace: default }
spec:
  selector:
    matchLabels: { app: backend }
  mtls: { mode: STRICT }
  portLevelMtls:
    9898:
      mode: PERMISSIVE
EOF
peerauthentication.security.istio.io/backend-legacy-port created
$ sleep 15
$ kubectl --context kind-mesh get peerauthentication backend-legacy-port -n default -o jsonpath='{.spec}' | jq
{
  "mtls": {
    "mode": "STRICT"
  },
  "portLevelMtls": {
    "9898": {
      "mode": "PERMISSIVE"
    }
  },
  "selector": {
    "matchLabels": {
      "app": "backend"
    }
  }
}
$ kubectl --context kind-mesh -n default run outsider --image=curlimages/curl:8.11.1 --restart=Never --overrides='{"metadata":{"labels":{"istio.io/dataplane-mode":"none"}},"spec":{"containers":[{"name":"outsider","image":"curlimages/curl:8.11.1","command":["sh","-c","sleep 300"]}]}}'
pod/outsider created
$ kubectl --context kind-mesh -n default wait --for=condition=Ready pod/outsider --timeout=120s
pod/outsider condition met
$ BACKEND=$(kubectl --context kind-mesh -n default get pod -l app=backend -o jsonpath='{.items[0].status.podIP}')
$ kubectl --context kind-mesh -n default exec outsider -- curl -s -o /dev/null -m 5 -w 'permissive_port=%{http_code}\n' "http://$BACKEND:9898/"; echo "curl exit $?"
permissive_port=200
curl exit 0
$ # now close the exception and nothing else changes
$ kubectl --context kind-mesh patch peerauthentication backend-legacy-port -n default --type merge -p '{"spec":{"portLevelMtls":{"9898":{"mode":"STRICT"}}}}'
peerauthentication.security.istio.io/backend-legacy-port patched
$ sleep 15
$ kubectl --context kind-mesh -n default exec outsider -- curl -s -o /dev/null -m 5 -w 'strict_port=%{http_code}\n' "http://$BACKEND:9898/"; echo "curl exit $?"
strict_port=000
command terminated with exit code 56
curl exit 56
$ kubectl --context kind-mesh -n default delete pod outsider
pod "outsider" deleted from default namespace
$ kubectl --context kind-mesh delete peerauthentication backend-legacy-port -n default
peerauthentication.security.istio.io "backend-legacy-port" deleted from default namespace
verify: plaintext gets through on the permissive port (200) and gets cut off immediately (exit 56) once you patch that port back to STRICT.

Request authentication and authorization are split into two objects on purpose: one validates the JWT if present, and the other enforces who can call. Deploying only RequestAuthentication quietly leaves anonymous traffic wide open, which is one of Istio's classic traps.

kubectl --context kind-mesh apply -f - <<'EOF'
apiVersion: security.istio.io/v1
kind: RequestAuthentication
metadata: { name: jwt-demo, namespace: default }
spec:
  targetRefs:
    - { group: gateway.networking.k8s.io, kind: Gateway, name: waypoint }
  jwtRules:
    - issuer: "testing@secure.istio.io"
      jwksUri: "https://raw.githubusercontent.com/istio/istio/release-1.24/security/tools/jwt/samples/jwks.json"
---
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata: { name: require-jwt, namespace: default }
spec:
  targetRefs:
    - { group: gateway.networking.k8s.io, kind: Gateway, name: waypoint }
  action: ALLOW
  rules:
    - from:
        - source:
            requestPrincipals: ["*"]
EOF
sleep 20
CLIENT=$(kubectl --context kind-mesh -n default get pod -l app=client -o jsonpath='{.items[0].metadata.name}')
kubectl --context kind-mesh -n default exec "$CLIENT" -- curl -s -o /dev/null -w 'no token: %{http_code}\n' http://backend/
TOKEN=$(curl -s https://raw.githubusercontent.com/istio/istio/release-1.24/security/tools/jwt/samples/demo.jwt)
kubectl --context kind-mesh -n default exec "$CLIENT" -- curl -s -o /dev/null -w 'with token: %{http_code}\n' -H "Authorization: Bearer $TOKEN" http://backend/
kubectl --context kind-mesh delete authorizationpolicy require-jwt -n default
kubectl --context kind-mesh delete requestauthentication jwt-demo -n default
outputcaptured 2026-09-12
$ kubectl --context kind-mesh apply -f - <<'EOF'
apiVersion: security.istio.io/v1
kind: RequestAuthentication
metadata: { name: jwt-demo, namespace: default }
spec:
  targetRefs:
    - { group: gateway.networking.k8s.io, kind: Gateway, name: waypoint }
  jwtRules:
    - issuer: "testing@secure.istio.io"
      jwksUri: "https://raw.githubusercontent.com/istio/istio/release-1.24/security/tools/jwt/samples/jwks.json"
---
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata: { name: require-jwt, namespace: default }
spec:
  targetRefs:
    - { group: gateway.networking.k8s.io, kind: Gateway, name: waypoint }
  action: ALLOW
  rules:
    - from:
        - source:
            requestPrincipals: ["*"]
EOF
requestauthentication.security.istio.io/jwt-demo created
authorizationpolicy.security.istio.io/require-jwt created
$ sleep 20
$ CLIENT=$(kubectl --context kind-mesh -n default get pod -l app=client -o jsonpath='{.items[0].metadata.name}')
$ kubectl --context kind-mesh -n default exec "$CLIENT" -- curl -s -o /dev/null -w 'no token: %{http_code}\n' http://backend/
no token: 403
$ TOKEN=$(curl -s https://raw.githubusercontent.com/istio/istio/release-1.24/security/tools/jwt/samples/demo.jwt)
$ kubectl --context kind-mesh -n default exec "$CLIENT" -- curl -s -o /dev/null -w 'with token: %{http_code}\n' -H "Authorization: Bearer $TOKEN" http://backend/
with token: 200
$ kubectl --context kind-mesh delete authorizationpolicy require-jwt -n default
authorizationpolicy.security.istio.io "require-jwt" deleted from default namespace
$ kubectl --context kind-mesh delete requestauthentication jwt-demo -n default
requestauthentication.security.istio.io "jwt-demo" deleted from default namespace
verify: the tokenless call gets 403 while the call with the sample JWT returns 200. Try deleting only the AuthorizationPolicy while leaving RequestAuthentication in place: anonymous traffic goes right back to 200, which is the exact trap to recognize on sight.

ztunnel holds the workload certs and enforces L4 policy, making its config dump the ground truth for who the mesh thinks every pod is. Whenever a policy behaves unexpectedly, this is where you settle the debate.

# ztunnel-config needs a specific ztunnel, and the one that logs a connection is the one on the client's node
CLIENT=$(kubectl --context kind-mesh -n default get pod -l app=client -o jsonpath='{.items[0].metadata.name}')
NODE=$(kubectl --context kind-mesh -n default get pod "$CLIENT" -o jsonpath='{.spec.nodeName}')
ZT=$(kubectl --context kind-mesh -n istio-system get pod -l app=ztunnel --field-selector spec.nodeName=$NODE -o jsonpath='{.items[0].metadata.name}')
echo "client=$CLIENT node=$NODE ztunnel=$ZT"
istioctl --context kind-mesh ztunnel-config certificates "$ZT.istio-system" | head -6
kubectl --context kind-mesh apply -f - <<'EOF'
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata: { name: ztunnel-demo, namespace: default }
spec:
  selector:
    matchLabels: { app: backend }
  action: ALLOW
  rules:
    - from:
        - source:
            principals: ["cluster.local/ns/default/sa/default", "cluster.local/ns/default/sa/waypoint"]
EOF
sleep 10
istioctl --context kind-mesh ztunnel-config policies | head -6
istioctl --context kind-mesh ztunnel-config workloads | head -6
kubectl --context kind-mesh -n default exec "$CLIENT" -- curl -s -o /dev/null -m 5 http://backend/
sleep 5
kubectl --context kind-mesh -n istio-system logs "$ZT" --tail=80 | grep -E 'src.identity' | tail -2
kubectl --context kind-mesh delete authorizationpolicy ztunnel-demo -n default
outputcaptured 2026-11-18
$ # ztunnel-config needs a specific ztunnel, and the one that logs a connection is the one on the client's node
$ CLIENT=$(kubectl --context kind-mesh -n default get pod -l app=client -o jsonpath='{.items[0].metadata.name}')
$ NODE=$(kubectl --context kind-mesh -n default get pod "$CLIENT" -o jsonpath='{.spec.nodeName}')
$ ZT=$(kubectl --context kind-mesh -n istio-system get pod -l app=ztunnel --field-selector spec.nodeName=$NODE -o jsonpath='{.items[0].metadata.name}')
$ echo "client=$CLIENT node=$NODE ztunnel=$ZT"
client=client-65b9d75449-fbtfj node=mesh-worker ztunnel=ztunnel-6wbft
$ istioctl --context kind-mesh ztunnel-config certificates "$ZT.istio-system" | head -6
CERTIFICATE NAME                                 TYPE     STATUS        VALID CERT     SERIAL NUMBER                        NOT AFTER                NOT BEFORE
spiffe://cluster.local/ns/default/sa/default     Leaf     Available     true           c88ecc85ff4f910babcb7cadb9ed2b5f     2026-11-19T09:54:33Z     2026-11-18T09:52:33Z
spiffe://cluster.local/ns/default/sa/default     Root     Available     true           3cc5246ce7f67728e63bee08841c0416     2036-11-15T04:22:19Z     2026-11-18T04:22:19Z
$ kubectl --context kind-mesh apply -f - <<'EOF'
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata: { name: ztunnel-demo, namespace: default }
spec:
  selector:
    matchLabels: { app: backend }
  action: ALLOW
  rules:
    - from:
        - source:
            principals: ["cluster.local/ns/default/sa/default", "cluster.local/ns/default/sa/waypoint"]
EOF
authorizationpolicy.security.istio.io/ztunnel-demo created
$ sleep 10
$ istioctl --context kind-mesh ztunnel-config policies | head -6
NAMESPACE    POLICY NAME                   ACTION SCOPE
default      ztunnel-demo                  Allow  WorkloadSelector
istio-system istio_converted_static_strict Deny   WorkloadSelector
$ istioctl --context kind-mesh ztunnel-config workloads | head -6
NAMESPACE          POD NAME                                   ADDRESS     NODE               WAYPOINT PROTOCOL
argo-rollouts      argo-rollouts-88797f77-dtvvz               10.244.1.22 mesh-worker        None     TCP
default            backend-7c644cf968-x8dxk                   10.244.1.33 mesh-worker        None     HBONE
default            client                                     10.244.1.27 mesh-worker        None     HBONE
default            client-65b9d75449-fbtfj                    10.244.1.34 mesh-worker        None     HBONE
default            kubernetes                                 172.18.0.9                     None     TCP
$ kubectl --context kind-mesh -n default exec "$CLIENT" -- curl -s -o /dev/null -m 5 http://backend/
$ sleep 5
$ kubectl --context kind-mesh -n istio-system logs "$ZT" --tail=80 | grep -E 'src.identity' | tail -2
2026-11-18T09:59:21.050701Z	info	access	connection complete	src.addr=10.244.1.34:47784 src.workload="client-65b9d75449-fbtfj" src.namespace="default" src.identity="spiffe://cluster.local/ns/default/sa/default" src.cluster="Kubernetes" dst.addr=10.244.1.35:15008 dst.hbone_addr=10.96.255.23:80 dst.service="backend.default.svc.cluster.local" dst.workload="waypoint-598689dd96-pz7c7" dst.namespace="default" dst.identity="spiffe://cluster.local/ns/default/sa/waypoint" dst.cluster="Kubernetes" direction="outbound" bytes_sent=693 bytes_recv=674 duration="33ms"
2026-11-18T09:59:35.364359Z	info	access	connection complete	src.addr=10.244.1.34:44972 src.workload="client-65b9d75449-fbtfj" src.namespace="default" src.identity="spiffe://cluster.local/ns/default/sa/default" src.cluster="Kubernetes" dst.addr=10.244.1.35:15008 dst.hbone_addr=10.96.255.23:80 dst.service="backend.default.svc.cluster.local" dst.workload="waypoint-598689dd96-pz7c7" dst.namespace="default" dst.identity="spiffe://cluster.local/ns/default/sa/waypoint" dst.cluster="Kubernetes" direction="outbound" bytes_sent=71 bytes_recv=674 duration="6ms"
$ kubectl --context kind-mesh delete authorizationpolicy ztunnel-demo -n default
authorizationpolicy.security.istio.io "ztunnel-demo" deleted from default namespace
verify: each workload carries a cert with identity cluster.local/ns/<ns>/sa/<sa>, and ztunnel's access logs attribute both ends of every connection by identity rather than just IP.

Linkerd models the exact same concept with three resources: a Server selects the port, a MeshTLSAuthentication lists allowed client identities, and an AuthorizationPolicy ties them together. Both Istio and Linkerd sit on the exam's tool list, so know both vocabularies.

This block only applies if you built the mesh cluster with MESH=linkerd make mesh; on the default Istio cluster, it detects that and skips cleanly.

# this lab's mesh cluster runs Istio; the Linkerd objects only apply if you rebuilt it with MESH=linkerd make mesh
if kubectl --context kind-mesh get ns linkerd >/dev/null 2>&1; then
  kubectl --context kind-mesh apply -f - <<'EOF'
apiVersion: policy.linkerd.io/v1beta1
kind: Server
metadata: { name: backend-http, namespace: default }
spec:
  podSelector:
    matchLabels: { app: backend }
  port: 9898
  proxyProtocol: HTTP/1
---
apiVersion: policy.linkerd.io/v1alpha1
kind: MeshTLSAuthentication
metadata: { name: client-identity, namespace: default }
spec:
  identities: ["default.default.serviceaccount.identity.linkerd.cluster.local"]
---
apiVersion: policy.linkerd.io/v1alpha1
kind: AuthorizationPolicy
metadata: { name: backend-from-client, namespace: default }
spec:
  targetRef: { group: policy.linkerd.io, kind: Server, name: backend-http }
  requiredAuthenticationRefs:
    - { group: policy.linkerd.io, kind: MeshTLSAuthentication, name: client-identity }
EOF
  sleep 20
  linkerd viz authz -n default deploy/backend
  kubectl --context kind-mesh -n default get pods -l app=backend
else
  echo 'skipped: kind-mesh runs Istio ambient, not Linkerd'
  echo 'to run this, rebuild the mesh cluster with: MESH=linkerd make mesh'
  kubectl --context kind-mesh get crd -o name | grep -c policy.linkerd.io || echo '0 policy.linkerd.io CRDs present'
fi
outputcaptured 2026-09-13
$ # this lab's mesh cluster runs Istio; the Linkerd objects only apply if you rebuilt it with MESH=linkerd make mesh
$ if kubectl --context kind-mesh get ns linkerd >/dev/null 2>&1; then
$   kubectl --context kind-mesh apply -f - <<'EOF'
apiVersion: policy.linkerd.io/v1beta1
kind: Server
metadata: { name: backend-http, namespace: default }
spec:
  podSelector:
    matchLabels: { app: backend }
  port: 9898
  proxyProtocol: HTTP/1
---
apiVersion: policy.linkerd.io/v1alpha1
kind: MeshTLSAuthentication
metadata: { name: client-identity, namespace: default }
spec:
  identities: ["default.default.serviceaccount.identity.linkerd.cluster.local"]
---
apiVersion: policy.linkerd.io/v1alpha1
kind: AuthorizationPolicy
metadata: { name: backend-from-client, namespace: default }
spec:
  targetRef: { group: policy.linkerd.io, kind: Server, name: backend-http }
  requiredAuthenticationRefs:
    - { group: policy.linkerd.io, kind: MeshTLSAuthentication, name: client-identity }
EOF
$   sleep 20
$   linkerd viz authz -n default deploy/backend
$   kubectl --context kind-mesh -n default get pods -l app=backend
$ else
$   echo 'skipped: kind-mesh runs Istio ambient, not Linkerd'
$   echo 'to run this, rebuild the mesh cluster with: MESH=linkerd make mesh'
$   kubectl --context kind-mesh get crd -o name | grep -c policy.linkerd.io || echo '0 policy.linkerd.io CRDs present'
$ fi
skipped: kind-mesh runs Istio ambient, not Linkerd
to run this, rebuild the mesh cluster with: MESH=linkerd make mesh
0
0 policy.linkerd.io CRDs present
verify: on the default Istio cluster, the script prints skipped: kind-mesh runs Istio ambient, not Linkerd and counts zero policy.linkerd.io CRDs. Read the YAML carefully anyway so you can explain each object cold: Server targets the port and protocol, MeshTLSAuthentication names allowed client identities, and AuthorizationPolicy connects the two. If you do rebuild with MESH=linkerd make mesh, watch how the backend's readiness probe breaks until you explicitly permit unauthenticated kubelet probes too (the classic Linkerd policy gotcha).

SPIRE hands a pod its X.509 certificate straight over a local socket, with zero Secrets and zero tokens in the pod spec. Pulling the URI SAN from that live cert proves the identity is real and tied to the ServiceAccount.

kubectl -n spire exec -i statefulset/spire-server -c spire-server -- /opt/spire/bin/spire-server entry show | head -12
# entries are registered per pod by the controller manager, so the selector is a pod uid, not a namespace
kubectl -n spire exec -i statefulset/spire-server -c spire-server -- /opt/spire/bin/spire-server entry show -spiffeID spiffe://lab.local/ns/default/sa/default
kubectl apply -f - <<'EOF'
apiVersion: v1
kind: Pod
metadata: { name: svid-reader, namespace: default }
spec:
  restartPolicy: Never
  containers:
    - name: c
      image: ghcr.io/spiffe/spire-agent:1.11.1
      # the image is distroless, so there is no shell to exec into: the fetch is the container command
      command: ["/opt/spire/bin/spire-agent", "api", "fetch", "x509", "-socketPath", "/run/spire/sockets/spire-agent.sock"]
      volumeMounts:
        - { name: spiffe-workload-api, mountPath: /run/spire/sockets, readOnly: true }
  volumes:
    - name: spiffe-workload-api
      csi:
        driver: csi.spiffe.io
        readOnly: true
EOF
kubectl wait --for=jsonpath='{.status.phase}'=Succeeded pod/svid-reader --timeout=120s
kubectl logs svid-reader
kubectl delete pod svid-reader
outputcaptured 2026-09-13
$ kubectl -n spire exec -i statefulset/spire-server -c spire-server -- /opt/spire/bin/spire-server entry show | head -12
Found 76 entries
Entry ID                : cnpe.9ba80ec0-eaca-4164-a5b5-206f9c2405a0
SPIFFE ID               : spiffe://lab.local/ns/argo-rollouts/sa/argo-rollouts
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/261f3dcd-f8be-458c-8458-2f845df05537
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:c6077b91-ee0d-43a5-805b-00c1fd9d955e
Hint                    : default

Entry ID                : cnpe.1dba842e-8ad8-43ea-902c-9248fb3032ad
SPIFFE ID               : spiffe://lab.local/ns/argo-rollouts/sa/argo-rollouts
$ # entries are registered per pod by the controller manager, so the selector is a pod uid, not a namespace
$ kubectl -n spire exec -i statefulset/spire-server -c spire-server -- /opt/spire/bin/spire-server entry show -spiffeID spiffe://lab.local/ns/default/sa/default
Found 1 entry
Entry ID                : cnpe.87081ae5-113d-433e-8580-e8efc6813353
SPIFFE ID               : spiffe://lab.local/ns/default/sa/default
Parent ID               : spiffe://lab.local/spire/agent/k8s_psat/cnpe/3071b2eb-e46d-43a2-be5a-76138083dc9d
Revision                : 0
X509-SVID TTL           : default
JWT-SVID TTL            : default
Selector                : k8s:pod-uid:6ccaa6c0-a85f-4ee5-9baf-da9a3ed8310b
Hint                    : default
$ kubectl apply -f - <<'EOF'
apiVersion: v1
kind: Pod
metadata: { name: svid-reader, namespace: default }
spec:
  restartPolicy: Never
  containers:
    - name: c
      image: ghcr.io/spiffe/spire-agent:1.11.1
      # the image is distroless, so there is no shell to exec into: the fetch is the container command
      command: ["/opt/spire/bin/spire-agent", "api", "fetch", "x509", "-socketPath", "/run/spire/sockets/spire-agent.sock"]
      volumeMounts:
        - { name: spiffe-workload-api, mountPath: /run/spire/sockets, readOnly: true }
  volumes:
    - name: spiffe-workload-api
      csi:
        driver: csi.spiffe.io
        readOnly: true
EOF
pod/svid-reader created
$ kubectl wait --for=jsonpath='{.status.phase}'=Succeeded pod/svid-reader --timeout=120s
pod/svid-reader condition met
$ kubectl logs svid-reader
Received 1 svid after 522.18534ms

SPIFFE ID:		spiffe://lab.local/ns/default/sa/default
Hint:			default
SVID Valid After:	2026-09-13 04:07:02 +0000 UTC
SVID Valid Until:	2026-09-13 08:07:12 +0000 UTC
CA #1 Valid After:	2026-09-12 19:26:42 +0000 UTC
CA #1 Valid Until:	2026-09-13 19:26:52 +0000 UTC
$ kubectl delete pod svid-reader
pod "svid-reader" deleted from default namespace
verify: the fetched cert's URI SAN is a spiffe:// ID built from the namespace and ServiceAccount, with not a single static credential anywhere in the pod spec.

Self-check

answer before opening
"We installed a service mesh, so all traffic is encrypted." Correct?

Not yet. By default, Istio runs in PERMISSIVE mode so teams can migrate gradually, meaning plaintext still gets accepted alongside mTLS. You need a PeerAuthentication set to STRICT (mesh-wide, per namespace, or per workload), and you prove it by watching an unmeshed plaintext client get rejected.

Where does a workload's mesh identity come from, and why does that matter to section 5.1?

Straight from its ServiceAccount: spiffe://cluster.local/ns/<ns>/sa/<sa>. That means your RBAC design from 5.1 now doubles as your network authorization boundary (one identity, two enforcement points), and letting unrelated apps share the default SA quietly weakens both.

You need to allow only POST to /orders from one service. What must exist?

An AuthorizationPolicy with an L7 to.operation rule and a waypoint proxy enrolled for the target. ztunnel only speaks L4, so without a waypoint nothing can inspect HTTP methods or paths.

NetworkPolicy or AuthorizationPolicy: when do you use each?

Use both as complementary layers. NetworkPolicy runs in the CNI using pod labels and covers all traffic, including unmeshed workloads. AuthorizationPolicy runs in the mesh using cryptographic certificates, surviving IP churn and crossing cluster boundaries. Together they give you defense in depth: the CNI shrinks the blast radius while the mesh verifies who's actually calling.

Give a scenario where SPIRE beats a mesh.

A pod needs to authenticate to something outside the mesh (a managed database, a partner API, or a legacy VM service) with short-lived credentials and no static secrets. SPIRE delivers an SVID over the local Workload API socket, whereas a mesh only governs traffic between meshed workloads. Bonus: SPIFFE trust bundles federate cleanly across trust domains, extending identity beyond a single cluster.

You add to.operation.paths to an existing ambient AuthorizationPolicy that uses selector, and now every request to the workload fails. Why?

A selector-based policy is enforced by ztunnel at L4, which can't parse HTTP paths. Rather than silently ignoring the L7 clause, Istio fails safe and turns it into a DENY. Move the L7 rule into an AuthorizationPolicy using targetRefs aimed at the Service or waypoint Gateway (making sure the target has istio.io/use-waypoint set), and keep any pure L4 identity check in ztunnel if needed.

A namespace has one ALLOW policy for service A. Service C, with no policy mentioning it, is suddenly refused by every caller. Explain.

Deny-by-default kicks in for a workload the instant any ALLOW policy matches it. If that ALLOW policy omits selector or targetRefs, it applies to every workload in the namespace, unintentionally sweeping up service C and blocking everyone except A's allowed callers. Scope A's policy properly with a selector, or add an explicit ALLOW policy for C.

In Linkerd you create a Server for port 8080 and an AuthorizationPolicy allowing one client identity. Readiness probes start failing. Why, and what do you add?

A Server defaults to accessPolicy: deny, and kubelet probes aren't in the mesh, so they're now rejected as unauthenticated traffic. Add an HTTPRoute matching the probe paths backed by an AuthorizationPolicy referencing a NetworkAuthentication for the node CIDRs (or 0.0.0.0/0), or set accessPolicy: all-unauthenticated if it's a dedicated probe port.

Walk the SPIRE chain from "a pod starts" to "it holds a certificate": which component does what, and where do selectors come from?

First, the node's spire-agent has already attested itself to spire-server (via k8s_psat). When the pod connects to the Workload API socket (mounted via csi.spiffe.io), the agent's k8s workload attestor asks the kubelet which pod owns that calling process and builds selectors (k8s:ns, k8s:sa, labels). The agent matches those selectors against registration entries under its parent ID (manual or generated by a ClusterSPIFFEID), gets spire-server to sign the cert, and streams the X509-SVID plus trust bundle back to the pod, automatically rotating before the 1h TTL expires.

Docs to know your way around

study time, not exam time
  • istio.io: ambient mode overview, PeerAuthentication and AuthorizationPolicy references, and waypoint proxies.
  • spiffe.io: SPIFFE core concepts (ID, SVID, Workload API, trust domain) and spire-server entry syntax.
  • linkerd.io: automatic mTLS overview, handy for quick compare-and-contrast answers.
  • Offline: istioctl ztunnel-config --help, istioctl analyze, and kubectl explain peerauthentication.spec.
  • istio.io/latest/docs/ambient/usage/waypoint (labels, waypoint-for, bypass caveat) and /docs/ambient/usage/l7-features (targeted vs attached policies and fail-safe DENY); /docs/concepts/security for CUSTOM, DENY, ALLOW evaluation order.
  • linkerd.io/2-edge/reference/authorization-policy: Server, AuthorizationPolicy, MeshTLSAuthentication, NetworkAuthentication, and default inbound policy values; /tasks/configuring-per-route-policy for the probe caveat.
  • github.com/spiffe/spire/blob/main/doc/spire_server.md and spire_agent.md (plugins, TTLs, federation), plus github.com/spiffe/spire-controller-manager/blob/main/docs/clusterspiffeid-crd.md for template fields.
free before 5.6make down-meshmake down-spire