What are Kubernetes namespaces?
Why Interviewers Ask This
Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Kubernetes (K8s) basics — a prerequisite for any developer role.
Answer
Namespaces provide logical isolation within a Kubernetes cluster — dividing cluster resources between multiple users, teams, or applications. Objects in different namespaces can have the same name without conflict. Default namespaces: default — resources without a specified namespace; kube-system — Kubernetes system components (kube-dns, kube-proxy, dashboard); kube-public — publicly readable by all users; kube-node-lease — node heartbeat objects. Creating a namespace: kubectl create namespace development kubectl apply -f namespace.yaml. Working with namespaces: kubectl get pods -n development kubectl apply -f deployment.yaml -n development kubectl config set-context --current --namespace=development # set default namespace. Resource quotas per namespace: apiVersion: v1 kind: ResourceQuota metadata: name: dev-quota namespace: development spec: hard: pods: "20" requests.cpu: "4" requests.memory: 8Gi limits.cpu: "8" limits.memory: 16Gi services.loadbalancers: "2". LimitRange: set default resource requests/limits for pods in a namespace — prevents unbounded resource consumption. Network policies: by default, all pods can communicate across namespaces. Network policies restrict this: "pods in namespace A can only communicate with pods in namespace B on port 443." RBAC per namespace: Role (namespaced) and RoleBinding — grant permissions within a specific namespace. ClusterRole/ClusterRoleBinding for cluster-wide access. When to use: environment separation (dev/staging/prod in same cluster), team isolation, multi-tenant clusters.
Pro Tip
This topic has Kubernetes (K8s)-specific nuances that differ from general programming. Highlighting those nuances in your answer shows expertise rather than generic knowledge.