Health checks

Kubernetes provides two layers of health checking. First, in the form of HTTP or TCP checks, K8s can attempt to connect to a particular endpoint and give a status of healthy on a successful connection. Second, application-specific health checks can be performed using command-line scripts.

Let's take a look at a few health checks in action. First, we'll create a new controller with a health check:

apiVersion: v1 kind: ReplicationController metadata:   name: node-js   labels:     name: node-js spec:   replicas: 3   selector:     name: node-js   template:     metadata:       labels:         name: node-js     spec:       containers:       - name: node-js         image: jonbaier/node-express-info:latest         ports:         - containerPort: 80         livenessProbe:           # An HTTP health check  

Get Getting Started with Kubernetes - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.