KubeCon EU 2016: Your App Is Alive
-
Upload
kubeacademy -
Category
Technology
-
view
225 -
download
0
Transcript of KubeCon EU 2016: Your App Is Alive
Your App Is AliveMichelle Noorali
Developer at Deis@michellenoorali
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
Helm ChartsKubernetes manifests + metadata
Try it outgithub.com/helm/charts
Health Checks
What?
a way to monitor your app’s health
A Health Check is
Is your app…responsive?
Is your app…Performant?
Is your app…Stable?
What does it look like?
• /healthcheck or /healthz endpoint
• checked by external system at intervals
• On success, do nothing
• On failure, notify and heal
Health checks continued …
In Kubernetes Land…
• Health checks are built in! • But first…
Introducing Puffy• … a simple go web server
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]
Puffy Repo
Dockerfile
Makefile
Manifest file
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
Let’s make sure puffy is ok.
Here comes the health check part…
Two Probes walk into a coffeeshop…
• Readiness Probe
• Liveness Probe
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
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
Define a Liveness Probe in the Pod Manifest
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
You’ll see failure
Oops• Forgot to add the /healthz endpoint
• kubectl delete -f puffy-pod.yaml
Add /healthz
• Define /healthz in app (common convention)
• Re-build/re-tag image
• Push image to registry
• Edit image declaration in manifest
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
Let’s add some complexity.
Puffy on /play
Puffy + Spotify API
ReadinessProbe Definition
/ready
Now we need a redis pod to hang out with
Find a redis chart … to borrow some manifests
and create our own chart
www.github.com/michelleN/helm-charts/many-directions
$ helm repo add michelle https://github.com/michelleN/many-directions$ helm repo list$ helm search many-directions$ helm install many-directions
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
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?
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
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