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

NamespacePurpose
defaultGeneral-purpose namespace if you do not specify one
kube-systemCore Kubernetes system components
kube-publicPublicly readable cluster information in some setups
kube-node-leaseNode 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.

Exercise

Built-in Namespace

Which built-in namespace commonly holds core Kubernetes system components?

Exercise

Quota Purpose

Why would you use a ResourceQuota in a namespace?

Continue Learning

Explore Related Topics

Try the Tool

Related Resources