A Kubernetes namespace separates names and permissions, and by default it blocks 0 network traffic between your teams:

Bottom line

  1. Namespace = a scope for names inside 1 cluster. Two teams can each have a Service called api
  2. It is also where policy attaches. The Kubernetes docs: "A mechanism to attach authorization and policy to a subsection of the cluster"
  3. The walls are sold separately. The docs again: "By default, all pods in a Kubernetes cluster are allowed to communicate with each other"
  4. 4 additions turn a namespace into a boundary. A RoleBinding, a ResourceQuota, a NetworkPolicy and Pod Security labels
  5. Tenants who do not trust each other get separate clusters. AWS: "the cluster is the only construct that provides a strong security boundary"

What to do, by where you are today:

Your situation What I would do
Everything runs in default Create 1 namespace per application and leave default empty
2 or more teams share a cluster 1 namespace per team and application, each with the 4 additions below
Dev, staging and production share a cluster Move production to its own cluster. Namespaces are fine for the rest
You host workloads of customers who do not trust each other A cluster per customer, or a virtual control plane per customer on isolated nodes
A namespace is stuck in Terminating Read its status.conditions before you touch a finalizer

Create a namespace, list them all, and make it your default:

kubectl create namespace shop kubectl get namespaces kubectl config set-context --current --namespace=shop 

Every version, default and quote in this guide comes from the Kubernetes documentation, the Kubernetes source and design documents, the AWS, Google and Microsoft docs and the Helm, Argo CD, Kustomize and Gateway API docs, as read on November 26, 2026 (Kubernetes is at v1.37).

Do several teams share your cluster, and you are not sure what separates them? In a free assessment, a senior engineer reviews your CI/CD, infra, Kubernetes, cloud cost and on-call setup, the namespace boundaries included.

Find your situation:

A namespace is a scope for names and a hook for policy

The docs' definition: "In Kubernetes, namespaces provide a mechanism for isolating groups of resources within a single cluster."

The word "isolating" does a lot of work in that sentence. What you get on day 1 is narrower:

  1. A scope for names. "Names of resources need to be unique within a namespace, but not across namespaces"
  2. A place to attach policy. Permissions, quotas, network rules and Pod security rules are all written per namespace

Namespace = a folder for Kubernetes objects, with a permission system that understands folders.

(Nobody ever called a folder a firewall.)

A namespace holds most of what you deploy. A few kinds live outside every namespace:

Inside a namespace Cluster-scoped (outside every namespace)
Pods, Services, Deployments Nodes
Secrets, ConfigMaps PersistentVolumes, StorageClasses
Roles, RoleBindings, ServiceAccounts ClusterRoles, ClusterRoleBindings
NetworkPolicies, ResourceQuotas, LimitRanges CustomResourceDefinitions (CRDs), admission webhooks
PersistentVolumeClaims Namespaces themselves

What lives inside a Kubernetes namespace: Pods, Services, Deployments, Secrets and Roles are inside it, while Nodes, PersistentVolumes, StorageClasses, ClusterRoles and CRDs are cluster-scoped
The dashed box is the namespace. Everything on the right belongs to the whole cluster.

Ask your own cluster which is which:

kubectl api-resources --namespaced=true kubectl api-resources --namespaced=false 

3 rules about the object itself:

  • Flat: "Namespaces cannot be nested inside one another and each Kubernetes resource can only be in one namespace"
  • Named like a DNS label: at most 63 characters of lowercase letters, digits and -, with a letter or a digit at both ends. The name becomes part of every Service's DNS name
  • No kube- prefix: "it is reserved for Kubernetes system namespaces"

The same namespace as a manifest, for the Git repository:

apiVersion: v1 kind: Namespace metadata: name: shop labels: team: payments 

(The short definition is in the glossary: Kubernetes Namespace.)

Every cluster starts with 4 namespaces

"Kubernetes starts with four initial namespaces":

Namespace What it is for
default So that "you can start using your new cluster without first creating a namespace"
kube-system "The namespace for objects created by the Kubernetes system"
kube-public "Readable by all clients (including those not authenticated)"
kube-node-lease 1 Lease object per node. Every kubelet heartbeat is an update to it

The docs on default: "For a production cluster, consider not using the default namespace."

Why? Because every command without -n lands there until you change your context, and so does every manifest without a namespace.

3 of the 4 cannot be deleted. An admission controller that is on by default "prevents deletion of three system reserved namespaces default, kube-system, kube-public".

