π§ Concept 6: Namespace (Resource Isolation + Multi-team π―)




π 1. Core Idea (1-line)
π Namespace = logical partition inside a Kubernetes cluster
π§ 2. Why Namespace Exists (VERY IMPORTANT β οΈ)
Imagine:
-
1 cluster
-
Multiple teams using it
Problems:
β Name conflicts (same pod names)
β Resource chaos
β No isolation
π Namespace solves this
π§© 3. What Namespace Does
-
Separates resources logically
-
Allows same names in different namespaces
-
Enables access control (RBAC)
-
Helps in resource limits
π₯ 4. Real-world Usage
Typical namespaces:
-
devβ development -
stagingβ testing -
prodβ production
π Same app can exist in all 3
π‘ 5. Example
You can have:
pod: my-app (in dev)
pod: my-app (in prod)π No conflict β
βοΈ 6. Default Namespaces (IMPORTANT)
Kubernetes already has:
-
default β if you donβt specify
-
kube-system β system components
-
kube-public β public resources
-
kube-node-lease β node heartbeats
π¦ 7. YAML Example
apiVersion: v1
kind: Namespace
metadata:
name: devβ‘ 8. Commands (CKA π₯)
kubectl get ns
kubectl create namespace dev
kubectl get pods -n dev
kubectl apply -f app.yaml -n devπ§ 9. VERY IMPORTANT: Scope Concept
Namespaced resources:
-
Pods
-
Services
-
Deployments
Cluster-wide resources:
-
Nodes
-
PersistentVolumes
π Not everything is inside namespace β
π₯ 10. Resource Quotas & Limits
You can restrict:
-
CPU
-
Memory
-
Number of pods
π Prevents one team from eating all resources
π₯ 11. Real DevOps Insight
In companies:
-
Each team gets namespace
-
RBAC applied per namespace
-
CI/CD deploys to specific namespace
π Multi-tenant architecture π―
β οΈ 12. Common Mistakes
β βNamespace = separate clusterβ β WRONG
π Itβs inside same cluster
β βNamespace gives security by defaultβ
π Needs RBAC configuration
πΌ 13. Interview Answer
π βNamespace is a logical isolation mechanism in Kubernetes used to divide cluster resources among multiple users or teams.β
π§ 14. Memory Trick
π Cluster = Building π’
π Namespace = Rooms πͺ
π₯ 15. Pro Insight
π Always use namespaces in production
π Never dump everything in default
π Next Step
Bol:
π βnextβ
Then we go to:
π₯ Concept 7: ConfigMap & Secret (Configuration Management π―)