Kubernetes Namespaces

My name is Shyju Krishnan having 10+ Years of experience as an IT infrastructure/Solution Architect
Search for a command to run...

My name is Shyju Krishnan having 10+ Years of experience as an IT infrastructure/Solution Architect
No comments yet. Be the first to comment.
In this series, i will brainstorm basic to advanced topics with examples,with commands,with usecases
What is ReplicaSet ? After reading this post you will be understanding the high level of Kubernetes Replicaset, its advantages of this, and basic kubectl commands related to replicaset If you have not yet checked the previous parts of this series, p...
API (Application Programming Interface) security is critical for protecting sensitive data and maintaining the integrity of systems and applications. APIs are used to connect different systems and applications, and as a result, they can provide a gat...

Well after months of deep slumber, away from social media networks, I had to return to Pune and adapt to hybrid working. I was browsing through meetup.com and was intrigued by one event from AWS user group Pune. It is AWS Reinvent 2022 -Recap on 21st...

Episode 2

Simplify Access Control and Enhance Transparency Over Your ML Projects

Episode 1

After reading this post you will be understanding the high level of Kubernetes namespace and basic kubectl commands related to namespaces.
What is namespace 🤔
In Kubernetes, namespaces provide a mechanism for isolating groups of resources within a single cluster. Names of resources need to be unique within a namespace, but not across namespaces.
Whenever you create a Kubernetes object without specifying a namespace, the object is placed in the Default namespace.
When you set up the cluster for the first time, Kubernetes will deploy the pod & services for the internal management these pods are created under the Kube-system namespaces by default. The purpose of the isolate is to prevent you from accidentally deleting or modifying these services.
kube-node-lease This namespace holds Lease objects associated with each node. Node leases allow the kubelet to send heartbeats so that the control plane can detect node failure.
kube-public this is another default namespace in the Kubernetes,
Kube-system output
coredns-6d4b75cb6d-2vqw4 1/1 Running 1 (6d2h ago) 10d
coredns-6d4b75cb6d-9dlh8 1/1 Running 1 (6d2h ago) 10d
etcd-kubernet-master 1/1 Running 1 (6d2h ago) 10d
kube-apiserver-kubernet-master 1/1 Running 1 (6d2h ago) 10d
kube-controller-manager-kubernet-master 1/1 Running 1 (6d2h ago) 10d
kube-proxy-6drkc 1/1 Running 1 (6d2h ago) 10d
kube-proxy-c5jr7 1/1 Running 1 (6d2h ago) 10d
kube-scheduler-kubernet-master 1/1 Running 1 (6d2h ago) 10d
👌Namespace you can short to ns
If your environment is small you shouldn’t really have to worry about namespaces, you could continue to work in the default namespace.
kubectl get namespace
NAME STATUS AGE
default Active 1d
kube-node-lease Active 1d
kube-public Active 1d
kube-system Active 1d
How to create namespace through manifest file
apiVersion: v1
kind: Namespace
metadata:
name: test
labels:
name: test
kubectl apply -f test.yaml
Create Namespace through CLI
kubectl create namespace test
How to create the container inside the namespace
kubectl run nginx -n test --image=nginx
apiVersion: v1
kind: Pod
metadata:
name: mypod
namespace: test
labels:
name: mypod
spec:
containers:
- name: mypod
image: nginx
If you try to find your Pod, you might notice you can’t!
This is because all commands are run against the currently active Namespace. To find your Pod, you need to use the “namespace” flag.
kubectl get pods --namespace=test
or
kubectl get pod -n test
How to delete the namespace
kubectl delete namespace test
What happens if I delete a namespace?
Deleting the namespace also deletes all the residing components. However, removing all deployments within a namespace does not remove the namespace.
Namespace overview

Refer to this link for more understanding about Namespaces 👉Name sapces
Do you know how to create the Pod? 🤔
Don't worry please refer to this link 👉 Pod Creation
Hope you have got an idea about Kubernetes Namespaces and how we can implement them in our product environments
Happy Learning !!!
Thank you!