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
/pingas 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.
- A service can only contain either
- If both
aliyun.probe.cmdare not contained in the service, by default, the container is healthy and other
aliyun.probe.xxxlabels are ignored.
Use URL to check whether or not the container is healthy.
Use shell scripts to check whether or not the container is healthy.