toolkit-maven-plugin automates canary releases for Spring Cloud, Dubbo, and High-speed Service Framework (HSF) applications deployed on Enterprise Distributed Application Service (EDAS). Instead of updating all instances at once, a canary release rolls out changes to a small subset of instances first, then gradually promotes the update across the remaining instances in batches.
How canary release works
A canary release with toolkit-maven-plugin follows a two-phase process:
Canary phase: Deploy the new version to a specified number of instances (
gray). These instances receive live traffic, allowing you to validate the new version before the full rollout.Batch rollout phase: Roll out the new version to the remaining instances in controlled batches (
batch), with a configurable interval (batchWaitTime) between each batch. Batches can run automatically or require manual approval.
The EDAS update strategy type for this process is GrayBatchUpdate.
Prerequisites
Before you begin, make sure that you have:
A Spring Cloud, Dubbo, or HSF application deployed to an EDAS Kubernetes cluster
An AccessKey ID and AccessKey secret for a Resource Access Management (RAM) user (recommended over root account credentials)
The application ID (
appId), or both the microservices namespace ID (namespaceId) and application name (appName) of the target application
Set up a canary release
To set up a canary release, add the plug-in dependency, create configuration files, and run the deployment command.
Step 1: Add the plug-in dependency
Add the following dependency to your pom.xml:
<build>
<plugins>
<plugin>
<groupId>com.alibaba.cloud</groupId>
<artifactId>toolkit-maven-plugin</artifactId>
<version>1.1.9</version>
</plugin>
</plugins>
</build>Always use the latest toolkit-maven-plugin version.
Step 2: Create configuration files
Create three YAML files in the root directory of your packaged project. If you deploy a Maven submodule, create the package configuration file in the submodule directory instead.
Account configuration (toolkit_profile.yaml)
regionId: # Region where the application is deployed, for example, cn-hangzhou
accessKeyId: # AccessKey ID of a RAM user
accessKeySecret: # AccessKey secret of a RAM user
jarPath: # (Optional) Path to the deployment package. Skips Maven packaging if specified.Package configuration (toolkit_package.yaml)
apiVersion: V1
kind: AppPackage
spec:
packageType: # War, FatJar, Image, or url
packageUrl: # (Optional) URL of a remote deployment package. Used when packageType is url.
imageUrl: # (Optional) Image URL. Used when packageType is Image.Deployment configuration (toolkit_deploy.yaml)
apiVersion: V1
kind: AppDeployment
spec:
type: kubernetes
target:
appId: # Application ID. If specified, namespaceId and appName are not required.
namespaceId: # Microservices namespace ID. Required if appId is not specified.
appName: # Application name. Required if appId is not specified.
updateStrategy:
type: GrayBatchUpdate
grayUpdate:
gray: 2 # Number of instances to update in the canary phase
batchUpdate:
batch: 3 # Number of batches for the remaining instances
releaseType: auto # auto or manual
batchWaitTime: 5 # Minutes to wait between batchesThe following table describes the canary release parameters:
| Parameter | Description | Example |
|---|---|---|
appId | EDAS application ID | 6bbc57a2-a2a0-4edb-****-************ |
namespaceId | Microservices namespace ID | cn-hangzhou:my-namespace |
gray | Number of canary instances | 2 |
batch | Number of rollout batches | 3 |
releaseType | auto (automatic) or manual (requires approval) | auto |
batchWaitTime | Minutes between batches | 5 |
Step 3: Run the deployment command
Navigate to the directory that contains pom.xml (or the submodule pom.xml) and run:
mvn clean package toolkit:deploy \
-Dtoolkit_profile=toolkit_profile.yaml \
-Dtoolkit_package=toolkit_package.yaml \
-Dtoolkit_deploy=toolkit_deploy.yamlWhen the deployment succeeds, the output displays BUILD SUCCESS.
Command parameters:
| Parameter | Description |
|---|---|
toolkit:deploy | Deploys the application after Maven packaging completes. |
-Dtoolkit_profile | Path to the account configuration file. |
-Dtoolkit_package | Path to the package configuration file. |
-Dtoolkit_deploy | Path to the deployment configuration file. |
-Ddeploy_version | (Optional) Deployment version. Overrides the version in toolkit_deploy.yaml. Requires toolkit-maven-plugin 1.0.6 or later. |
To skip the -Dtoolkit_profile, -Dtoolkit_package, and -Dtoolkit_deploy parameters, place the configuration files in the same directory as pom.xml and prefix each filename with a dot (.toolkit_profile.yaml, .toolkit_package.yaml, .toolkit_deploy.yaml). The plug-in detects them automatically.
Deployment scenarios
Deploy with a local WAR or FatJar package
Build a WAR or FatJar package locally and deploy it to an existing EDAS application.
toolkit_package.yaml:
apiVersion: V1
kind: AppPackage
spec:
packageType: War # Or FatJartoolkit_deploy.yaml:
apiVersion: V1
kind: AppDeployment
spec:
type: kubernetes
target:
appId: # Application ID
namespaceId: # (Optional) Namespace ID, required if appId is not specified
appName: # (Optional) Application name, required if appId is not specifiedDeploy with an existing image URL
Deploy an application using a container image that already exists in a registry.
toolkit_package.yaml:
apiVersion: V1
kind: AppPackage
spec:
packageType: Image
imageUrl: registry.cn-beijing.aliyuncs.com/test/gateway:latesttoolkit_deploy.yaml:
apiVersion: V1
kind: AppDeployment
spec:
type: kubernetes
target:
appId: # Application ID
namespaceId: # (Optional) Namespace ID, required if appId is not specified
appName: # (Optional) Application name, required if appId is not specifiedBuild and push a local Docker image
Build a Docker image locally, push it to an Alibaba Cloud container image repository, and deploy.
toolkit_package.yaml:
apiVersion: V1
kind: AppPackage
spec:
packageType: Image
build:
docker:
dockerfile: Dockerfile
imageRepoAddress: # Image repository address
imageTag: # Image tag
imageRepoUser: # Repository username
imageRepoPassword: # Repository passwordtoolkit_deploy.yaml:
apiVersion: V1
kind: AppDeployment
spec:
type: kubernetes
target:
appId: # Application ID
namespaceId: # (Optional) Namespace ID, required if appId is not specified
appName: # (Optional) Application name, required if appId is not specifiedConfiguration reference
Package parameters
apiVersion: V1
kind: AppPackage
spec:
packageType: # War, FatJar, Image, or url
imageUrl: # Image URL. Required when deploying with an image.
packageUrl: # Package URL. Used when packageType is url.
build:
docker:
dockerfile: # Dockerfile path. Required for local image builds.
imageRepoAddress: # Alibaba Cloud image repository address
imageTag: # Image tag
imageRepoUser: # Repository username
imageRepoPassword: # Repository password
oss:
bucket: # Object Storage Service (OSS) bucket name
key: # OSS object path
accessKeyId: # AccessKey ID for OSS access
accessKeySecret: # AccessKey secret for OSS access