Slide 1

Slide 1 text

Your App Is Alive Michelle Noorali Developer at Deis @michellenoorali

Slide 2

Slide 2 text

Health Checks

Slide 3

Slide 3 text

What?

Slide 4

Slide 4 text

a way to monitor your app’s health A Health Check is

Slide 5

Slide 5 text

Is your app… responsive?

Slide 6

Slide 6 text

Is your app… Performant?

Slide 7

Slide 7 text

Is your app… Stable?

Slide 8

Slide 8 text

What does it look like?

Slide 9

Slide 9 text

• /healthcheck or /healthz endpoint • checked by external system at intervals • On success, do nothing • On failure, notify and heal

Slide 10

Slide 10 text

In Kubernetes Land… •Health checks are built in! •But first…

Slide 11

Slide 11 text

Introducing Puffy • … a simple go web server

Slide 12

Slide 12 text

Let’s review! • I have an app (Puffy) and I want to deploy it onto my Kubernetes cluster so… • I write a manifest … • … which references an image • … which will contain all the instructions for my app

Slide 13

Slide 13 text

Key Concepts • Image • Union of layered filesystems • Immutable • Container (Docker, rkt) • runtime instance of an image

Slide 14

Slide 14 text

Kubernetes Concepts • Pod • Represents a logical application • One or more containers • Manifest • yaml file • serves as resource (ex. pod) definition • kubectl • CLI tool to control kubernetes cluster

Slide 15

Slide 15 text

Pre-requisites • Running Kubernetes cluster on GCE [Google Compute Engine] • Docker Image for app stored on DockerHub • DockerHub = place to store images • Can also use Quay.io or GCR [Google Container Registry]

Slide 16

Slide 16 text

Puffy Repo

Slide 17

Slide 17 text

Dockerfile

Slide 18

Slide 18 text

Makefile

Slide 19

Slide 19 text

Manifest file

Slide 20

Slide 20 text

Life of Puffy: The Skeleton • puffy starts out as an image • docker build -t mnoorali/puffy:1.0.0 . • docker push mnoorali/puffy:1.0.0

Slide 21

Slide 21 text

Demo: Create a Puffy Pod in Kubernetes Cluster

Slide 22

Slide 22 text

Life of Puffy: It’s Alive • create a pod definition in manifest • create resource in kubernetes from manifest • kubectl create -f puffy-pod.yaml • watch it come to life • kubectl get pods • Check it out • curl pod_ip:port/index on a node

Slide 23

Slide 23 text

Let’s make sure puffy is ok. • Here comes the health check part…

Slide 24

Slide 24 text

Two Probes walk into a coffeeshop… • Readiness Probe • Liveness Probe

Slide 25

Slide 25 text

Wait. What is this probe thing? • a probe = a diagnostic periodically performed on a container • Three ways to perform a diagnostic: • Execute a command in a container • Successful if exit status code 0 • Perform tcp check on a container’s IP address on a specific port • Successful if the port is open • Perform an HTTP Get against the container’s IP address on a specific port • Successful if response has status code >= 200 and <400

Slide 26

Slide 26 text

Back to the probes… • Readiness Probe • Is my app ready to serve traffic? • On failure, it stops serving requests • Liveness Probe • Is my app in a good state? • On failure, it restarts the pod

Slide 27

Slide 27 text

Define a Liveness Probe in the Pod Manifest

Slide 28

Slide 28 text

Apply the Changes in the Pod Manifest to the Cluster • kubectl delete -f puffy-pod.yaml • kubectl get pods • edit puffy-pod.yaml • kubectl create -f pod-puffy.yaml

Slide 29

Slide 29 text

FAIL • But, what happened?

Slide 30

Slide 30 text

Oops • forgot to add the /healthz endpoint • kubectl delete -f puffy-pod.yaml

Slide 31

Slide 31 text

Add /healthz • Define /healthz in app (common convention) • Re-build/re-tag image • Push image to registry • Edit image declaration in manifest

Slide 32

Slide 32 text

Bring Puffy Back! • kubectl create -f puffy-pod.yaml • kubectl get pods • kubectl describe pod puffy • On node, curl ip:port/healthz

Slide 33

Slide 33 text

Summary • automate monitoring apps with health checks • Use Kubernetes’s built in health check features • readinessProbe • Is your app ready to serve traffic? • livenessProbe • Is your app in a good state?

Slide 34

Slide 34 text

That’s it folks. Visit puffy at www.github.com/michelleN/puffy Will have a link to slides above and on twitter: @michellenoorali Thank You!