Sign inSign up

yeasy/ckeeper

By yeasy

Updated about 10 years ago

Container application health keeper

Image
0

1.5K

yeasy/ckeeper repository overview

ckeeper

Build Status Go Report Card Keep the health of container applications.

ckeeper can be deployed on each docker host, and it will automatically check the health status, e.g., validate if the web service online, and run specified operations on unhealthy containers, e.g., restart.

The default configuration is in ckeeper.yaml.

Features

  • Automatically watch the health status of application as a nanny.
  • Support container selection based on flexible filtering options.
  • Support customized healing actions for unhealthy applications.

Usage

There are two ways to use ckeeper: docker image (recommended) and local installation.

Run in container
$ docker run \
	 -v YOUR_CONFIG_FILE:/cmonit/ckeeper.yaml \
	 yeasy/ckeeper \
	 start --logging-level=debug
Local run
$ make run

Configuration File

logging
  • level: Set output logging message level: debug|info|warning|error|critical.
host
  • daemon: The daemon url of the container host
check
  • retries: Each check will run how many tries before thinking it unhealthy.
  • interval: Seconds between two check.
Rules

Define how to decide unhealthy status and what action to take.

You can put multiple rules here, each rule will be processed in order.

For each rule:

  • option: Used to select containers to check health, following the ListOption.
  • target: Think as healthy if the target cmd's running result is true.
  • action: What action to take if the target is not met. If the target is not set, then take action by default. Valid action values include:
    • start: Start the container
    • restart: Restart the container
    • stop: Stop the container
    • pause: Pause the container
    • unpause: Un-pause the container
    • rm: Remove the container
    • print: Print the information of the matched container
    • ignore: Take no action

The target cmd can be customized easily to achieve flexible health as the user needs.

E.g., the following rule will keep every running web containers serving normally on port 80, otherwise, restart it.

  rule_web:
    option:
      All: true
      Filters:
        status:
          - running
    target: '[[ `curl -sL -w "%{http_code}\\n" CONTAINER:80 -o /dev/null` == "200" ]]'
    action: "restart"

The following rule will start all containers in exited or paused status.

  rule_start:
    option:   # container filter
      All: true
      Filters:
        status:
          - exited
          - paused
    action: "start"

Testing

$ make test

TODO

  • Add more docs and test cases.
  • Design more powerful rule engine.

Tag summary

Content type

Image

Digest

Size

247 MB

Last updated

about 10 years ago

docker pull yeasy/ckeeper