Namespaces Flashcards
What is a namespace
A mechanism for isolating groups of resources within a single cluster
What are the four automatically generated namespaces
- default
- kube-system
- kube-public
- kube-node-lease
What does the kube-system namespace for
Made for objects created by the Kubernetes system
What does the kube-public namespace for
- reserved for cluster usage in case some resources need to be public
What does the kube-node-lease namespace for
- holds Lease objects associated with each node
What is a K8s Lease
- leases allow the kubelet to send heartbeats so that the control plane can detect node failure
Explain an example of different namespaces
- The same cluster has different namespaces for dev and prod
- Namespaces have their own policy
- Namespaces have a quota of the nodes in a cluster
How do resources within the same namespace refer to each other?
By their resource name (e.g. web-prod, db-service)
How do resources communicate with other resources in another namespace
Using DNS.
service-name.namespace.svc.cluster.local
How to list all pods in a namespace
$ k get pods –all-namespaces
How to list pods in a specific namespace
$ k get pods –n=<namespace></namespace>
How to create pod in a namespace
k create -f pod-definition.yaml –ns=dev
How to create a namespace
$ k create namespace <name></name>
How to get cluster IP, external IP, or ports about services in a namespace
k get svc -n=<namespace></namespace>