On a managed cluster, kube-system belongs to the provider:

  • GKE Autopilot: "doesn't allow deploying workloads in GKE-managed namespaces, such as kube-system"
  • AKS: "We don't recommend deploying your own applications to this namespace"

My rule: your workloads never go in a namespace you did not create.

Create, list, switch and delete a namespace with kubectl

You want to Command
Create one kubectl create namespace shop
Get the YAML without creating it kubectl create namespace shop --dry-run=client -o yaml
List all namespaces kubectl get namespaces
See its labels, quota and limit ranges kubectl describe namespace shop
Run 1 command in it kubectl get pods -n shop
Look across all namespaces kubectl get pods -A
Make it the default of your context kubectl config set-context --current --namespace=shop
Check which namespace you are in `kubectl config view --minify \
Delete it, with everything in it {% raw %}kubectl delete namespace shop

kubectl get namespaces on a new cluster:

NAME STATUS AGE default Active 11d kube-node-lease Active 11d kube-public Active 11d kube-system Active 11d 

STATUS has 2 values: Active and Terminating.

4 things worth knowing about these commands:

  • The default namespace is stored on your laptop. set-context writes it into the context in your kubeconfig. The cluster knows nothing about it
  • -A wins over everything. With --all-namespaces, the "namespace in current context is ignored even if specified with --namespace"
  • A manifest and a flag that disagree = an error. If the YAML says namespace: shop and you pass -n billing, kubectl stops and reports that the namespace of the object "does not match" the one you passed
  • Delete means everything. The docs put it with an exclamation mark: "This deletes everything under the namespace!"

kubectl does not ask first unless you add --interactive.

(More commands like these are in the kubectl cheat sheet.)

Reach a Service in another namespace with service.namespace

Every Service gets a DNS name of this form:

..svc.cluster.local 

What a Pod in namespace test gets when it looks up a Service called data that lives in namespace prod:

The Pod asks for Result
data Nothing. A short name is looked up in the Pod's own namespace
data.prod The Service in prod
data.prod.svc.cluster.local The Service in prod

The short form works because the kubelet writes a search list into each Pod's /etc/resolv.conf: the Pod's own namespace first, then svc.cluster.local, the entry that completes data.prod.

This is also why the same manifest works in every namespace: an app that calls data finds its own namespace's data.

2 warnings from the docs:

  • DNS crosses namespaces by default. "By default, the Kubernetes DNS service allows lookups across all namespaces in the cluster"
  • A namespace named like a top-level domain hijacks lookups. Call a namespace com, and Services in it can take "precedence over public DNS" for every workload in the cluster. The fix in the docs: "limit privileges for creating namespaces to trusted users"

A namespace isolates nothing by default

Create 2 namespaces, deploy into both, and this is what they still share:

Shared by default What the docs say
The network "If no policies exist in a namespace, then all ingress and egress traffic is allowed to and from pods in that namespace"
The nodes and the kernel "Containers are processes running on a shared kernel"
CPU and memory No quota exists until you create one. A single namespace can take the whole cluster
Cluster-scoped objects Namespace isolation "doesn't apply to Kubernetes resources that can't be namespaced, such as Custom Resource Definitions, Storage Classes, and Webhooks"
The list of namespaces AWS: "If a tenant has the ability to view a particular Namespace, it can view all Namespaces within the cluster"

By default a Kubernetes namespace blocks nothing: a Pod in namespace team-a reaches a Pod in namespace team-b, all traffic allowed, on shared nodes and kernel
2 namespaces on day 1: separate names, shared everything else.

The docs say it in 1 sentence: "The namespace isolation model requires configuration of several other Kubernetes resources, networking plugins, and adherence to security best practices to properly isolate tenant workloads."

Kubernetes also "does not have first-class concepts of end users or tenants". A tenant is something you build out of namespaces and policy.

Turn a namespace into a boundary with 4 additions

Addition It decides Without it
RoleBinding Who can act in the namespace Access is granted for the whole cluster or for nothing
ResourceQuota (with a LimitRange) How much it can use 1 team can starve the others
NetworkPolicy Which traffic gets in Every Pod in the cluster can call it
Pod Security labels What a Pod may do on the node A privileged Pod can reach the node

4 additions turn a Kubernetes namespace into a boundary: a RoleBinding (who can act), a ResourceQuota (how much it can use), a NetworkPolicy (which traffic gets in) and Pod Security labels (what a Pod may do)
Each of the 4 is its own object or label, written per namespace.

1. A RoleBinding: who can act

Bind a team's group to the built-in edit role, inside 1 namespace:

apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: payments-edit namespace: shop subjects: - kind: Group name: payments-team apiGroup: rbac.authorization.k8s.io roleRef: kind: ClusterRole name: edit apiGroup: rbac.authorization.k8s.io 

A RoleBinding can point at a ClusterRole, and it then grants those permissions "inside the RoleBinding's namespace" only.

So you define the roles once and reuse them in every namespace. Kubernetes ships 3 for this: admin, edit and view.

Check the result from the team's point of view:

kubectl auth can-i create deployments --as=jane --as-group=payments-team -n shop kubectl auth can-i create deployments --as=jane --as-group=payments-team -n billing 

2 facts decide how many namespaces you need:

  1. Create a Pod = own the namespace. Permission to create workloads "implicitly grants access to many other resources in that namespace, such as Secrets, ConfigMaps, and PersistentVolumes that can be mounted in Pods", plus the API access of every ServiceAccount in it
  2. Edit the Namespace object = change its rules. Whoever can patch a namespace can change its labels, and the labels drive Pod Security and NetworkPolicy selection

The docs' conclusion: "boundaries within a namespace should be considered weak."

(The first fact has its own guide: Kubernetes Secrets. The permission model is in the glossary under Kubernetes RBAC.)

2. A ResourceQuota and a LimitRange: how much it can use

apiVersion: v1 kind: ResourceQuota metadata: name: compute namespace: shop spec: hard: requests.cpu: "8" requests.memory: 16Gi limits.memory: 32Gi pods: "50" 

The surprise comes right after you apply it.

The docs: "If you enforce a resource quota in a namespace for either cpu or memory, you and other clients, must specify either requests or limits for that resource, for every new Pod you submit."

What a team sees the next morning:

  • The Deployment is created without an error
  • Some or all of its Pods never appear
  • The reason sits in the events of the ReplicaSet: the Pod "is forbidden", because of an exceeded quota or a missing request

So a quota ships with a LimitRange, which fills in defaults for containers that set nothing:

apiVersion: v1 kind: LimitRange metadata: name: defaults namespace: shop spec: limits: - type: Container defaultRequest: cpu: 100m memory: 128Mi default: memory: 256Mi 

1 catch: a container that requests more than 256Mi and sets no limit still gets the 256Mi default limit, and that Pod will not run. Keep the default limit above your largest request.

See what is used and what is left:

kubectl describe quota -n shop 

Both apply at admission. Pods that already run are left alone: "Neither contention nor changes to quota will affect already created resources."

(How to pick the numbers is in the requests and limits guide.)

3. A NetworkPolicy: which traffic gets in

The docs' default deny for incoming traffic, 1 per namespace:

apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: default-deny-ingress namespace: shop spec: podSelector: {} policyTypes: - Ingress 

Then allow the namespace to talk to itself, and 1 other namespace to call in:

apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: allow-same-namespace-and-gateway namespace: shop spec: podSelector: {} policyTypes: - Ingress ingress: - from: - podSelector: {} - namespaceSelector: matchLabels: kubernetes.io/metadata.name: gateway 

4 rules that save an afternoon:

  • Your network plugin has to support it. "Creating a NetworkPolicy resource without a controller that implements it will have no effect." No error, no warning
  • A policy selects namespaces by label. Every namespace carries the label kubernetes.io/metadata.name with its own name as the value, set by the control plane, so you always have one to select on
  • The NetworkPolicy API has no cluster-wide default. The default deny is created in each namespace
  • Denying egress also denies DNS. "A default deny-all egress policy also blocks DNS traffic", so add an allow rule for the cluster DNS first

(The object itself is in the glossary: Kubernetes NetworkPolicy.)

4. Pod Security labels: what a Pod may do

Pod Security Admission is built in (stable since Kubernetes v1.25) and is configured with labels on the namespace:

kubectl label --overwrite namespace shop \ pod-security.kubernetes.io/enforce=baseline \ pod-security.kubernetes.io/warn=restricted 
Level The docs' description
privileged "Unrestricted policy"
baseline "Minimally restrictive policy which prevents known privilege escalations"
restricted "Heavily restricted policy, following current Pod hardening best practices"

Same surprise as with quotas: enforce applies to Pods only. A Deployment that breaks the policy is accepted, and its Pods are rejected.

The warn label is what tells the person running kubectl apply.

Almost nothing can be referenced across namespaces

From a namespace, can you use Answer
A Secret or ConfigMap of another namespace in a Pod No. "The Pod and the ConfigMap must be in the same namespace", and the same goes for Secrets
A PersistentVolumeClaim of another namespace No. "Claims must exist in the same namespace as the Pod using the claim"
A Service of another namespace as an Ingress backend No. "The service must exist in the same namespace as the Ingress object"
An owner in another namespace No. "Cross-namespace owner references are disallowed by design"
A Service of another namespace over the network Yes, by DNS name, unless a NetworkPolicy blocks it
A Gateway of another namespace from a Route (Gateway API) Yes, when "the Gateway owner and Route owner both agree"
A backend or Secret of another namespace (Gateway API) Yes, when the owner of the target creates a ReferenceGrant

The pattern: objects reference inside their namespace, and traffic crosses.

So the same Secret in 2 namespaces means 2 copies, or a tool that syncs them.

Slice by team and application, keep environments apart

The docs set the bar for when to start: "For clusters with a few to tens of users, you should not need to create or think about namespaces at all."

I would start earlier, for a boring reason. Moving a running application to another namespace later means recreating every object in it.

How I would slice:

  1. 1 namespace per team and application. payments-api, payments-worker, search-api. Permissions, quotas and network rules then line up with who owns what
  2. Versions of the same software share a namespace. The docs: "use labels to distinguish resources within the same namespace"
  3. Environments get clusters when you can afford it. At least production. A bad upgrade, a broken CRD or a noisy node ignores namespace lines
  4. Platform tools get their own. ingress, monitoring, argocd. Never kube-system

On names, Google's advice is to "avoid tying the environment name (development, staging, and production) to the namespace name and instead use the same name across environments."

I agree: payments-api in the staging cluster and payments-api in the production cluster means 1 set of manifests.

How far it scales, from the Kubernetes scalability thresholds:

Limit Threshold
Namespaces per cluster 10,000
Pods per namespace 3,000
Services per namespace 5,000
Deployments per namespace 2,000

Most of them are soft: crossing one "results in degraded performance" before anything fails.

Your deploy tools each have their own way of handling the namespace:

Tool How it handles the namespace
Helm --namespace picks it. A missing namespace is an error unless you pass --create-namespace
Argo CD CreateNamespace=true as a sync option creates it. managedNamespaceMetadata sets its labels
Kustomize namespace: "will override the existing namespace if it is set on a resource"

A namespace created by a flag has no quota and no policies. I would keep the Namespace manifest in Git next to its 4 additions and let the tools deploy into it.

Namespaces vs clusters: trust decides

The docs describe a spectrum from "soft" multi-tenancy to "hard" multi-tenancy.

Who shares What separates them
Teams of 1 company Namespaces with the 4 additions
Teams that need their own CRDs or cluster-wide settings A virtual control plane per team
Customers, or anyone running code you did not write A cluster per tenant, or a virtual control plane on isolated nodes

What the 3 clouds say about the last row:

  • AWS: "the cluster is the only construct that provides a strong security boundary"
  • Microsoft: "Kubernetes environments aren't entirely safe for hostile multi-tenant usage"
  • Google: "Kubernetes cannot guarantee perfectly secure isolation between tenants"

And what they say about the first row. Microsoft: "Minimize the number of physical AKS clusters you deploy to isolate teams or applications." Google: a tenant per cluster or per project is "harder to manage".

Both are right. Trust = the variable.

A virtual control plane gives each tenant its own API server. Tools like vCluster run it inside a namespace of a host cluster. It isolates the cluster-scoped objects, and it leaves the nodes shared: per-tenant control planes "do not solve isolation problems in the data plane".

2 things changed here recently:

  • The Hierarchical Namespace Controller, the project that gave namespaces a parent and child structure, was archived on April 17, 2025
  • AKS has managed namespaces, which bundle quotas, network policies and access with the namespace. GKE has fleet namespaces and team scopes, which manage access to namespaces across clusters

Fix a namespace stuck in Terminating

Deleting a namespace is asynchronous. What happens after kubectl delete namespace shop:

  1. The API server sets a deletion timestamp, and the phase becomes Terminating
  2. New objects are refused in it
  3. The namespace controller deletes the Pods first, and waits for them (the default order since Kubernetes v1.33, stable since v1.34)
  4. It deletes everything else, resource type by resource type
  5. It removes the kubernetes finalizer from the namespace's spec.finalizers
  6. The namespace is gone

What happens when you delete a Kubernetes namespace: kubectl delete namespace, phase Terminating, Pods are deleted first, everything else is deleted, finalizer removed and namespace gone. Stuck in Terminating means something could not be deleted
A namespace that stays in Terminating is waiting on one of the middle steps.

Stuck in Terminating = the controller could not list or delete something in the namespace.

It tells you why. Read the conditions:

kubectl get namespace shop -o yaml 
Condition in status.conditions What it means What to do
NamespaceDeletionDiscoveryFailure An API group does not answer, so the controller cannot list what to delete Find the broken APIService
NamespaceContentRemaining Objects are still in the namespace List them, find what blocks them
NamespaceFinalizersRemaining Those objects carry finalizers that nothing is removing Bring back the controller that owns the finalizer
NamespaceDeletionContentFailure A delete call failed Read the message, it names the resource

A common cause of the first one is an add-on that was removed while its APIService stayed behind (a metrics adapter, for example):

kubectl get apiservice | grep False 

And for the second, Google's GKE troubleshooting docs give the command that lists what is left:

kubectl api-resources --verbs=list --namespaced -o name \ | xargs -n 1 kubectl get -n shop 

A common cause of the third: you deleted an operator before the custom resources it manages. The resources wait for a controller that no longer exists.

What half the internet tells you to do is empty the finalizers and move on.

The Kubernetes docs: "avoid manually removing finalizers to allow deletion to continue. Finalizers are usually added to resources for a reason."

Google documents the forced route "only as a last resort", because it "could result in resources remaining in your cluster that you can't access".

A load balancer or a disk that nobody can see is still on the invoice.

My order: conditions, then the APIService, then the leftover objects. A finalizer gets removed by hand only after you cleaned up what it was guarding.

The namespace checklist

Always:

  • Nothing of yours runs in default or kube-system
  • Every namespace is a manifest in Git, with an owner label
  • Every namespace has a RoleBinding to a group (a list of people goes stale)
  • Every namespace has a ResourceQuota, and a LimitRange next to it
  • Every namespace has a default deny NetworkPolicy, and your network plugin enforces it
  • Every namespace has a pod-security.kubernetes.io/enforce label
  • Only the platform team can create namespaces or patch them
  • The same application has the same namespace name in every cluster
  • Custom resources are deleted first, their operator last
  • Tenants who do not trust each other share no control plane and no nodes

Kubernetes namespace FAQ

What is a namespace in Kubernetes?

A namespace is a scope for names inside 1 cluster, and the unit that permissions, quotas, network policies and Pod security rules attach to. Object names have to be unique within a namespace, and can repeat across namespaces.

How do I list all namespaces?

With kubectl get namespaces. To list Pods or any other resource across all of them, add -A, as in kubectl get pods -A.

How do I switch the namespace in kubectl?

With kubectl config set-context --current --namespace=NAME. It saves the namespace in your kubeconfig for every later command in that context. For 1 command, pass -n NAME.

What is the difference between a node and a namespace?

A node is a machine that runs Pods. A namespace is a grouping of objects in the API. Nodes belong to no namespace, and the Pods of every namespace run side by side on the same nodes unless you schedule them apart.

What is the difference between a namespace and a cluster?

A cluster has its own API server, nodes and cluster-wide settings. A namespace is a partition inside 1 cluster that shares all 3. Use namespaces for teams that trust each other and clusters for tenants that do not.

Can Pods in different namespaces communicate?

Yes, by default. All Pods in a cluster can reach each other until a NetworkPolicy says otherwise, and a Service in another namespace is reachable as service.namespace.

Does deleting a namespace delete everything in it?

Yes. Every namespaced object in it is deleted, custom resources and PersistentVolumeClaims included. A volume that was provisioned for a claim follows its reclaim policy, and for dynamically provisioned volumes the default is Delete, so the disk goes too.

How many namespaces can a Kubernetes cluster have?

The Kubernetes scalability thresholds put it at 10,000 per cluster. That is a tested threshold on the largest clusters, and Google calls it a theoretical maximum that "many factors" can keep you from reaching.

A Recap!

If you take away 1 thing from this guide, let it be this:

A namespace is where isolation attaches. The isolation is what you add to it.

  1. Namespace = a scope for names, and a hook for policy
  2. By default all Pods can talk to each other, across every namespace
  3. The 4 additions: a RoleBinding, a ResourceQuota, a NetworkPolicy, Pod Security labels
  4. Create a Pod = own the namespace. Split by trust
  5. Stuck in Terminating: read the conditions before you touch a finalizer

You don't NEED anyone for this. The checklist above is the whole job, and every piece of it ships with Kubernetes.

If you would rather have someone who has done it look at your cluster first (yes, I sell DevOps engineers), start with the free assessment.