Upgrade to Pro — share decks privately, control downloads, hide ads and more …

KubeCon-HealthChecks-pdf.pdf

Michelle Noorali
March 11, 2016
350

 KubeCon-HealthChecks-pdf.pdf

Michelle Noorali

March 11, 2016
Tweet

Transcript

  1. Your App Is Alive Michelle Noorali Developer at Deis @michellenoorali

  2. 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
  3. Helm Charts Kubernetes 
 manifests + metadata

  4. Try it out github.com/helm/charts

  5. Health Checks

  6. What?

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

    is
  8. Is your app… responsive?

  9. Is your app… Performant?

  10. Is your app… Stable?

  11. What does it look like?

  12. • /healthcheck or /healthz endpoint • checked by external system

    at intervals • On success, do nothing • On failure, notify and heal Health checks continued …
  13. In Kubernetes Land… • Health checks are built in! •

    But first…
  14. Introducing Puffy • … a simple go web server

  15. 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]
  16. Puffy Repo

  17. Dockerfile

  18. Makefile

  19. Manifest file

  20. 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
  21. Let’s make sure puffy is ok. Here comes the health

    check part…
  22. Two Probes walk into a coffeeshop… • Readiness Probe •

    Liveness Probe
  23. 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
  24. 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
  25. Define a Liveness Probe in the Pod Manifest

  26. 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
  27. You’ll see failure

  28. Oops • Forgot to add the /healthz endpoint • kubectl

    delete -f puffy-pod.yaml
  29. Add /healthz • Define /healthz in app (common convention) •

    Re-build/re-tag image • Push image to registry • Edit image declaration in manifest
  30. 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
  31. Let’s add some complexity.

  32. None
  33. Puffy on /play

  34. Puffy + Spotify API

  35. ReadinessProbe Definition

  36. /ready

  37. Now we need a redis pod to hang out with

  38. Find a redis chart … to borrow some manifests

  39. None
  40. and create our own chart

  41. www.github.com/michelleN/helm-charts/many-directions

  42. $ helm repo add michelle https://github.com/michelleN/many-directions $ helm repo list

    $ helm search many-directions $ helm install many-directions
  43. 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
  44. 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?
  45. 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
  46. 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