Kubernetes - liveness and Readiness

  You want to make sure that if the applications running inside some of your pods get into a broken state, Kubernetes restarts the pods automatically.


#Example of linveness

apiVersion: apps/v1

kind: Deployment

metadata:

  creationTimestamp: null

  labels:

    app: podliveness

  name: podliveness

spec:

  replicas: 1

  selector:

    matchLabels:

      app: podliveness

  strategy: {}

  template:

    metadata:

      labels:

        app: podliveness

    spec:

      containers:

      - image: busybox

        name: busybox

        args:

         - /bin/sh

         - -c

         - touch webapp; sleep 20; rm -f webapp; sleep 600

        livenessProbe:

         exec:

          command:

            - cat

            - webapp

         initialDelaySeconds: 5

         periodSeconds: 3



#Example of Readiness

apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: podrediness
  name: podrediness
spec:
  replicas: 1
  selector:
    matchLabels:
      app: podrediness
  strategy: {}
  template:
    metadata:
      labels:
        app: podrediness
    spec:
      containers:
      - image: busybox
        name: busybox
        args:
         - /bin/sh
         - -c
         - sleep 20; touch webapp; sleep 600
        readinessProbe:
         exec:
          command:
            - cat
            - webapp
         initialDelaySeconds: 15
         periodSeconds: 3

Comments

Popular posts from this blog

Terraform

Different Types of Reports in Scrum - Agile

Scrum Master Interview help - Bootcamp