Namespace and Service-Level Security
What You'll Learn
You'll learn how to apply security policies at different scopes—mesh-wide, namespace-level, and service-specific—to build a layered defense strategy in your service mesh.
Granular Security Scoping
In a service mesh, security policies can be applied at three distinct levels, much like organizing building security: you have perimeter gates (mesh-wide), floor access controls (namespace-level), and individual office locks (service-specific).
Mesh-Wide Security
This is your baseline security posture—policies that apply to every service across all namespaces. For example, requiring mTLS everywhere or blocking external traffic by default. These policies act as your foundation.
Namespace-Level Security
Within a namespace, you can define security boundaries for groups of related services. This is particularly useful in multi-tenant environments or when separating development, staging, and production workloads. For instance, you might allow all services within the payments namespace to communicate freely while restricting cross-namespace traffic.
Service-Level Security
The most granular scope lets you define precise authorization rules for individual services. You can specify exactly which services can call a particular endpoint, what HTTP methods are allowed, or even which paths are accessible based on caller identity.
Layered Defense Strategy
These scopes work together hierarchically. A request must satisfy mesh-wide policies first, then namespace policies, and finally service-specific rules. This layered approach follows the principle of least privilege—start restrictive at the mesh level, open up carefully at the namespace level, and fine-tune at the service level.
For example, you might enforce mTLS mesh-wide, allow internal traffic within the backend namespace, but restrict your database service to only accept connections from specific authenticated services.
Key Takeaway: Service mesh security policies operate at mesh, namespace, and service scopes, enabling you to build defense-in-depth with progressively granular authorization controls.