Zero Trust Networking: Never Trust, Always Verify in Microservices
Apply zero trust principles—workload identity, least-privilege policies, and continuous verification—to secure east-west traffic between your services.
In a traditional perimeter-based security model, everything inside your network is implicitly trusted. Once a service reaches the internal network—whether legitimately or through a compromised container—it can freely talk to any other service. This worked when you had a handful of monolithic apps behind a firewall. In modern microservices architectures, where you might have hundreds of services deployed across multiple clusters, clouds, and availability zones, that assumption is catastrophically dangerous. A single compromised pod becomes a pivot point for lateral movement across your entire system. Zero trust networking inverts this model: every connection must be authenticated, every request must be authorized, and trust is never assumed—only continuously verified.
Workload Identity: Who Is Calling Whom?
The foundation of zero trust is identity. Before you can enforce any policy, every workload needs a cryptographically verifiable identity. SPIFFE (Secure Production Identity Framework for Everyone) is the standard here. Each service gets a SPIFFE Verifiable Identity Document (SVID)—an X.509 certificate encoding a URI like spiffe://cluster.local/ns/payments/sa/checkout-service. The SPIRE agent running on each node automatically rotates these short-lived certificates.
Notice that this code never handles certificate paths, rotation timers, or CAs directly. The SPIRE agent manages all of that. Your application just declares which peer it expects to talk to, and the mTLS handshake enforces it.
Enforcing Authorization Policies with OPA
Authentication (proving who you are) is not authorization (proving what you’re allowed to do). For east-west traffic policies, Open Policy Agent (OPA) is the de facto standard. You embed OPA as a sidecar or call it out-of-process, and it evaluates Rego policies against the request context—caller identity, target resource, HTTP method, even request body fields.
Wire OPA into your Go HTTP middleware so that every inbound request is evaluated before reaching your handler:
Deploying the SPIRE Stack
Getting SPIRE running in Kubernetes involves a server (cluster-wide) and a per-node agent DaemonSet. Here is a minimal but production-oriented Kubernetes manifest for the SPIRE server:
Registering Workload Entries
SPIRE only issues SVIDs to workloads that have been explicitly registered. This is your least-privilege enrollment step—services not registered simply cannot obtain an identity. Use the SPIRE server CLI or its registration API:
Auditing Access in the Database Layer
Zero trust should extend to your data stores. PostgreSQL supports certificate-based client authentication. Map each service’s SPIFFE-derived common name to a database role with the minimum grants required:
Istio as a Zero Trust Data Plane
If you are already running a service mesh, Istio’s AuthorizationPolicy implements zero trust without changing application code. The sidecar proxies handle mTLS and policy evaluation transparently:
Any traffic not matching an explicit ALLOW rule is denied by default—this is the zero trust default-deny posture enforced at the mesh layer, not the application layer.
Zero trust networking is not a product you buy or a single configuration you toggle. It is an operational discipline built on three pillars: every workload has a short-lived, cryptographically verifiable identity; every connection is authenticated via mTLS against that identity; and every request is authorized against an explicit, auditable policy before it reaches business logic. Start by deploying SPIRE to establish workload identity across your cluster, wire OPA into your service middleware for fine-grained authorization, and layer Istio or another mesh on top for defense-in-depth at the infrastructure level. The payoff is not just security—it is also observability, because every denied request gives you a precise, attributable signal about what is trying to reach what, which is invaluable both for incident response and for understanding your actual traffic topology.