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

Your App Is Alive

Your App Is Alive

From the Kubernetes Colorado meetup on February 18th, 2016

Michelle Noorali

February 18, 2016
Tweet

More Decks by Michelle Noorali

Other Decks in Technology

Transcript

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

  2. Health Checks

  3. What?

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

    is
  5. Is your app… responsive?

  6. Is your app… Performant?

  7. Is your app… Stable?

  8. What does it look like?

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

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

  11. Introducing Puffy • … a simple go web server

  12. 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
  13. Key Concepts • Image • Union of layered filesystems •

    Immutable • Container (Docker, rkt) • runtime instance of an image
  14. 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
  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: The Skeleton • puffy starts out as

    an image • docker build -t mnoorali/puffy:1.0.0 . • docker push mnoorali/puffy:1.0.0
  21. Demo: Create a Puffy Pod in Kubernetes Cluster

  22. 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
  23. Let’s make sure puffy is ok. • Here comes the

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

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

  28. 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
  29. FAIL • But, what happened?

  30. Oops • forgot to add the /healthz endpoint • kubectl

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

    Re-build/re-tag image • Push image to registry • Edit image declaration in manifest
  32. Bring Puffy Back! • kubectl create -f puffy-pod.yaml • kubectl

    get pods • kubectl describe pod puffy • On node, curl ip:port/healthz
  33. 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?
  34. 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!