Kubernetes Namespaces
Isolate environments, teams, and workloads within a single cluster using Kubernetes Namespaces and ResourceQuotas.
Kubernetes Namespaces
A Namespace provides a mechanism for isolating groups of resources within a single physical Kubernetes cluster. Namespaces provide scoped naming, RBAC boundaries, and resource quota limits.
1. Default Built-in Namespaces
When a Kubernetes cluster is created, it comes with default namespaces:
default: The default target for objects that don't declare a specific namespace.kube-system: Reserved for control plane and infrastructure components (CoreDNS, kube-proxy, metrics-server).kube-public: Publicly readable cluster status information.kube-node-lease: Holds heartbeat lease objects for node health checking.
2. Working with Namespaces
Create a Namespace
kubectl create namespace staging
kubectl create namespace productionOr Declare in YAML
apiVersion: v1
kind: Namespace
metadata:
name: stagingView Resources in a Specific Namespace
kubectl get pods -n stagingSwitch Your Default Working Namespace Context
kubectl config set-context --current --namespace=staging3. Cross-Namespace Communication
Pods in one namespace can reach Services in another namespace using Fully Qualified Domain Names (FQDN):
# Reaching the PostgreSQL service in the 'database' namespace:
http://postgres.database.svc.cluster.local:54324. Enforcing Limits with ResourceQuota
Prevent a development team or staging namespace from exhausting all cluster CPU or memory:
# quota.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
name: staging-quota
namespace: staging
spec:
hard:
requests.cpu: "4"
requests.memory: 8Gi
limits.cpu: "8"
limits.memory: 16Gi
pods: "20"Kubernetes Secrets & Credential Management
Securely store database passwords, API tokens, TLS certificates, and registry credentials using Kubernetes Secrets.
Kubernetes Ingress & Routing
Configure Layer 7 HTTP/HTTPS traffic routing, domain mapping, TLS termination, and Ingress Controllers (ingress-nginx, Traefik).