DevOps Classroom Series – 10/Sept/2021

Resource Management

  • 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

  • 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 Preview
  • 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

Replica Set

  • 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 Preview Preview

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin