📌 Namespaces in Kubernetes
🔹 What are Namespaces in Kubernetes? ⇒
In Kubernetes, Namespaces provide a way to logically divide cluster resources among multiple users, teams, or applications. They help in managing a shared cluster efficiently by isolating resources, enforcing policies, and preventing conflicts in naming.
- You can name your object, but if many are using the cluster then it would be difficult for managing.
- A namespace is a group of related elements that each have a unique name or identifier. Namespace is used to uniquely identify one or more names from other similar names of different objects, groups or the namespace in general.
- Kubernetes namespaces help different projects, teams or customers to share a kubernetes cluster & provides:
- A scope for every names
- A mechanism to attach authorization and policy to a subsection of the cluster
- By default, a kubernetes cluster will instantiate a default namespace when provisioning the cluster to hold the default set of pods, services and deployments used by the cluster
- We can use resource quota on specifying how many resources each namespace can use.
- Most kubernetes resources (e.g. pods, services, replication controllers and others) are in same namespace and low-level resources such as nodes and persistent volumes, are not in any namespace.
- Namespace are intended for use in environments with many users spread across multiple teams, or projects for cluster with a few to tens of users, you should not need to create or think about namespaces and all.
📝 Key Features of Namespaces ⇒
✅ Logical Grouping → Helps organize related resources within a Kubernetes cluster.
✅ Name Isolation → Allows different projects to use the same resource names without conflicts.
✅ Access Control → Enables authorization and policies to be applied at the Namespace level.
✅ Resource Management → Supports Resource Quotas, limiting CPU, memory, and storage usage.
✅ Predefined Default Namespace → When a Kubernetes cluster is created, it includes a default Namespace that holds essential Pods, Services, and Deployments.
⚡ Namespaces vs Non-Namespace Resources ⇒
Namespace Resources |
Non-Namespace Resources |
Pods, Services, Deployments |
Nodes, PersistentVolumes |
ConfigMaps, Secrets |
StorageClasses |
ReplicaSets, StatefulSets |
ClusterRoles, ClusterRoleBindings |