Kubernetes Namespace scoping¶
Kubernetes namespace scoping refers to the logical partitioning of cluster resources, which isolates resources and objects (such as Pods, Services, and Deployments) from one another.^[400-devops__06-Kubernetes__k8s-ithelp__Day11__README.md]
A single Kubernetes cluster can host multiple namespaces.^[400-devops__06-Kubernetes__k8s-ithelp__Day11__README.md] By default, if a namespace is not explicitly specified in a command or configuration, kubectl targets the default namespace for all operations.^[400-devops__06-Kubernetes__k8s-ithelp__Day11__README.md]
Operations and Scope¶
Namespaces function as a scope for names, meaning resource names must be unique within a namespace but can be duplicated across different namespaces.^[400-devops__06-Kubernetes__k8s-ithelp__Day11__README.md] While standard resource retrieval commands (like get pods) only display items in the current (or default) namespace, users can query across all namespaces using specific flags.^[400-devops__06-Kubernetes__k8s-ithelp__Day11__README.md]
Examples¶
To list all Pods across all namespaces, the following command is used^[400-devops__06-Kubernetes__k8s-ithelp__Day11__README.md]:
[kubectl](<./kubectl.md>) get po --all-namespaces
To retrieve a list of all available namespaces within the cluster^[400-devops__06-Kubernetes__k8s-ithelp__Day11__README.md]:
[kubectl](<./kubectl.md>) get namespace
Related Concepts¶
- Kubernetes
- kubectl
- [[Cluster]]
Sources¶
^[400-devops__06-Kubernetes__k8s-ithelp__Day11__README.md]