Kubernetes Namespaces
Organize cluster resources with namespaces, understand built-in namespaces, and apply quotas and limits for multi-team environments.
What Are Namespaces?
Namespaces are a way to divide cluster resources into logical spaces. They help separate teams, environments, or applications.
Built-in Namespaces
| Namespace | Purpose |
|---|---|
default | General-purpose namespace if you do not specify one |
kube-system | Core Kubernetes system components |
kube-public | Publicly readable cluster information in some setups |
kube-node-lease | Node heartbeat lease objects |
Create a Namespace
kubectl create namespace dev
Namespace YAML with ResourceQuota
apiVersion: v1
kind: Namespace
metadata:
name: team-a
---
apiVersion: v1
kind: ResourceQuota
metadata:
name: team-a-quota
namespace: team-a
spec:
hard:
requests.cpu: "4"
requests.memory: 8Gi
limits.cpu: "8"
limits.memory: 16Gi
pods: "20"
Scope Commands with -n
kubectl get pods -n team-a
kubectl get services -n kube-system
Cross-Namespace DNS
A service in another namespace can be addressed by a fuller DNS name such as:
api.team-a.svc.cluster.local
LimitRange Mention
A LimitRange can set default resource requests and limits inside a namespace, helping keep workloads predictable.
When to Use Multiple Namespaces
Use multiple namespaces when you want:
- separation between teams
- environment boundaries such as dev and prod
- quota and policy isolation
- simpler RBAC scoping
Namespaces are like departments inside the same company building. Everyone shares the building, but rooms, budgets, and permissions can differ.
Built-in Namespace
Which built-in namespace commonly holds core Kubernetes system components?
Quota Purpose
Why would you use a ResourceQuota in a namespace?