Slide 1

Slide 1 text

Self-Healing Applications with Kubernetes

Slide 2

Slide 2 text

@sheharyarn ! " # Sheharyar Naseer

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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?)

Slide 5

Slide 5 text

Kubernetes • Container automation framework • Open-sourced by Google in 2014 • Monitors, Detects and RectiHes issues in your cluster • Declarative, not Imperative

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

Architecture • Containers • Pods • Deployment • Services, Volumes, ReplicaSets, etc.

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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


Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

Demo

Slide 14

Slide 14 text

Outro Previous talk (Deployment with K8S): to.shyr.io/io19-k8s 
 
 Find these slides at: to.shyr.io/k8s-self-healing ! ! # shyr.io [email protected] sheharyarn