Updated on 2024-06-27 GMT+08:00

Blue-Green Upgrade

Kubernetes provides the blue-green upgrade policy. Users who have purchased ASM can upgrade Deployment in a cluster in blue-green mode.

  • In Kubernetes, a service can be associated with Deployment instances of multiple versions through LabelSelector.
  • VirtualService can be used to further control the routing policy between traffic and Deployment instances of a specific version.
  • The blue-green release starts. Kubernetes creates a Deployment instance of a new version (blue cluster) based on the current Deployment instance (green cluster). By default, the blue cluster inherits the configuration of the green cluster. You can update the configuration on the CCE console before traffic diversion.
  • After the blue cluster is created, update the DestinationRule resource object of the ASM to generate routing table information.
  • When the traffic diversion starts, user traffic is automatically switched from the green cluster to the blue cluster.
  • After the verification, click Released to remove the original green cluster and end the upgrade task.

Prerequisites

  • The service has been brought online on CCE, and the service and Deployment have been created.
  • VirtualService and DestinationRule corresponding to the service have been created in ASM.

Procedure

  1. After creating a pipeline and configuring image build, add a KubernetesRelease task to the pipeline and set related parameters. For details about the parameters, see Table 1.

    Table 1 Parameter description

    Parameter

    Description

    Name

    Enter the name of the upgrade. The default name is KubernetesRelease.

    Region

    Select a region for deployment.

    CCE Cluster

    Select the Kubernetes cluster applied in CCE.

    Namespace

    Select the namespace of the Kubernetes cluster on CCE.

    Use IAM to improve permissions

    If you do not have the permission to execute an API, this parameter enables you to obtain the temporary AK/SK of the parent user to execute the CCE API through IAM.

    Deployment Strategy

    The deployment strategy includes Rolling and Blue-Green (we use Blue-Green as an example).

    • Rolling: rolling release for deployment
    • Blue-Green: ASM-based blue-green release

    Service Name

    The service to be upgraded.

    VirtualService

    Select the target VirtualService. Log in to the ASM console, choose Mesh Configuration > Istio Resource Management and filter the target namespace and Istio resources.

    DestinationRule

    Select the target DestinationRule. Log in to the ASM console, choose Mesh Configuration > Istio Resource Management and filter the target namespace and Istio resources.

    Image URL

    URL of the image to be upgraded. You can enter a prepared image URL as the target image, for example, swr.cn-north-1.myhuaweicloud.com/demo/springboot-helloworld:v1.1. You can also use ${} to reference pipeline parameters, for example, swr.cn-north-1.myhuaweicloud.com/demo/springboot-helloworld:${version}.

    Grayscale Version

    If you enable it, use the keyword "version" in the label to distinguish the official version from the grayscale version. The version number must be the same as the subsets object name in DestinationRule and is used as an identifier for grayscale traffic distribution.

    Grayscale Workload Upgrading Timeout (minutes)

    If the grayscale Deployment cannot be created within the timeout interval, the upgrade will fail.

    Route Traffic Waiting Time (minutes)

    After the waiting time, all user traffic is switched to the grayscale Deployment.

  2. After the configuration, run the pipeline. Click the task card and select Task Result in the displayed dialog box. You can view the detailed upgrade process on the Release Sheet page.

    The page displays information such as the sheet ID, executor, start time, end time, release status, basic information, release details, and release logs.

    • To end the upgrade, click Released to bring the old Deployment offline.
    • To roll back a release, click Rollback to switch the traffic to the old Deployment and bring the new one offline. The Rollback Sheet page is displayed. The content of the rollback sheet is similar to that of the release sheet.
    • Click Release Status to refresh the release status.

    Basic Information

    This area displays the names, types, namespaces, versions, images, timeout interval, and traffic switching waiting time of the old and new Deployments.

    Release Detail

    This area displays the number of Deployment copies, basic Deployment information, and key events of the old and new Deployments.

    The Online icon indicates the Deployment of the current user traffic. You can click the card to view the pod information corresponding to the Deployment.

    • Basic Information
      • Instance Name: pod name.
      • Status: running status of the pod.
      • Pod IP: IP address of the pod.
      • Host IP: IP address of the node where the pod is located.
      • Create Time: time when the instance is created.
    • Key Event

      This area displays the key events of the pod, including the Kubernetes component name, event type, Kubernetes event, first occurrence time, and recent occurrence time. These can be used to locate a pod fault.

    Release Log

    Switch to the Release Log tab page to view the detailed logs.