K8s default namespaces
kube-system:
- Do NOT create or modify in kube-system
- System processes
- Master and Kubectl processes
kube-public
kube-node-lease
- Heartbeats of nodes, availability of a node
default
- Resources/Components will be created within this namespace if we do not set namespace when creating
1
| kubectl create namespace my-namespace
|
Use cases
- Structure your components
- Avoid conflict between teams (order, payment, inventory,…)
- Share services between different environments (database, ELK stack, monitoring,…)
- Access and Resource Limits on Namespaces Level
Persistent volumes, node can’t be created within a Namespace
1
| kubectl api-resources --namespaced=false
|
Create component within a Namespace
1
| kubectl apply -f my-service.yaml --namespace=my-namespace
|
or but it in .yaml file itself (recommended)
1
2
3
4
| apiVersion: v1
kind: Service
metadata:
namespace: my-namespace
|
Change active namespace with kubens
- Install
- Get list
- Switch active namespace