Namespaces:

Namespaces are logical compartments for isolating resources (network stack, processes, ...)


When we don't mention a namespace when creating kubernetes objects, they get created in the "default" namespace.

We can display kubernetes namespaces using the below command:


Creating a service in a namespace:

The below Yaml file creates a "clusterIP" service in the namespace "namespace_1":


The service "service_1" will receive the below DNS name:
"service_1.namespace_1.svc.cluster.local"

If we don't mention any namespace, the DNS name will be :
"service_1.default.svc.cluster.local"

Pods and namespaces:

To create a pod in a different namespace "namespace_1" for example, we can mention it in the Yaml configuration file or in the command line, when creating the pod:


We then create the pod using the below command:


Using the command line, we create a "debian" pod in the "namespace_1" namespace:


Creating a namespace:

If for some reason, we want to create a namespace for testing purposes for example, we use a the Yaml file as below:


We create the namespace using the below command:


We can check our namespace using the below command:


Brando Sabatini and Ikbal C ©. Powered by Blogger.