Namespace Basics
What is a Kubernetes Namespace?
A Kubernetes namespace is a virtual cluster that provides a mechanism for resource isolation and organization within a single physical cluster. It allows you to partition and manage cluster resources more effectively, creating logical boundaries between different teams, projects, or environments.
Key Characteristics of Namespaces
Namespaces offer several important features for cluster management:
Feature |
Description |
Resource Isolation |
Separate resources across different namespaces |
Access Control |
Implement granular access policies |
Resource Quota |
Define resource limits for specific namespaces |
Namespace Architecture
graph TD
A[Kubernetes Cluster] --> B[Default Namespace]
A --> C[kube-system Namespace]
A --> D[Custom Namespaces]
D --> E[Development Namespace]
D --> F[Production Namespace]
Code Example: Namespace Operations
Create a new namespace using kubectl:
## Create a namespace
kubectl create namespace my-project
## Verify namespace creation
kubectl get namespaces
## Create a resource within a specific namespace
kubectl create deployment nginx-deployment \
--image=nginx \
-n my-project
Default Namespaces in Kubernetes
Kubernetes provides several default namespaces:
default
: Standard namespace for resources without explicit namespace
kube-system
: System-level resources and core Kubernetes components
kube-public
: Publicly accessible resources
kube-node-lease
: Node heartbeat information
Resource Naming and Scope
Resources within a namespace must have unique names but can be duplicated across different namespaces. This enables efficient cluster management and logical separation of workloads.