Kubernetes namespaces explained in plain terms: a namespace is a way to divide one cluster into separate virtual clusters, so different teams, environments or applications can share the same infrastructure without getting in each other’s way. If several groups use one cluster, namespaces are the mechanism that keeps their resources organised and their names from colliding. The central question is what a namespace actually does, and the short answer is that it scopes names, access and resource limits: two teams can each have a Deployment called api, each with its own quota and its own permissions, inside the same cluster.
Namespaces are a logical partition, not a physical one. Every namespace draws on the same nodes, the same network and the same control plane; only the organisational layer is separated. That distinction matters, because it tells you what namespaces can and cannot do for security.
Most clusters start simple, with everything running in the default namespace, and grow into namespaces as teams and environments multiply. The sooner you adopt a naming convention for them, the less painful that growth is. Our guide to Kubernetes architecture, control plane and nodes explains the cluster itself if you need the wider picture first.
Key takeaways
- A namespace is a logical partition of one cluster, not a separate cluster.
- Every cluster ships with four namespaces: default, kube-system, kube-public and kube-node-lease.
- Namespaces scope names, RBAC permissions, quotas and limits per team or environment.
- Namespaces are not a hard security boundary: pods in different namespaces share nodes and the network.
- Never run application workloads in kube-system, and never leave everything in default.
What is a Kubernetes namespace?
A namespace is a Kubernetes object that groups related resources and gives them a shared scope. Pods, Services, Deployments, ConfigMaps and Secrets all belong to exactly one namespace, and their names only need to be unique within it. The full identity of an object is its name plus its namespace, which is why two teams can both run a Service called web without conflict.
Some objects are cluster-scoped rather than namespaced. Nodes, PersistentVolumes, StorageClasses, ClusterRoles and namespaces themselves exist at the cluster level and do not belong to any namespace. Forgetting this distinction is a common mistake: a ClusterRole applies across every namespace, while a Role applies only inside one.
Namespaces also give you a boundary to attach policy to. ResourceQuotas cap how much CPU, memory or how many objects a namespace may consume. Roles and RoleBindings grant permissions inside one namespace only. NetworkPolicies can restrict which pods may talk to each other across namespace boundaries. Without namespaces, all of these controls would have to apply to the whole cluster at once.
Best for: separating environments such as dev, staging and production, or separating teams that share a cluster, so each group gets its own names, quotas and access rules.
The four built-in namespaces
Every Kubernetes cluster ships with four namespaces already in place. The default namespace is where resources land when you do not specify one. That is fine for learning, but in a shared cluster it quickly becomes a mess: nobody can tell who owns what, and a single quota or permission change affects everyone.
The kube-system namespace holds the cluster’s own components: the API server, the scheduler, the controller manager and the DNS service. Application workloads do not belong here. Deploying into kube-system pollutes the system namespace and makes it harder to tell platform components from user workloads, so treat it as out of bounds.
The kube-public namespace is readable by all users, including unauthenticated ones, and holds cluster information that is meant to be public. It is rarely used directly by application teams. The kube-node-lease namespace holds Lease objects that track node heartbeats, which the cluster uses to detect when a node has failed. Both are system namespaces you should leave alone.
You can list them at any time with the get namespaces command, which shows each namespace’s name and status. Creating a new one is a single command or a short manifest, and once it exists you can start placing resources inside it.

