$30 off During Our Annual Pro Sale. View details »

Self-Healing Applications with Kubernetes

Self-Healing Applications with Kubernetes

My talk on building scalable, reliable, fault-tolerant, and self-healing applications using Kubernetes at DevFest Lahore 2019.

No matter what your language or framework of choice is, using strategies in this talk can help your application figure out if it's failing using custom-defined health checks that can automatically restart your app and try to bring it back to its last good state.

Video and more info: https://shyr.io/t/k8s-self-healing

Sheharyar Naseer

November 23, 2019
Tweet

More Decks by Sheharyar Naseer

Other Decks in Technology

Transcript

  1. Self-Healing Applications with Kubernetes

  2. @sheharyarn ! " # Sheharyar Naseer

  3. Why do I care? • DevOps is hard • From

    1 instance on your laptop to 100s in production • Something breaks • Requires monitoring and manual intervention • SSH'ing into production at 3am on a Saturday night
  4. Holy Grail of DevOps • Imagine: Your server constantly monitoring

    for issues • And automatically Hxing them • You no longer hate your job and yourself • And you can Hnally have a life (Maybe?)
  5. Kubernetes • Container automation framework • Open-sourced by Google in

    2014 • Monitors, Detects and RectiHes issues in your cluster • Declarative, not Imperative
  6. Imperative System • Give your system explicit instructions • It

    executes them to get to your desired state • You still need to monitor for changes • Give more instructions in case something goes down
  7. Declarative System • Desired State • Tell Kubernetes what you

    want,
 not what to do • If stuX breaks • Kubernetes will automatically Hx it • Will always go back to desired state
  8. Architecture • Containers • Pods • Deployment • Services, Volumes,

    ReplicaSets, etc.
  9. Container FROM openjdk:8-jdk-alpine VOLUME /tmp RUN mkdir /k8s-demo COPY .

    /k8s-demo WORKDIR /k8s-demo RUN /k8s-demo/gradlew build RUN mv /k8s-demo/build/libs/*.jar /app.jar ENTRYPOINT ["java","-jar","/app.jar"] Architecture apiVersion: apps/v1 kind: Deployment metadata: name: app-deploy spec: replicas: 3 ... template: spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80 - name: k8s-demo resources: limits: cpu: 6000m memory: 24Gi requests: cpu: 2000m memory: 10Gi Deployment
  10. Application Health • Pod Phases • Pending, Running, Succeeded, Failed,

    etc. • Health Checks • Readiness:
 Finished initializing and ready to accept requests • Liveness:
 Can process and respond to requests

  11. Application Health • Probes • Exec:
 Execute a command in

    the container • HTTP GET:
 Make a web request to check if a success response is returned • TCP Socket:
 Pe?orm a TCP check for an open poA
  12. Readiness readinessProbe: httpGet: path: /ready port: http initialDelaySeconds: 5 timeoutSeconds:

    1 periodSeconds: 5 failureThreshold: 3 Self-Healing livenessProbe: httpGet: path: /healthy port: http initialDelaySeconds: 10 timeoutSeconds: 10 failureThreshold: 3 Liveness
  13. Demo

  14. Outro Previous talk (Deployment with K8S): to.shyr.io/io19-k8s 
 
 Find

    these slides at: to.shyr.io/k8s-self-healing ! ! # shyr.io hi@shyr.io sheharyarn