Help Center/ Cloud Container Instance/ User Guide/ Workload/ Setting Health Check Parameters
Updated on 2023-02-07 GMT+08:00

Setting Health Check Parameters

Container health can be checked regularly when the container is running.

CCI provides two health check methods based on Kubernetes:

  • Liveness probe: checks whether a containerized application is alive. The liveness probe is similar to the ps command for checking whether a process is running. If the containerized application fails the check, the container will be restarted. If the containerized application passes the check, no operation will be performed.
  • Readiness probe: checks whether a containerized application is ready to handle requests. An application may take a long time to start up and provide services, for example, because it needs to load disk data or wait for the startup of an external module. In this case, application processes are running, but the application is not ready to provide services. This is where the readiness probe is useful.

Health Check Modes

  • HTTP Request Mode

    The probe sends an HTTP GET request to the container. If the probe receives a 2xx or 3xx status code, the container is healthy.

  • Command Line Script

    The probe runs a command in the container and checks the exit status code. If the exit status code is 0, the probe is healthy.

    For example, if you want to run the cat /tmp/healthy command to check whether the /tmp/healthy directory exists, configure data as shown in the following figure.

    Figure 1 Command setting

Common Parameter Description

Table 1 Health check parameters

Parameter

Description

Time Window (s)

Delay time (unit: second). For example, if you set this parameter to 10, the probe starts 10 seconds after the container is started.

Timeout Period (s)

Timeout period (unit: second). For example, if you set this parameter to 10, the container must return a response in 10 seconds. Otherwise, the probe is counted as failed. If you set this parameter to 0 or do not specify any value, the default value (1 second) is used.

Setting Health Check Using kubectl