Setup
First of all, start the cluster (minikube)
$ minikube start
and set k as an alias to kubectl so that we’ve to type less.
$ alias k="kubectl"
Let’s check all the namespaces the cluster has
$ k get ns
(ns is shorthand for namespace)
As we can see the cluster has 4 namespaces that come out of the box in a Kubernetes cluster.
How To Use Kubernetes Namespaces?
Because it is very easy for a team to accidentally overwrite or disrupt another service without even realizing it and Kubernetes Namespaces allows us to share the cluster with multiple teams or projects without impacting others’ work. They are logically separated from each other and within a namespace, you can’t create any two resources of the same name but you can create the same resource in a different namespace. While most types of resources are namespace, a few aren’t, for example, the Node resource which is global and not tied to a single namespace.
To follow this tutorial you need a working cluster it can be minikube, kind, or any other managed Kubernetes service like EKS, GKE, AKS, etc. For the sake of simplicity, I’m using a minikube cluster.