Kubernetes explained

Kubernetes Namespaces: What They Do and Do Not Isolate

A Kubernetes namespace is a named scope inside one cluster. Names of most objects only need to be unique inside their namespace, and you can apply quotas and access rules per namespace. A namespace does not create a separate cluster and does not, by itself, stop pods in one namespace from talking to pods in another.

By , Founder at SeaGit

·

Key takeaways

  • Names must be unique within a namespace for a given kind, so two Deployments called api can live in staging and prod.
  • Some objects are cluster-wide and never belong to a namespace: Nodes, PersistentVolumes and StorageClasses, for example.
  • Network and workload isolation between namespaces needs NetworkPolicy and RBAC. The namespace name is only a label.
  • Deleting a namespace deletes everything in it. A namespace stuck in Terminating has its own failure mode.

What a namespace scopes, and what it does not

The concept page says namespaces isolate groups of resources within a single cluster, and that name scoping applies to namespaced objects such as Deployments and Services. It does not apply to cluster-scoped objects. You can see the split on your own cluster with the api-resources command:

bash
# Objects that live inside a namespace
kubectl api-resources --namespaced=true

# Objects that do not: Nodes, PersistentVolumes, Namespaces themselves
kubectl api-resources --namespaced=false
Run both on a real cluster. The list is the authoritative answer for your Kubernetes version.

The same Deployment name can exist in two namespaces without conflict. That is the main reason teams use namespaces: one cluster, several copies of the same app layout.

The four namespaces every cluster starts with

A new cluster has four namespaces. Knowing what each one holds prevents accidents, such as deploying application workloads into kube-system.

NamespaceWhat the official docs say it holds
defaultWhere objects go when you do not name a namespace
kube-node-leaseLease objects, one per node, used for kubelet heartbeats
kube-publicReadable by all clients, reserved mostly for cluster use
kube-systemObjects created by the Kubernetes system, such as the DNS add-on

The default namespace is a convenience for first use. Most teams create their own namespaces for each environment or team and stop using default for real workloads.

Create a namespace and make it your default

A namespace is one command to create. Passing -n on every kubectl call is tedious, so most people set a default namespace on their kubeconfig context. Be careful with this: a context that points at prod makes a bare kubectl delete hit prod.

bash
kubectl create namespace staging

# Make staging the default for the current context
kubectl config set-context --current --namespace=staging

# Confirm which context and namespace kubectl will use
kubectl config view --minify --output 'jsonpath={..namespace}'
The config subcommands act on your kubeconfig, not on the cluster. Check the output before you run a delete.

Decision rule: namespace per environment or per team?

  • One namespace per environment (dev, staging, prod) suits a small team that shares one cluster and wants identical object names across environments.
  • One namespace per team suits larger organisations where each team owns its quota and its access rules.
  • Do not use a namespace to separate untrusted tenants by itself. Add NetworkPolicy, RBAC and quotas, or use separate clusters.

Quotas and access: the controls that make namespaces useful

A namespace is the unit you attach limits to. The official Secrets page points to resource quotas as the way to cap how many Secrets a namespace can hold, which is one example of a per-namespace control. RBAC roles are also scoped to a namespace when you use a Role and RoleBinding instead of a ClusterRole.

  • Use a ResourceQuota to cap CPU, memory and object counts per namespace, so one team cannot starve another.
  • Use a Role and RoleBinding for developers, so their access stops at their namespace.
  • Use a NetworkPolicy to stop traffic between namespaces you want separate. The namespace itself does not block packets.

Deleting a namespace is destructive

Deleting a namespace removes every namespaced object inside it. That includes Deployments, Services, PersistentVolumeClaims and Secrets. Check the contents first:

bash
# What would be removed
kubectl get all,secret,pvc,ingress -n staging

# Then, if you are sure
kubectl delete namespace staging
kubectl get all does not list every kind. Check PersistentVolumes separately if the namespace holds volumes.

A namespace can also stay in Terminating after you delete it, when a finalizer on one of its objects never clears. That is a separate problem with its own fix, covered in the stuck-namespace guide linked below.

Frequently asked questions

Kubernetes Namespaces: What They Do and Do Not Isolate: FAQ

Is a Kubernetes namespace a security boundary?

Not by itself. A namespace scopes names and lets you attach quotas and RBAC. Network isolation needs NetworkPolicy, and workload isolation needs RBAC, pod security settings or separate clusters.

Can two objects have the same name?

Yes, if they are in different namespaces. Names must be unique within a namespace for a given kind. Nodes and PersistentVolumes are cluster-scoped, so their names are unique across the cluster.

What is the difference between a namespace and a cluster?

A cluster is the control plane plus its nodes. A namespace is a scope inside one cluster. Several namespaces share the same nodes and the same API server.

Why is my namespace stuck in Terminating?

Usually a resource with a finalizer that the controller cannot clear. The namespace waits until that object is gone. The stuck-namespace guide shows how to find it.

Sources

Checked 11 October 2026.

  1. Kubernetes: Namespaces — Initial namespaces, name uniqueness per namespace, and the list of cluster-scoped objects such as Nodes and PersistentVolumes.
  2. Kubernetes: Secrets — Resource quotas used to limit the number of Secrets in a namespace.
  3. Kubernetes: kubectl config view — How kubectl reads and merges kubeconfig, which is where the default namespace is stored.

Read next