How namespaces organise teams and environments
The most common pattern is one namespace per environment: dev, staging and production, each holding the same application with different configuration. This keeps the environments clearly separated while letting them share the cluster’s nodes, which is cheaper than running three clusters. Each environment gets its own quota, so a runaway job in dev cannot starve production.
The other common pattern is one namespace per team or per application. A platform team might own a namespace for shared services, while each product team owns one for its own applications. This works well when teams deploy independently, because RBAC can be granted per namespace without giving anyone cluster-wide access.
Many organisations combine the two: a namespace per team per environment, such as payments-dev and payments-prod. That gives the clearest ownership, but it also creates more namespaces to manage. Whatever pattern you choose, write it down as a convention and apply it consistently, because an inconsistent naming scheme is worse than none at all.
Namespaces compared with other isolation options
| Option | Isolation level | Cost | When to use it |
|---|---|---|---|
| One namespace per environment | Logical: names, quotas and RBAC separated | Low: one cluster | Dev, staging and production on shared infrastructure |
| One namespace per team | Logical: names, quotas and RBAC separated | Low: one cluster | Multiple teams sharing a cluster independently |
| Separate clusters | Strong: separate nodes, network and control plane | High: full cluster per environment or team | Strict isolation, compliance or very different needs |
| Virtual clusters | Stronger than namespaces, weaker than clusters | Medium: extra tooling on one cluster | Multi-tenancy with near-cluster isolation |
That limitation surprises people, so it is worth stating plainly. Pods in different namespaces can reach each other over the network unless a NetworkPolicy stops them, they share the same nodes and the same control plane, and a cluster administrator can see everything. Namespaces organise; they do not isolate in the security sense.
Resource quotas and LimitRanges
A namespace on its own does not limit what its workloads consume. Two objects do that work. A ResourceQuota sets hard limits on a namespace’s total consumption: total CPU, total memory, and how many objects of each type may exist. Once the quota is reached, new pods are rejected until something is removed, which protects the rest of the cluster from one greedy tenant.
A LimitRange sets defaults and bounds for individual containers. It gives every container a default request and limit when the pod specification does not set them, and it can enforce a maximum and minimum per container. This matters because a ResourceQuota counts requests, so a pod with no requests at all counts as zero and can consume far more than its fair share.
Use the two together. The LimitRange keeps individual pods from running with no resource requests, and the ResourceQuota keeps the namespace’s total footprint under control even when every pod is well behaved. Apply both to every namespace you create for a team or an environment, and review the quotas as the workload grows.
DNS and cross-namespace communication
Every Service gets a DNS name, and inside a namespace you can reach it by its short name. From another namespace, you need the fully qualified name, which includes the Service name and the namespace. This small detail causes a surprising amount of confusion: a call that works from inside one namespace fails from another, not because of a network problem, but because the short name resolves to nothing at all.
Cross-namespace communication is normal and expected. A frontend in one namespace often talks to a database in another, or to a shared service in a platform namespace. The fully qualified DNS name is the way to do it, and it is stable even as pods come and go. Keep the pattern explicit in your documentation so nobody has to guess which namespace a service lives in.
NetworkPolicies add control on top of this. By default, Kubernetes allows all traffic between pods, including across namespaces. A NetworkPolicy can restrict which pods may connect to a given pod, by namespace, by label or by both.
RBAC and access control per namespace
Role-based access control is where namespaces deliver their clearest value for teams. A Role grants permissions inside one namespace, and a RoleBinding assigns that Role to a user or group within that namespace. A developer can be given full access to the dev namespace and read-only access to staging, all without any cluster-wide permissions.
ClusterRoles and ClusterRoleBindings are the cluster-wide equivalents, and they should be granted sparingly. A ClusterRoleBinding gives its permissions in every namespace, which is a much larger blast radius than most people intend. Prefer namespaced Roles, and reserve cluster-wide access for platform administrators who genuinely need it.
Service accounts follow the same pattern. Each namespace has a default service account, and pods run with it unless you specify another. Create a dedicated service account per application, grant it only the permissions that application needs, and keep it inside the application’s namespace.
Common namespace mistakes
Running everything in the default namespace is the most common mistake, and it is also the easiest to fix. Move workloads into named namespaces as soon as a second team or a second environment appears. Our guide to common Kubernetes problems and practical troubleshooting covers the symptoms that follow when namespaces are left unmanaged.
Deploying into kube-system is the most dangerous mistake. It mixes your workloads with the cluster’s own components, so always check the namespace before applying a manifest, and set a namespace explicitly in every manifest you write.
Forgetting that some resources are cluster-scoped is another regular trap. A PersistentVolume, a StorageClass or a ClusterRole is not contained by a namespace, so a change to one of them affects the whole cluster.
Kubernetes namespace checklist
- Create a named namespace for each team or environment; never leave everything in default.
- Never deploy application workloads into kube-system, kube-public or kube-node-lease.
- Use a consistent naming convention, such as team-environment, and write it down.
- Apply a ResourceQuota to every team or environment namespace.
- Add a LimitRange so containers without requests still get sensible defaults.
- Grant access with namespaced Roles and RoleBindings, not ClusterRoleBindings.
- Give each application its own service account inside its own namespace.
- Use fully qualified DNS names for Services in other namespaces.
- Add NetworkPolicies where the cluster supports them, to express intended traffic.
- Audit namespaces regularly and delete ones that no longer have an owner.
Frequently asked questions
What is a Kubernetes namespace?
A namespace is a logical partition inside one cluster. It scopes the names of objects such as pods and Services, and it is the boundary for RBAC permissions, resource quotas and limits. Namespaces let teams and environments share a cluster without colliding.
How many namespaces does a cluster have by default?
Four: default, kube-system, kube-public and kube-node-lease. The default namespace holds resources created without a namespace, kube-system holds cluster components, kube-public holds publicly readable information, and kube-node-lease holds node heartbeat data.
Can two namespaces have a pod with the same name?
Yes. Names only need to be unique within a namespace, because an object’s full identity is its name plus its namespace. That is one of the main reasons namespaces exist: teams can use the same names independently.
Do namespaces isolate pods from each other?
Only partly. Namespaces separate names, permissions and quotas, but pods in different namespaces share the same nodes and the same network, and can reach each other unless a NetworkPolicy blocks them. For strong isolation, use separate clusters.
How do I switch to a different namespace?
Pass the namespace flag on each command, or set it as the default for your current context so every command uses it. Setting the context default saves typing and prevents accidental deployments into the wrong namespace.







