- Refer Here for the official docs
- Resource Requests: Minimum Resources
- Resource Limits: Capping Resource Usage
- Refer Here for the changeset containing k8s pod with resource limits
- Labels provide identifying metadata for objects.
- These are fundamental quantities of the k8s object that will be used in grouping viewing and operating
- Label is key value pair
app: nginx appVersion: 1.2.1 qt.com/app-version: 1.2.1
- Lets create a pod
kubectl run nginx --image=nginx:1.21.1 --labels "ver=1,app=nginx" kubectl run nginx2 --image=nginx:1.21.1 --labels "ver=2,app=nginx"
- Lets get the pods
kubectl get pods --show-labels
- Label selectors
kubectl get pods --selector="app in (nginx, httpd)" kubectl get pods --selector="ver in (nginx, httpd)" kubectl get pods --selector="ver in (1,5)" kubectl get pods --selector='app!=nginx' kubectl get pods --selector="ver notin (1,5)" kubectl get pods --selector='!env' # doesnt have label with key env kubectl get pods --selector='env' # has a label env with any value
- Till now we have run individual container as Pods.
- More often we want multiple replicas of our application to be running
- Redundancy: mean failure can be tolerated
- Scale: More requests can be served by your application.
- In ReplicaSets, we can specify the desired state in terms of how many replicas we want and kubernetes will ensure that all the replicas are working
- Refer Here for the replica set sample and Refer Herefor the fix with selector