Help Center/ Cloud Container Instance/ Best Practices/ Workload Management/ Performing Graceful Rolling Upgrade for CCI Applications
Updated on 2024-01-16 GMT+08:00

Performing Graceful Rolling Upgrade for CCI Applications

Scenario

When you deploy a workload in CCI to run an application, the application is exposed as a LoadBalancer Service or ingress, and connected to a dedicated ELB load balancer to allow access traffic to reach the containers directly. When rolling upgrade or auto scaling is performed on the application, your pods may fail to work with ELB and 5xx errors may occur. This section guides you to configure container probes and readiness time to achieve graceful upgrade and auto scaling.

Procedure

The following uses an Nginx Deployment as an example.

  1. On the CCI console, choose Workloads > Deployments in the navigation pane, and click Create from Image in the upper right corner.

    Figure 1 Creating a Deployment

  2. In the Container Settings area, click Use Image to select an image.
  3. Click Advanced Settings of the image, click Health Check > Application Readiness Probe, and configure the probe.

    Figure 2 Configuring the application readiness probe

    The probe checks whether your container is ready. If the container is not ready, requests will not be forwarded to the container.

  4. Expand Lifecycle and configure the parameters of Pre-Stop Processing for the container.

    Figure 3 Configuring lifecycle parameters

    This configuration ensures that the container can provide services for external systems during its exit.

  5. Click Next: Configure Access Settings and configure settings as shown in Figure 4.

    Figure 4 Configuring the access type and port

  6. Click Next and complete the Deployment creation.
  7. Configure the minimum readiness time.

    A pod is considered available only when the minimum readiness time is exceeded without any of its containers crashing.

    In the upper right corner of the Deployments page, click Create YAML to configure the minimum readiness time as below.
    Figure 5 Configuring the minimum readiness time
    • The recommended value of minReadySeconds is the expected time for starting the service container plus the duration from the time when the ELB service delivers the member to the time when the member takes effect.
    • The value of minReadySeconds must be smaller than that of sleep to ensure that the new container is ready before the old container stops and exits.

  8. Test the application upgrade and auto scaling.

    Prepare a client outside the cluster, and configure the detection script detection_script.sh with the following content (100.85.125.90:7552 indicates the public network address for accessing the Service):
    #! /bin/bash 
    for (( ; ; ))
    do
             curl -I 100.85.125.90:7552 | grep "200 OK"
             if [ $? -ne 0 ]; then
                      echo "response error!"
                      exit 1
             fi 
    done

  9. Run the detection script (bash detection_script.sh) and trigger the rolling upgrade of the application on the CCI console. You can change the specifications of the container to trigger the rolling upgrade of the application.

    Figure 6 Modifying container specifications

    If the access to the application is not interrupted, and the returned responses are all 200OK, the graceful upgrade is successfully triggered.