Loading

Quipoin Menu

Learn • Practice • Grow

kubernetes / Kubernetes Namespaces
tutorial

Kubernetes Namespaces

Namespaces are a way to divide a Kubernetes cluster into virtual sub‑clusters. They help organize resources, especially when multiple teams or projects use the same cluster.

What Are Namespaces?

A namespace is a scope for names. Resources in different namespaces can have the same name without conflict. For example, you can have a database service in both dev and prod namespaces.

Namespaces provide isolation and organization for cluster resources.

Default Namespaces

When you start a cluster, Kubernetes creates several default namespaces:
  • default: The default namespace for resources with no explicit namespace.
  • kube-system: For system resources (e.g., kube-dns, metrics server).
  • kube-public: Readable by all users, for public resources.
  • kube-node-lease: Holds node lease objects for heartbeat monitoring.
List them:
kubectl get namespaces

Creating a Namespace

Create a namespace with kubectl create namespace my-namespace. Or using YAML:
apiVersion: v1
kind: Namespace
metadata:
name: my-namespace
Apply with kubectl apply -f namespace.yaml.

Working with Namespaces

To create a pod in a specific namespace, use --namespace flag:
kubectl run nginx --image=nginx --namespace=my-namespace
To list resources in a namespace:
kubectl get pods --namespace=my-namespace
You can set a default namespace for all kubectl commands with:
kubectl config set-context --current --namespace=my-namespace

Deleting a Namespace

Deleting a namespace removes all resources inside it:
kubectl delete namespace my-namespace


Two Minute Drill
  • Namespaces isolate resources within a cluster.
  • Default namespaces: default, kube-system, kube-public.
  • Create namespace: kubectl create namespace name.
  • Specify namespace with --namespace or set default with kubectl config set-context.
  • Delete namespace: kubectl delete namespace name.

Need more clarification?

Drop us an email at career@quipoinfotech.com