Interview Prep/Kubernetes/Architecture & Control Plane

What is a namespace and what does it isolate?

BeginnerConceptArchitecture & Control Plane
Answer

Short answer

A namespace is a way to divide one Kubernetes cluster into separate logical sections, for example one per team or environment. It separates object names, access permissions (RBAC) and resource limits (quotas) — but by default it does not block network traffic between namespaces.

Explained in simple words

Think of a big office building (the cluster) with different floors (namespaces) for different departments. Each floor can have its own room called "Meeting Room 1" without confusion, and you can give people a key card only for their floor. But unless you lock the stairs (NetworkPolicy), people can still walk between floors.

What a namespace separates — and what it doesn't

Separated by namespace Not separated by default
Object names (two web Deployments in different namespaces are fine) Network traffic — Pods can talk across namespaces
RBAC permissions (a team can only manage its namespace) Nodes — Pods from all namespaces share the same nodes
ResourceQuotas (CPU and memory limits per team) Cluster-wide objects like Nodes, PersistentVolumes, StorageClasses

Example

kubectl create namespace payments
kubectl apply -f deploy.yaml -n payments
kubectl get pods -n payments
kubectl get pods -A                          # all namespaces

kubectl config set-context --current --namespace=payments   # make it your default

Default namespaces you'll see in every cluster: default, kube-system (system components), kube-public and kube-node-lease.

A Pod in namespace frontend reaches a Service in namespace payments using its full DNS name:

curl http://api.payments.svc.cluster.local

What to say in the interview

"A namespace is a logical partition inside a cluster. It scopes object names, RBAC permissions, ResourceQuotas and NetworkPolicies, so teams or environments can share a cluster without stepping on each other. But namespaces are not a network or security boundary by default — Pods can still talk across namespaces unless we add NetworkPolicies. Cluster-scoped objects like Nodes and PersistentVolumes don't belong to any namespace."

Follow-up questions you may get

  • How do you stop Pods in different namespaces from talking? Apply a default-deny NetworkPolicy in each namespace and allow only the traffic you need.
  • Should you use namespaces or separate clusters for prod and dev? Most companies use separate clusters for production, because namespaces share nodes and the control plane.
All Kubernetes questions Roadmap: Kubernetes core

More on Architecture & Control Plane