Kubernetes 101 : Default namespaces, custom namespaces and pods



For organization and also isolation purposes, kubernetes creates during its initial setup its main default namespaces - default, kube-system and kube-public -.

To see these namespace, we use the below command:


When we create a kubernetes object, a pod for example without mentioning any namespace, our pod is created in the default namespace.

The kube-system namespace contains all the resources that make the kubernetes cluster run as we can see below:


The kube-public namespace is accessible by everybody, it is mainly used to house public cluster information, ...

We can create a namespace using a Yaml file as below:


Then we "apply" the Yaml file:


We can check if our namespace was created using the below command:


Now that we have our namespace, we are going to run an "nginx" pod in it using the below command:


To see our pod, we would need to specify the namespace otherwise we will only see the resources in the default namespace:


To avoid mentioning the namespace - namespace_1 - with each command, we could change the default namespace for kubernetes using the below command:

Comments

Leave as a comment:

Archive