A Kubernetes cluster can have multiple namespaces.
Namespaces are used to separate, manage, and organize resources in the cluster.
When the cluster default namespace is provisioned, it can contain the production pods, services, and Deployments in the cluster.
The control plane, running in the kube-system namespace, contains the core cluster components
List existing namespaces in the cluster
Kubectl get namespaces
A Kubernetes cluster installation is provisioned usually with below four namespaces.

Create a namespace
Kubectl create namespace cricket
Kubectl create namespace boxing

Creating resources in namespace
By default when you create a resource, it is created in ‘default’ namespace.
However, in our scenario here, we will deploy resources in different namespaces.
Lets create a POD
Kubectl create -f https://raw.githubusercontent.com/riyasriy/kubernetesrepo/main/pod1.yaml –namespace=cricket
The configuration file can be a URL or yaml file.
-f flag is used to create an object by using the configuration or manifest file that is passed as argument.
-n can be used to specify namespace instead of ‘–namespace’
Most of kubectl command types can be expressed using shortname.
You can list resources specific to the namespaces by passing argument or simply using ‘-A’ to list every resources in cluster

Lets do another Deployment
A deployment appends a unique suffix to the names of pod replicas to identify them in cluster.

Change context of namespace
A Kubernetes context refers to combination of cluster, current namespace and the user.
Lets try to see how many PODS exist.

We have created resources (POD, deployments) in the cluster earlier but are not listed here. This is because our context is in default namespace and the resources are created in different namespaces.
To check the current context use:
Kubectl config view
To change the context to a different namespace.

The context the modified to namespace ‘cricket’ and we can see the PODS easily when hit the cmdlet to list PODS without specifying namespace details in it.
Cluster Resource in namespace
To check the deployed resources in a namespace
Kubectl api-resources –namespaced=true
To list resources that are not in a namespace
Kubectl api-resources –namespaced=false
Delete namespace
Before deleting a namespace, switch the context to ‘default’ namespace
To delete a namespace
Kubectl delete namespace cricket
Kubectl delete namespace boxing

When you delete a namespace, resources inside the namespaces will get deleted.