Namespace
Namespaces provide a mechanism for isolating groups of resources within a single cluster. Names of resources need to be unique within a namespace, but not across namespaces. Namespace-based scoping is applicable only for namespaced objects (e.g. Deployments
, Services
, Pods
, etc.) and not for cluster-wide objects (e.g. StorageClass
, Nodes
, PersistentVolumes
, etc.).
By default, a Kubernetes cluster will instantiate a default namespace when provisioning the cluster to hold the default set of Pods, Services, and Deployments used by the cluster.
Create
To create new namespace we can use kubectl create
command or using yaml file definition.
Lets try to create new namespace using command.
We can get list of namespace using kubectl get
command.
To delete a namespace we can use kubectl delete
command.
Now lets try to create namespace using yaml file definition. This method is preferred if you want to use infrastructure as a code (IaC).
Create new file namespace.yaml
and put this namespace definition below. This will create a new namespace named limited
.
Lets apply using kubectl apply
and get the name space again.
References
Last updated