![]() |
Kubernetes namespaces offer an indispensable instrument for resource organization and isolation in the ever-changing realm of container orchestration. Like distinct districts in a busy metropolis, each namespace in your Kubernetes cluster serves as a dedicated place where you may organize related storage, services, and applications into logical units. What Is Kubernetes Namespace?Kubernetes Namespace is a mechanism that enables you to organize resources. It is like a virtual cluster inside the cluster. A namespace isolates the resources from the resources of other namespaces. For example, You need to have different names for deployments/services in a namespace but you can have the same name for deployment in two different namespaces. Kubernetes Namespace – Read Switching Namespaces Using the kubectl CommandKubernetes namespace provides the isolation for the different types of resources within the cluster you can use the following command to switch the namespace in the Kubernetes cluster,
Steps To Switch NamespaceStep 1: List all the namespaces in Kubernetes. kubectl get namespaces
Step 2: Select the namespace that you want to switch to and want to set it as a default and use the command shown in below. Here I am using “kube-public”. Step 3: Know get the current namespace you are in using the given command below. kubectl config view | grep namespace:
Using the kubectl Command With the –namespace FlagThe namespace for which you wish to perform operations can be specified by using the kubectl command with the –namespace flag. The basic syntax is as follows:
kubectl
[command]
–namespace=<namespace-name>
In the place of command use the command like “get pods”. In the place of “<namespace-name>” in this give the namespace name which you want to perform the command. kubectl get pods --namespace=kube-system
Setting Namespace in Kubernetes Configuration FilesIn some organization they frequently work on some namespace for example “dev-ns”,”prod-ns” and etc in that cases you can set the particular namespace as a default to the cluster for that follow the steps below. Step 1: list all the hidden folder in the kubernetes cluster ls -a use the cd command and change the directory to the “.kube” directory there you can find and file with name config. Step 2: Edit the config file by using the following test in the namespace field contexts: Replace the above with required details.
Change Namespace in Kubernetes – FAQsHow to communicate one namespace to another namespace in Kubernetes?
Can we have two namespace with same name?
|
Reffered: https://www.geeksforgeeks.org
Kubernetes |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |