Create and Manage Namespaces Using Imperative Commands¶
Let's look at the imperative commands that you can use to create and manage kubernetes namespaces.
Step 1: Create a Namespace¶
Let's create a namespace named dev
follows:
Step 2: List Namespaces¶
Resource types are case-insensitive and you can specify the singular, plural, or abbreviated forms.
The following commands produce the same output:
Note
namespace
is abbreviated as ns
.
Step 3: Describe a Namespace¶
# Command template
kubectl describe namespace <namespace-name>
# Actual command
kubectl describe namespace dev
Step 4: Create Kubernetes Resources in a Namespace¶
Let's create a pod in the dev
namespace that we created:
You can either use -n
or --namespace
to specify the namespace where the resource should be created.
Step 5: List Resources in a Namespace¶
Let's list all the pods in the dev
namespace:
Let's start a shell session inside the nginx container to verify if the application in the pod is running as expected:
Get the default nginx page:
Step 6: Delete a Resource in a Namespace¶
Let's delete the nginx
pod in the dev
namespace: