Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
Self-Healing Applications with Kubernetes
Sheharyar Naseer
November 23, 2019
Technology
0
150
Self-Healing Applications with Kubernetes
Given at DevFest Lahore 2019:
https://facebook.com/GDGLahore
Sheharyar Naseer
November 23, 2019
Tweet
Share
More Decks by Sheharyar Naseer
See All by Sheharyar Naseer
sheharyar
0
65
sheharyar
1
100
sheharyar
0
270
sheharyar
0
180
sheharyar
2
930
sheharyar
0
89
sheharyar
0
87
Other Decks in Technology
See All in Technology
dena_tech
0
200
syoshie
0
660
sansandsoc
0
360
mahito
0
230
armaniacs
0
200
dena_tech
15
3.4k
robcrowley
0
160
htomine
0
180
shirayanagiryuji
1
280
nitya
0
320
ihcomega56
1
600
harshbothra
0
150
Featured
See All Featured
matthewcrist
73
7.5k
hatefulcrawdad
257
17k
revolveconf
200
9.7k
jonrohan
1021
380k
reverentgeek
27
2k
sachag
267
17k
pauljervisheath
195
15k
cassininazir
347
20k
holman
447
130k
eileencodes
113
25k
shpigford
165
19k
paulrobertlloyd
71
3.6k
Transcript
Self-Healing Applications with Kubernetes
@sheharyarn ! " # Sheharyar Naseer
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
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?)
Kubernetes • Container automation framework • Open-sourced by Google in
2014 • Monitors, Detects and RectiHes issues in your cluster • Declarative, not Imperative
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
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
Architecture • Containers • Pods • Deployment • Services, Volumes,
ReplicaSets, etc.
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
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
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
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
Demo
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