Kubernetes 101 : Namespaces and labels



Namespaces is a way to partition the kubernetes cluster into different separated compartments.
When we create a kubernetes object ( pod, deployment, ... ), it gets created in the default namespace.

To display the namespaces in the cluster, we use the below command - we can see the default namespace there -:


We can create a kubernetes object in a certain namespace, either by mentioning it in the YAML file of the object we want to create, or in the command line as below - creates and runs a debian pod -:


We can create a namespace using the below YAML configuration file for example:


We display our namespaces along with their respective labels using the below command:


We can set the default namespace - where an object is created if no namespace is mentioned in our current kubernetes context using the below command:


Comments

Leave as a comment:

Archive