Setting up a canary release
You can only set up a canary release for OpenAPI specifications
- In the management console
, navigate to the folder containing the API gateway. - Select API Gateway.
- In the API gateway row, click
and select Edit. - Under Variable settings, enable canary release.
- In the Share of requests in canary release field, specify the percentage of requests for the canary release to process.
- In the Variables for canary release field, list the variables and their values to use in the canary release.
- Click Save.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To set up a canary release:
-
Edit the OpenAPI specification file or create a new one, if required.
-
View the description of the CLI command for updating an API gateway:
yc serverless api-gateway update --help -
Specify the API gateway ID or name and the canary release parameters in the command below:
yc serverless api-gateway update \ --id <API_gateway_ID> \ --canary-weight <percentage_of_requests> \ --canary-variables=<list_of_variables>Where:
--canary-weight: Percentage of requests for the canary release to process.--canary-variables: Variables for the canary release, listed askey=value.
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
To set up a canary release:
-
Open the Terraform configuration file and add the
canarysection to it:resource "yandex_api_gateway" "<API_gateway_name>" { ... canary { weight = <percentage_of_requests> variables = { <list_of_variables> } }Where:
weight: Percentage of requests for the canary release to process.variables: Variables for the canary release, listed askey=value.
For more information about
yandex_api_gatewayproperties in Terraform, see this Terraform article. -
Check the configuration using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planThe terminal will display a list of resources with their properties. No changes will be made at this step. If the configuration contains any errors, Terraform will point them out.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
You can check the API gateway update using the management console
yc serverless api-gateway get <API_gateway_name>
To set up a canary release, use the update REST API method for the ApiGateway resource or the ApiGatewayService/Update gRPC API call.