Updated on 2025-08-12 GMT+08:00

Health Check

The health of a running container can be checked regularly.

CCI 2.0 supports the following types of probes:

  • 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 application fails the check, the container will be restarted. If the 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 due to some reasons, for example, 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.
  • Startup probe: checks whether a container is started successfully. It checks when the container is started to ensure that the application can be started and run normally.

Health Check Methods

  1. Log in to the CCI 2.0 console.
  1. On the Health Check tab, configure the liveness probe, readiness probe, or startup probe.

    • HTTP request

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

    • TCP connection

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

    • Command

      The probe runs a command in the container and checks the exit status code. If the exit status code is 0, the container 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 Parameters

Table 1 Health check parameters

Parameter

Description

Interval (s)

Specifies the interval for performing a health check, in seconds. For example, if this parameter is set to 10, the health check is performed every 10 seconds.

Delay (s)

Specifies the time required for the probe to be initiated after the container has started, in seconds. For example, if you set this parameter to 10, the probe is initiated within 10 seconds after the container is started.

Timeout (s)

Specifies the amount of time after which the probe times out, in seconds. For example, if you set this parameter to 10, the container must return a response within 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.

NOTE:

If the executed command generates a subprocess in the image, timeoutSeconds may not take effect.

Success Threshold

Specifies the number of consecutive successful health checks for a container to be considered healthy. For example, if this parameter is set to 1, the health check is successful if the probe succeeds for one time after a probe failure.

Failure Threshold

Specifies the number of consecutive failed health checks for a container to be considered unhealthy. For example, if this parameter is set to 3, the health check fails after the probe fails for three consecutive times. In this case, the container is considered unhealthy and will be restarted.