reitzig / docker-healthchecker

Study of a docker-compose cluster whose health is checked by a dedicated container

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Health Check for Docker Clusters

Study of a docker-compose cluster whose overall health is checked by a dedicated container; in essence, it runs smoke tests from inside the cluster network. The actual checks being run are defined in healthchecks.json.

Motivation

Inspired by an actual issue at work, this mini project mainly serves as investigation grounds for which language provides the nicest way to implement "scripts" in a container context. Criteria are:

  • Easy to write correct scripts. Ideally testable.
  • Good abstractions for readable scripts.
  • Minimal tooling required and available as Docker images.
  • Low runtime requirements for the final container.

Yes, I want to get rid of the ubiquitous "small" shell script as a default approach.

Tested Features

More specifically, the following language or library features are needed.

  • Command-line parameters.
  • Environment variables.
  • JSON parsing & generation.
  • File I/O.
  • External command execution.

Comparison

First, some numbers. Smaller is better.

LOC LOD SOF SLI
Go 135 15 5.4MB 356MB

Where the metrics are defined as follows:

  • LOC -- Lines of "script" (and tooling) code
  • LOD -- Lines in Dockerfile.
  • SOF -- size overhead in the final image, that is the size of the final image minus the size of healthcheck.
  • SLI -- size of the largest intermediate image.

And now some subjective observations.

Go

  • The standard library (or, for that matter, the official Docker container) has everything we need here.
  • No tooling beyond the compiler required.
  • Code is reasonably neat and could be tested.
  • Struct-based JSON marshalling makes for safe code.
  • Some gaps in the standard library that are off for a modern language, e.g. higher-order collection functions.

Run

docker build -t healthcheck --build-arg checks=healthchecks.json healthcheck/
docker-compose -d up

Check docker-compose.yml for the port mappings of the individual healthcheckers.

About

Study of a docker-compose cluster whose health is checked by a dedicated container

License:Apache License 2.0


Languages

Language:Go 74.4%Language:Dockerfile 25.6%