Kubernetes Namespaces: Simplifying Cluster Management
To keep things simpler:
NAMESPACES are a way of dividing a cluster into multiple virtual clusters. Namespaces are a form of soft isolation and enable soft multi-tenancy.
For example, you can create Namespaces for your DEV, TEST and QA environments and apply different quotas and policies to each.
Namespaces are a way for multiple tenants to share the same cluster. For instance, you might divide the production clusters into the following three Namespaces to match your organizational structure, say
finance
hr
corporate-ops
You’d deploy finance apps to the FINANCE NAMESPACES, HR apps to the HR NAMESPACES and Corporate-ops Namespaces. Each Namespace can have its own users, permissions, resource quotas and policies.
Default Namespaces:
Every Kubernetes cluster has a set of pre-created Namespaces.
Run the command:
The DEFAULT Namespace is where new objects go if don’t specify a Namespace creating them.
The KUBE-SYSTEM is where control plane components such as the internal DNS service and the metrics server run.
The KUBE-PUBLIC is for objects that need to be readable to anyone.
The KUBE-NODE-LEASE is used for node heartbeat and managing node leases.
Creating Namespaces:
You can create your own namespaces as well. For example, if you wanted to use the same cluster for both DEVELOPMENT and PRODUCTION environments, but at the same time isolate resources between them, you can create a different Namespace for each of them.
kubectl Commands:
$kubectl create ns hashnode
namespace/hashnode created$kubectl apply -f devops-ns.yml
namespace/devops created$kubectl get ns
To get the list of Namespaces$kubectl delete ns devops
namespace “devops” deleted$kubectl create -f pod-definition.yml --namespace=dev
To create PODS in desired Namespace (here, NS is dev)$kubectl get pods --namespace=dev
To get PODS of a specific Namespace (here, NS is dev)$kubectl get pods --all=namespaces
To get a list of all PODS from all the Namespaces available in the cluster
Let’s connect :
Linkedin: https://www.linkedin.com/in/mohammedzaid-bhatti-33b70322a/
Gmail: bhattizaid123@gmail.com