Kubernetes Namespace Usage Guidelines
Kubernetes Namespace Usage Guidelines explain best practices for organizing resources, ensuring isolation, and improving manageability in Kubernetes environments.
Kubernetes Namespace Usage Guidelines are the practical conventions for deciding how many namespaces to create and what determines their boundaries, covering the trade-offs between organizing by environment, by team, or by application, why the default namespace should generally be avoided for real workloads, and the important caveat that a namespace alone is not a security boundary without additional, deliberately configured controls.
Organizing By Environment vs. By Team vs. By Application
Environment-Based Namespaces
production
staging
development
Namespacing by environment keeps environment-specific RBAC, resource quotas, and network policies cleanly separated, appropriate when a single team owns an application across its full environment lifecycle and environment isolation is the primary organizational concern.
Team-Based Namespaces
team-payments
team-checkout
team-platform
Namespacing by team instead gives each team a consistent RBAC and quota boundary regardless of environment, appropriate in larger organizations where multiple teams share a single cluster and access control by ownership matters more than access control by environment; this pattern commonly combines with environment suffixes (team-payments-prod) when both dimensions matter simultaneously.
Application-Based Namespaces
myapp
myapp-workers
Namespacing by application, one namespace per distinct application regardless of team or environment, suits clusters dedicated to a single environment already (a per-environment cluster architecture) where the remaining organizational question is separating distinct applications from each other rather than separating environments within the same cluster.
Avoiding the default Namespace for Real Workloads
Why default Is a Poor Home for Production Resources
kubectl get pods -n default
The default namespace exists automatically and requires no explicit creation, which makes it an easy but poor choice for real workloads: it carries no inherent RBAC scoping, no dedicated resource quota, and its shared, catch-all nature means unrelated resources from different purposes tend to accumulate there without a clear ownership boundary; reserving default for nothing more than quick, disposable testing and creating purpose-specific namespaces for anything intended to persist avoids this drift.
Right-Sizing Namespace Count
Too Few Namespaces: Excessive Blast Radius
A cluster with only one or two namespaces for dozens of unrelated applications means a single overly broad RoleBinding, NetworkPolicy misconfiguration, or ResourceQuota exhaustion event affects far more of the cluster's workloads than necessary, since the namespace boundary that would otherwise contain the impact does not exist at a granularity fine enough to matter.
Too Many Namespaces: Coordination Overhead
Conversely, creating a new namespace per microservice or per minor variation multiplies the number of RBAC bindings, quotas, and network policies that must be independently maintained, and cross-namespace communication (which requires more explicit Service DNS references and network policy allowances than same-namespace communication) becomes the common case rather than the exception, adding operational overhead without a corresponding isolation benefit.
Namespace as a Boundary, Not a Complete Security Control
What a Namespace Alone Does Not Provide
A namespace by itself provides no network isolation, pods in different namespaces can communicate freely by default unless NetworkPolicy resources explicitly restrict it, and it provides no automatic RBAC restriction beyond what explicit RoleBindings within it grant; treating namespace separation as sufficient isolation on its own, without also applying network policies, resource quotas, and Pod Security Admission labels, leaves gaps that a namespace boundary alone was never designed to close.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-ingress
namespace: team-payments
spec:
podSelector: {}
policyTypes: ["Ingress"]
apiVersion: v1
kind: Namespace
metadata:
name: team-payments
labels:
pod-security.kubernetes.io/enforce: restricted
Namespace Lifecycle and Cleanup
Deleting a Namespace Cascades
kubectl delete namespace team-old-project
Deleting a namespace deletes every resource within it, without any of the finer-grained confirmation a single resource deletion might warrant, making namespace deletion an operation that deserves the same explicit inventory-check discipline recommended before deleting a CRD; verifying what a namespace actually contains before deleting it avoids inadvertently destroying resources someone else assumed were safely isolated but still in active use.
kubectl get all,pvc,secrets -n team-old-project
Relationship to Best Practices Scope and Reliability and Availability
Namespace usage guidelines are a foundational best practice operating within the scope established for this knowledge area, and the boundaries chosen here directly determine the effectiveness of resource governance mechanisms, ResourceQuota and LimitRange, already covered under reliability and availability: a namespace strategy that does not align with actual isolation needs undermines those quota mechanisms regardless of how carefully the quotas themselves are configured.