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

More Decks by Michelle Noorali

Other Decks in Technology


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

    at intervals • On success, do nothing • On failure, notify and heal
  2. 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
  3. Key Concepts • Image • Union of layered filesystems •

    Immutable • Container (Docker, rkt) • runtime instance of an image
  4. 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
  5. 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]
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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
  11. Add /healthz • Define /healthz in app (common convention) •

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

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