1.4 K8s NameSpaces
Kubernetes creates three default namespaces at cluster setup:
- 
default: For general user workloads. 
- 
kube-system: For internal Kubernetes components (like networking, DNS). 
- 
kube-public: For resources accessible to all users. 
- 
While small or learning environments can work within the default namespace, larger or production setups benefit from custom namespaces (e.g., dev, prod) to isolate resources, apply access policies, and manage resource quotas. This helps prevent accidental changes and ensures better organization and control. 
- 
In Kubernetes, resources within the same namespace can communicate using just their names (e.g., a web pod can reach a DB service by using dbservice). To access services across namespaces, use the full DNS format: servicename.namespace.svc.cluster.local (e.g., dbservice.dev.svc.cluster.local). Kubernetes automatically creates these DNS entries, where cluster.local is the default cluster domain and svc indicates itβs a service. 
 

NameSpace Commands (Click to Expand)
| Get Pods in a namespace | |
|---|---|
| Create pods in another namespace | |
|---|---|
Pod Definition with Namespace
Pod Configuration (Click to Expand)
Namespace Definition
Set Another Namespace As Default (Click to Expand)
- But what if we want to switch to the devnamespace permanently, so that we don't have to specify the--namespaceoption anymore?
| Set Default Namespace for kubectl | |
|---|---|
