Home K8s namespace
Post
Cancel

K8s namespace

K8s default namespaces

kube-system:

  • Do NOT create or modify in kube-system
  • System processes
  • Master and Kubectl processes

kube-public

  • Publicly accessible data

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

  1. Install
1
brew install kubectx
  1. Get list
1
kubens
  1. Switch active namespace
1
kubens my-namespace
This post is licensed under CC BY 4.0 by the author.