Setting up a canary release
You can only set up a canary release for OpenAPI specifications
- In the management console
, go 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 to be processed by the canary release.
- In the Variables for canary release field, list the variables and their values to be used in the canary release.
- Click Save.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To set up a canary release:
-
If necessary, edit the OpenAPI specification file or create a new one.
-
View a 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 <gateway_ID> \ --canary-weight <percentage_of_requests> \ --canary-variables=<list_of_variables>
Where:
--canary-weight
: Percentage of requests to be processed by the canary release.--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 documentation on the Terraform
If you don't have Terraform, install it and configure the Yandex Cloud provider.
To set up a canary release:
-
Open the Terraform configuration file and add the
canary
section to it:resource "yandex_api_gateway" "<API_gateway_name>" { ... canary { weight = <percentage_of_requests> variables = { <list_of_variables> } }
Where:
weight
: Percentage of requests to be processed by the canary release.variables
: Variables for the canary release, listed askey=value
.
For more information about the
yandex_api_gateway
resource parameters in Terraform, see the provider documentation . -
Check the configuration using this command:
terraform validate
If the configuration is correct, you will get this message:
Success! The configuration is valid.
-
Run this command:
terraform plan
The terminal will display a list of resources with parameters. No changes will be made at this step. If the configuration contains any errors, Terraform will point them out.
-
Apply the configuration changes:
terraform apply
-
Confirm the changes: type
yes
into the terminal and press Enter.
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.