Kubernetes interview question · Most asked
What are Kubernetes namespaces, when should you create them, and what isolation do they provide?
Definition Asked in DevOps Engineer · Site Reliability Engineer (SRE) · Cloud Engineer interviews
Summary
Namespaces partition a cluster into virtual sub-clusters that scope names, RBAC policies, resource quotas and network policies. They isolate teams and environments logically but do not isolate workloads at the network or node level by themselves.
Longer Answer
Every object in Kubernetes lives in a namespace (except cluster-scoped objects like
Nodes, PersistentVolumes and ClusterRoles). The default namespace exists out of the
box, but production clusters create additional namespaces for:
- Team or service boundaries:
team-payments,team-search— each team gets its own RBAC bindings and resource quotas. - Environment separation in a shared cluster:
staging,production— though separate clusters are safer for true production isolation. - System workloads:
kube-system,monitoring,ingress— keep platform components separate from application workloads.
What namespaces isolate:
- Names: two Deployments can both be called
apiif they're in different namespaces. - RBAC: a RoleBinding scoped to a namespace limits who can read or write its resources.
- ResourceQuota / LimitRange: caps CPU, memory and object counts per namespace.
- NetworkPolicy: rules are namespace-scoped, so a default-deny policy in one namespace doesn't affect another.
What they don't isolate:
- Network by default: pods in different namespaces can still reach each other unless NetworkPolicies deny it.
- Nodes: pods from any namespace can land on any node unless you add taints or node affinity.
- Cluster-scoped resources: ClusterRoles, PVs, Nodes and CRDs are shared.
A common anti-pattern is creating one namespace per microservice — this adds operational overhead without meaningful isolation. Group by team or bounded context instead.
Key Points
- Namespaces scope names, RBAC, quotas and network policies within a cluster
- They do not isolate network traffic by default — NetworkPolicies are needed for that
- Create them per team or bounded context, not per microservice
- Cluster-scoped resources (Nodes, PVs, ClusterRoles) are shared across all namespaces
Explanation
What interviewers look for
Look for understanding of what namespaces do and don't isolate. Weak answers treat namespaces as full security boundaries. Strong answers mention that network isolation requires NetworkPolicies and that node isolation needs taints/affinity.
More Kubernetes questions
- How does the scheduler place pods? Explain resource requests, node affinity, taints and tolerations.
- How do you make pods shut down gracefully without dropping requests?
- Write a Kubernetes Deployment and Service for a web API with probes, resource requests and a rolling update strategy.
- Deployment, StatefulSet, DaemonSet, Job and CronJob: when do you use each?
- Describe the Kubernetes architecture: what runs on the control plane and what runs on the nodes?
- What is the difference between resource requests and limits, and what are the QoS classes?
- What happens, step by step, when you run kubectl apply for a Deployment?
- A pod is in CrashLoopBackOff. How do you debug it?