A resource name can be qualified further with a namespace. This is useful when different teams are sharing the same cluster and a naming collision is a possibility. It can act as a virtual barrier between clusters.
In replicated environments, you can utilize the same namespaces and setting policies for specific cluster segments. Namespaces are also necessary for creating roles and ensuring proper access settings in Kubernetes. A request is issued using the namespace API utilizing the defined syscalls to establish a new Kubernetes namespace, and because Kubernetes has admin capabilities, a new namespace is established.
The abilities of a new process assigned to its domain will be specified inside the new namespace. In this tutorial, we will explain the method to build a namespace in Kubernetes.
Pre-requisites
To create a namespace in Kubernetes, you have to install Ubuntu 20.05 Linux system. Inside it, make sure to install a minikube. Without the installation of minikube, you will not be able to run Kubernetes services on Ubuntu.
Method to Create a Namespace in Kubernetes
To create a namespace in Kubernetes, open the command line terminal via the application area or utilize the shortcut key of “Ctrl+Alt+T”. Once the terminal is opened, you have to follow the below steps:
Step 1: Start Minikube
To run Kubernetes services, you have to start the minikube cluster. You have to run the below-specified command in the terminal shell.
This process might take some time. You have to wait to get started with the minikube cluster.
Step 2: Displaying Namespaces
To check out the current namespaces in your system, you have to run the below-listed command.
Default: This is the namespace that every Kubernetes command defaults to, as well as the default location of every Kubernetes resource. The whole cluster exists in ‘default’ until additional namespaces are added.
Kube-system: That is the namespace of Kubernetes systems. It should be prevented when using Kubernetes components.
Kube-public: The term “public resources” is used here. Users are not advised to utilize it. This namespace is primarily for cluster use if some resources should be publicly viewable and readable across the whole cluster.
Step 3: Summary of a Specific Namespace
If you want to check the summary of any specific namespace, run the cited command in the shell.
You can write your desired namespace and get its summary report.
Step 4: Detailed Report of a Specific Namespace
If you want to check the detailed report of any specific namespace, run the cited command in the shell.
You can write your desired namespace and get its detailed report.
Step 5: Create a New Namespace
To create a new namespace. You have to inscribe the below-listed command and execute it.
You can write your desired namespace. We have named it “nginx-demo”. From the output, check that a new namespace has been created effectively.
Step 6: Display Newly Created Namespace
To check out the newly created namespaces in your system, you have to run the below-listed command.
From the output, you can view the newly created namespaces in your system.
Step 7: Delete Namespace
To delete a namespace, you have to write the below-listed command and execute it.
You can write your desired namespace. We have named it “nginx-demo”. From the output, check that the new namespace has been deleted effectively.
Conclusion
This guide teaches you the basic concept of namespace in Kubernetes. Also, you have learned how to check the currently present namespaces in your system. Along with that, we have elaborated on the way to create and delete a new namespace.
Hopefully, you will be able to create and delete a new namespace in your system easily and effectively.