edit-icon download-icon

probe

Last Updated: Nov 28, 2017

Set the health check of a service.

  • Check the health by using URLs. HTTP and TCP protocols are supported.
  • Check the health by using shell scripts.

The health check is initiated from the container host. At regular intervals (two seconds by default), a request is sent to the container or the shell script commands are run on the container.

The health check is successful if the following criteria are met:

  • The HTTP request returns the code 2XX/3XX.
  • The TCP port can establish a link.
  • The shell scripts return the value 0.

Descriptions of the fields used for check:

  • aliyun.probe.url: The URL requested by HTTP and TCP. You only need to add the word container, without entering your domain name or IP address. The URL is used for the health check after being resolved into the corresponding IP address of the container. The service passes the health check when 2XX or 3XX is returned.

    • For example, the container provides the HTTP service by using the port 8080 and provides /ping as the URL for the health check. The URL format for the probe is http://container:8080/ping. Container Service automatically requests to check the URL returned results by using HTTP GET. The health check is successful if 2XX or 3XX is returned.

    • For example, MySQL container monitors port 3306. The URL format for the probe is tcp://container:3306. The service checks whether the container opens the port 3306 or not. If yes, the health check is successful.

  • aliyun.probe.cmd: The shell command, /check.sh, is run during the health check. Container Service regularly runs this command within the container. If the shell scripts return the value 0, the health check is successful.

  • aliyun.probe.timeout_seconds: The timeout for health check.

  • aliyun.probe.initial_delay_seconds: The number of seconds delayed to start the health check after the start of the container.

Note:

  • A service can only contain either aliyun.probe.url or aliyun.probe.cmd.
  • If both aliyun.probe.url and aliyun.probe.cmd are not contained in the service, by default, the container is healthy and other aliyun.probe.xxx labels are ignored.

Example:

Use URL to check whether or not the container is healthy.

  1. os:
  2. image: my_nginx
  3. labels:
  4. aliyun.probe.url: http://container/ping
  5. aliyun.probe.timeout_seconds: "10"
  6. aliyun.probe.initial_delay_seconds: "3"

Use shell scripts to check whether or not the container is healthy.

  1. os:
  2. image: my_app
  3. labels:
  4. aliyun.probe.cmd: health_check.sh
  5. aliyun.probe.initial_delay_seconds: "3"
Thank you! We've received your feedback.