K8s by Example: Namespaces
| Namespaces partition a cluster into virtual sub-clusters. They provide scope for names and are the basis for resource quotas and RBAC policies. |
| namespace.yaml | |
| A Namespace is a core Kubernetes resource ( | |
| The | |
| Labels help organize and select namespaces. Common patterns: environment, team, cost-center. | |
| terminal | |
| Built-in namespaces: | |
| terminal | |
| Create a namespace imperatively with | |
| terminal | |
| Set a default namespace for your current context to avoid typing | |
| terminal | |
| Verify your current namespace setting. | |
| pod.yaml | |
| Within the same namespace, reference services by name only. Kubernetes DNS resolves it automatically. | |
| Cross-namespace references use | |
| Full FQDN includes | |
| resourcequota.yaml | |
| ResourceQuotas limit total resource consumption per namespace. Prevents one team from consuming all cluster resources. | |
|
| |
| limitrange.yaml | |
| LimitRanges set default and max/min resource limits per container. | |
|
| |
|
| |
| terminal | |
| Some resources are cluster-scoped: Nodes, PersistentVolumes, ClusterRoles, Namespaces. | |
| terminal | |
| Most workload resources are namespaced: Pods, Services, Deployments, ConfigMaps. | |
| terminal | |
| Apply resources to a specific namespace with | |
| terminal | |
| View pods across all namespaces with | |
| terminal | |
| Warning: deleting a namespace deletes ALL resources within it. No undo. | |