Skip to content
Kubernetes

Namespaces

Partition a cluster into isolated virtual clusters.

#namespace#isolation#quota

Code

kubernetes
# Create and switch namespaces
kubectl create namespace staging
kubectl config set-context --current --namespace=staging

# List and inspect
kubectl get namespaces
kubectl get pods -A                # all namespaces
kubectl get pods -n staging

# Resource quota in a namespace
apiVersion: v1
kind: ResourceQuota
metadata:
  name: staging-quota
  namespace: staging
spec:
  hard:
    requests.cpu: "4"
    requests.memory: 8Gi
    pods: "20"

# Delete a namespace (removes everything inside)
kubectl delete namespace staging