Keyboard Shortcuts N Next post
P Previous post
S Save / unsave
R Read aloud
T Toggle theme
/ Focus search
Esc Close panels
🔥
Ready to read...
K8s Architecture Kubernetes Kubernetes: From Zero to Production Module 2 - Cluster Architecture

Namespaces - Organizing Your Kubernetes Cluster

Reviewed & accurate
AI Summary

What You Will Learn

Beginner

  • What namespaces are and why they matter
  • When to use them
  • How to create and switch namespaces

A namespace is a logical partition of a Kubernetes cluster. It groups resources and provides isolation between teams or environments.

Terminalbash
# List namespaces
kubectl get namespaces

# Default namespaces:
# default       - where your resources go by default
# kube-system  - K8s system components
# kube-public  - public resources
# kube-node-lease - node heartbeat data

# Create a namespace
kubectl create namespace my-app

# Run a Pod in a specific namespace
kubectl apply -f pod.yaml -n my-app

# Switch default namespace
kubectl config set-context --current --namespace=my-app
When to use namespaces
Use namespaces for: environments (dev, staging, prod), teams (frontend, backend), or projects. Do NOT use for isolating untrusted tenants - use separate clusters for that.
Use caseNamespace strategy
Dev / Staging / ProdOne namespace per environment
Multiple teamsOne namespace per team
Multiple projectsOne namespace per project
Resource limitsSet quotas per namespace

Practical Exercise

Run: kubectl get namespaces
Create: kubectl create namespace dev
Apply a Pod to dev: kubectl apply -f pod.yaml -n dev
List pods in dev: kubectl get pods -n dev
Switch: kubectl config set-context --current --namespace=dev

Key Takeaways

  • Namespaces partition the cluster logically.
  • Default namespaces: default, kube-system, kube-public.
  • Use for: environments, teams, projects.
  • kubectl apply -n namespace to target a namespace.
  • ResourceQuota: limit CPU/memory per namespace.
Previously: Lesson 08 covered worker nodes.
Today: You learned: Organize cluster resources with namespaces.
Next: Lesson 10 covers kubectl.
Test Your Knowledge
How did you find this?

Comments

Join the discussion! Sign in with your Google or Blogger account, or comment as Anonymous - no account needed. For quick questions, also reach me on Telegram @cytestch.

Comments