Self-healing Applications

Learn how to put the latest open source technology into practice with hands-on training, delivered by industry experts, aligned to your desired business outcomes

A self-healing application in the context of Kubernetes:

  • Automatically recovers containers from an unhealthy state
  • Ensures at least a single copy of the application is running at all times
  • Maintain a consistent network identity

Users can create a simple self-healing application using a controller to maintain a desired state (at least one running pod) and a service to maintain a consistent network identity in the face of pod deletion/recreation.

$ kubectl create deploy apache-prod --image httpd

deployment.apps/apache-prod created

$ kubectl expose deploy apache-prod --port 80

service/apache-prod exposed


This creates a Deployment, which ensures at least a single copy of the application runs at all times and a Service that maintains the consistent network identity.

A liveness probe configured in the Deployment spec provides the pod’s managing kubelet with a way to check if the application is alive.

apiVersion: apps/v1
kind: Deployment
    app: apache-prod
  name: apache-prod
  progressDeadlineSeconds: 600
  replicas: 1
      app: apache-prod
      creationTimestamp: null
        app: apache-prod
      - image: httpd
        imagePullPolicy: Always
          failureThreshold: 1
            path: /
            port: 80
            scheme: HTTP
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        name: httpd
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always

If this probe’s livenessProbe ever returns a failure, the kubelet tells the container runtime to restart the container and bring the application back from an unhealthy state.

Learn more about: