Creating a namespace in a Kubernetes cluster
Written by
Updated at June 21, 2024
To create a namespace in a Managed Service for Kubernetes cluster:
Management console
kubectl CLI
-
Open Managed Service for Kubernetes in the folder where you want to change the Kubernetes cluster.
-
Select the appropriate cluster from the list.
-
Go to the Namespaces tab.
-
In the top-right corner, click Create.
-
Specify a Name for the namespace. It must be compliant with RFC 1123
:- Length: maximum 63 characters.
- May contain only lowercase Latin letters, numbers, and hyphens.
- Use a letter or number for the first and last characters.
Note
It's not a good idea for the name to begin with
kube-
: this prefix is used by system namespaces. -
Click Add.
Install kubectl
Run the following command:
kubectl create namespace <namespace_name>
The namespace name must comply with RFC 1123
- Length: maximum 63 characters.
- May contain only lowercase Latin letters, numbers, and hyphens.
- Use a letter or number for the first and last characters.
Note
It's not a good idea for the name to begin with kube-
: this prefix is used by system namespaces.