Your App Is Alive
Michelle Noorali
Developer at Deis
@michellenoorali
Slide 2
Slide 2 text
Helm
• Kubernetes Package Manager
• Packages = “Charts”
• “Homebrew” for Kubernetes
• Great way to find, share, and use software built for
Kubernetes
• Community focused
• www.helm.sh
Slide 3
Slide 3 text
Helm Charts
Kubernetes
manifests
+ metadata
Slide 4
Slide 4 text
Try it out
github.com/helm/charts
Slide 5
Slide 5 text
Health Checks
Slide 6
Slide 6 text
What?
Slide 7
Slide 7 text
a way to monitor your app’s health
A Health Check is
Slide 8
Slide 8 text
Is your app…
responsive?
Slide 9
Slide 9 text
Is your app…
Performant?
Slide 10
Slide 10 text
Is your app…
Stable?
Slide 11
Slide 11 text
What does it look like?
Slide 12
Slide 12 text
• /healthcheck or /healthz endpoint
• checked by external system at intervals
• On success, do nothing
• On failure, notify and heal
Health checks continued …
Slide 13
Slide 13 text
In Kubernetes Land…
• Health checks are built in!
• But first…
Slide 14
Slide 14 text
Introducing Puffy
• … a simple go web server
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: It’s Alive
• Create a pod definition in manifest
• Create resource in kubernetes from manifest with
$ kubectl create -f puffy-pod.yaml
• Watch it come to life with $ kubectl get pods -w
• Talk to a route
• curl pod_ip:port/index on a node
• https://asciinema.org/a/7okfmusa0c368obqxba8t9my4
Slide 21
Slide 21 text
Let’s make sure puffy is ok.
Here comes the health check part…
Slide 22
Slide 22 text
Two Probes walk into a
coffeeshop…
• Readiness Probe
• Liveness Probe
Slide 23
Slide 23 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 24
Slide 24 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 25
Slide 25 text
Define a Liveness Probe in
the Pod Manifest
Slide 26
Slide 26 text
Apply the Changes in the
Pod Manifest to the Cluster
$ kubectl delete -f puffy-pod.yaml
~ edit puffy-pod.yaml ~
$ kubectl create -f pod-puffy.yaml
Slide 27
Slide 27 text
You’ll see failure
Slide 28
Slide 28 text
Oops
• Forgot to add the /healthz endpoint
• kubectl delete -f puffy-pod.yaml
Slide 29
Slide 29 text
Add /healthz
• Define /healthz in app (common convention)
• Re-build/re-tag image
• Push image to registry
• Edit image declaration in manifest
Slide 30
Slide 30 text
Bring Puffy Back!
$ kubectl create -f puffy-pod.yaml
or $ helm install puffy
$ kubectl get pods
$ kubectl describe pod puffy
On node, curl ip:port/healthz
Things to watch out for
• Try to leave health checks as simple as possible
• Don’t get too aggressive
• Use the right probe for your situation
Slide 44
Slide 44 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 45
Slide 45 text
Deployment Manager
+
Coming together to bring you a simple and
powerful way to deploy and manage Kubernetes
Charts and is going to CNCF along with the rest of
Kubernetes
Slide 46
Slide 46 text
That’s it folks. Thank you.
Puffy: www.github.com/michelleN/puffy
Many-directions: www.github.com/michelleN/many-directions
My charts: www.github.com/michelleN/charts
Helm: www.helm.sh
Helm charts: www.github.com/helm/charts
Look for
www.github.com/kubernetes/helm
&
www.github.com/kubernetes/charts
@michellenoorali