✅ What is a Namespace?
A Namespace is a way to divide a Kubernetes cluster into virtual sub-clusters.
Think of it as a folder or workspace inside your cluster where resources (pods, services, deployments, etc.) live.
It does not create separate nodes — it’s just logical separation.
It helps avoid name conflicts and organize resources.
Some namespaces are system-managed, some are user-managed.
[mahesh@devopsvm01 .kube]$ minikube kubectl -- get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default nginx-web-b9c74675f-2gwnv 1/1 Running 0 56m
default nginx-web-b9c74675f-vtvt5 1/1 Running 0 56m
default nginx-web-b9c74675f-w8t8l 1/1 Running 0 31m
kube-system coredns-66bc5c9577-5t9v7 1/1 Running 0 7h48m
kube-system etcd-minikube 1/1 Running 0 7h48m
kube-system kube-apiserver-minikube 1/1 Running 0 7h48m
kube-system kube-controller-manager-minikube 1/1 Running 0 7h48m
kube-system kube-proxy-7flzw 1/1 Running 0 7h48m
kube-system kube-scheduler-minikube 1/1 Running 0 7h48m
kube-system storage-provisioner 1/1 Running 1 (7h47m ago) 7h48m
kubernetes-dashboard dashboard-metrics-scraper-77bf4d6c4c-2drbq 1/1 Running 0 6h12m
kubernetes-dashboard kubernetes-dashboard-855c9754f9-btszn 1/1 Running 0 6h12m
[mahesh@devopsvm01 .kube]$
🔹 Namespaces you are seeing
1️⃣ default
-
All your resources go here if you don’t specify a namespace.
-
Your NGINX deployment is here:
2️⃣ kube-system
-
Used by Kubernetes itself to run core components:
-
kube-apiserver -
kube-controller-manager -
kube-scheduler -
kube-proxy -
coredns
-
-
You usually don’t touch resources here unless debugging the cluster.
3️⃣ kubernetes-dashboard
-
Used by the Kubernetes Dashboard addon.
-
Runs pods like
kubernetes-dashboardanddashboard-metrics-scraper. -
Keeps dashboard-related resources separate from your workloads.
🔹 Why separate namespaces are useful
-
Avoid name conflicts
-
You could have a
nginx-webdeployment in multiple namespaces without clashing.
-
-
Organize teams or projects
-
Example:
-
devnamespace → development pods -
qanamespace → testing pods -
prodnamespace → production pods
-
-
-
Apply resource limits
-
You can set CPU/memory quotas per namespace.
-
-
Access control
-
RBAC (Role-Based Access Control) can restrict users to certain namespaces.
-
🔹 Useful commands
-
List all namespaces:
-
Create a new namespace:
-
Create a pod in a specific namespace:
-
Get pods in a specific namespace:
✅ In short
-
Namespaces = logical partitions of a cluster
-
default= your default workspace -
kube-system= core Kubernetes components -
kubernetes-dashboard= dashboard resources -
Helps with organization, security, and resource management.
nginx-web, in multiple different namespaces within the same Kubernetes cluster without any conflict.🏗️ How to Create the Identical Deployments
The key to creating the identical Deployment names lies in specifying the target Namespace using the --namespace or -n flag with the kubectl command.
1. Create in the production Namespace
First, let's assume you create a new namespace for production, though you can use any name.
minikube kubectl -- create deployment nginx-web --image=nginx --namespace=production
This command creates a resource addressed as: production/nginx-web
2. Create in the testing Namespace
Next, you can create another Deployment using the exact same name but targeting a different namespace, say testing.
minikube kubectl -- create deployment nginx-web --image=nginx --namespace=testing
This command creates a resource addressed as: testing/nginx-web
No comments:
Post a Comment