Canary Instance Group Deployment

Create deployment pipeline using Canary release strategy for instance group deployment.

Prerequisites

The prerequisites are as follows:

  • Have a deployment pipeline, two instance group environments to deploy to (canary and production) without common instances, and artifacts. Artifacts must be located in the Artifact Registry.

    Artifacts can be a deployment configuration file or general artifacts. Deployment configuration file defines the commands and steps to download application package artifact from the specified Artifact Registry and place in the target compute instance file system.

  • Have a load balancer and listener configured in the Console for routing the traffic. You can also have a test load balancer and listener to validate the new version of the application before shifting the production traffic.
  • The Compute Instance Run Command plugin must be enabled on the instance, and plugin must be running. To enable the plugin, follow these steps:
    1. In the Console, open the navigation menu, and click Compute. Under Compute, click Instances.
    2. Select an instance from the instance group to deploy to.
      Note

      DevOps only supports instance group deployments to Oracle Linux and CentOS.
    3. Click the Oracle Cloud Agent tab.
    4. For the Compute Instance Run Command plugin, toggle the Enabled Plugin switch to Enabled.

      It takes up to 10 minutes for the change to take effect.

      Caution

      Functionality that depends on the plugin, such as monitoring, autoscaling, deployment, or OS management does not work when the plugin is disabled.
      Caution

      To deploy applications using the Compute Instance Run Command plugin, you must appropriately configure and maintain least privilege policies. For more information, see Running Commands on an Instance.

      For information about managing plugins, see Managing Plugins with Oracle Cloud Agent. For troubleshooting, see Troubleshooting Oracle Cloud Agent.

  • Have permission to run commands on the instance. See the required Identity and Access Management (IAM) policy

For creating dynamic groups and policies for deployment pipelines, see Deployment Pipeline Policies. For more details, see DevOps IAM Policies.

For accessing DevOps using the Oracle Cloud Console, REST API, and CLI, see Accessing DevOps.

    1. Open the navigation menu and click Developer Services. Under DevOps, click Projects.
    2. Select a project, and a deployment pipeline.
    3. To add a stage to the pipeline, click the + icon and select Add stage.
    4. For stage type, select Canary Strategy, and then click Next.
    5. Select Instance group for deployment type.
    6. Enter a name and description for the stage. Adding a description is optional.
    7. For Canary environment, select an existing instance group environment.
    8. Click Select Artifact, and then select available instance group deployment configuration artifacts to deploy.

      The deployment configuration file defines the artifacts to be downloaded to the instance and the location where the artifacts must be copied. For more information, see Deployment Configuration File.

    9. (Optional) Click Select Artifact to add more artifacts that are downloaded to the compute instances during the deployment.

      These additional artifacts must not be defined inline.

    10. Click Select load balancer.
      1. Select the load balancer region and compartment.
      2. Select a load balancer from the available list.

      Load balancer shifts part of the production traffic to the canary environment during the deployment. For more information, see Load Balancer Management.

    11. To add a listener to the load balancer, click Select Listener.

      Listeners check for incoming traffic on the load balancer's IP address and listener port. For more information, see Listener Management.

    12. Enter a Backend port value.

      This is the port of the instances where the application is running.

    13. (Optional) Select a test load balancer, listener, and backend port to test the application before shifting the production traffic.

      This helps to avoid any risk of deployment failure during production.

    14. The Rollout policy controls the rate and behavior of the instance rollout across the target environment. Select one of the following options:
      • Rollout by percentage: Enter the percentage value between 1 and 100. This value controls the maximum percentage of instances that are deployed, or are not running, at a time.
      • Rollout by count: Enter the count value. This value controls the maximum number of instances that are deployed, or are not running, at a time.
    15. (Optional) For Delay between batches, enter a duration in seconds.
    16. (Optional) To add tags to the pipeline, click Show tagging options. Tagging is a metadata system that lets you organize and track the resources in your tenancy.

      If you have permissions to create a resource, you also have permissions to add free-form tags to it.

      To add a defined tag, you must have permissions to use the tag namespace.

      For more information, see Resource Tags.

    17. Click Next.
    18. Validate the deployment run. To validate, a custom function is added to the pipeline. Select Run a custom logic through a function and enter the following values:
      1. Enter a name and description for the stage. Adding a description is optional.
      2. For Environment, select an existing function to invoke.

        The read-only Function name field displays the function that is called in the pipeline.

      3. (Optional) To select and add artifacts to the stage, click Select Artifact.

        Select an existing artifact resource from your DevOps project. The artifact must be a generic (universal) file type. Parameters in the artifact must be in JSON format and can have placeholders. While configuring the DevOps artifact resource, select Allow parameterization. Selecting this checkbox ensures that the placeholders are substituted with the argument value during the deployment. For more information, see Configuring Parameters.

        Here's an example of the generic artifact content to pass two user-defined parameters and their values:
        • Parameters: test_name, app_version
        • Values: {"test_name":"verify_production", "app_version":"${app_version}"}
      4. For Stage run mode, select to run asynchronously or synchronously.

        If you select Run asynchronously, the service invokes the function but does not wait for the function to complete. On selecting Run synchronously, the service invokes the function and waits for the function to complete.

      5. Select to disable or enable validation.

        If the validation is enabled, then the service verifies the return value of the function. The return value is a UTF-8 string literal, true or false. If the return value is true, then the stage is marked as Succeeded, otherwise the stage is marked as Failed.

        If the validation is disabled, then the service does not verify the return value.

        Validation occurs only if you have selected the option "Run synchronously" for stage run mode.

      6. (Optional) To add tags to the pipeline, click Show tagging options. Tagging is a metadata system that lets you organize and track the resources in your tenancy.

        You can select a tag namespace or a free-form tag is added. Enter corresponding tag key and tag value. You can add multiple tags.

      Note

      If you don't want to validate the deployment run, select None.
    19. Click Next.
    20. Enter a name and optional description for the Shift traffic stage to shift part of the traffic to the canary environment.
    21. Enter Ramp Limit in percentage to specify the maximum traffic to be shifted. The value must be between 1 and 25.

      For example, if the ramp limit is 20, then 20% of the traffic is shifted to the canary environment.

    22. Click Next.
    23. Enter a name and description for the manual Approval stage. Adding a description is optional.
    24. Enter number of approvers and click Next.
    25. Enter a name and description for the Production canary stage. Adding a description is optional.
    26. For Production environment, select an existing instance group environment that is used to deploy the application validated in the canary environment.
    27. Enter the Production namespace.
    28. To automatically roll back the deployment to the last successful version if the stage fails, select the Auto rollback check box.
    29. The Rollout policy controls the rate and behavior of the instance rollout across the target environment. Select one of the following options:
      • Rollout by percentage: Enter the percentage value between 1 and 100. This value controls the maximum percentage of instances that are deployed, or are not running, at a time.
      • Rollout by count: Enter the count value. This value controls the maximum number of instances that are deployed, or are not running, at a time.
    30. (Optional) For Delay between batches, enter a duration in seconds.
    31. (Optional) The Failure policy defines the failure criteria for a stage. It can be defined based on the number of compute hosts failing in an instance group. Select one of the following options:
      • None
      • Fail by percentage: Enter the percentage value between 1 and 100. This value defines the percentage of compute hosts that fail after which the stage fails.
      • Fail by count: Enter the count value. This value defines the number of compute hosts that fail after which the stage fails.
    32. To add the stage to the pipeline, click Add.

      A modal window opens displaying status of various stage configurations that are part of the canary instance group deployment strategy. They include, instance group canary deployment, traffic shift, manual approval, and production rolling deployment stages. If the validation is not successful, then you can check the error message specific to each failed stage and take corrective action.

      If the validation is successful, then you can run the deployment pipeline or add more stages sequentially or in parallel to the pipeline, as needed.

  • To create an instance group canary stage, run the create-deploy-compute-instance-group-canary-stage command:

    oci devops deploy-stage create-deploy-compute-instance-group-canary-stage

    Required parameters:

    • --compute-instance-group-environment-id
    • --deployment-spec-artifact-id
    • --rollout-policy
    • --pipeline-id
    • --production-load-balancer-config
    • --stage-predecessor-collection

    To get help for this command:

    oci devops deploy-stage create-compute-instance-group-canary-stage -h

    To create an instance group canary traffic shift stage, run the create-compute-instance-group-canary-traffic-shift-stage command:

    oci devops deploy-stage create-compute-instance-group-canary-traffic-shift-stage

    Required parameters:

    • --compute-instance-group-canary-stage-id
    • --pipeline-id
    • --stage-predecessor-collection

    To get help for this command:

    oci devops deploy-stage create-compute-instance-group-canary-traffic-shift-stage -h

    To create an invoke function stage, run the create-invoke-function-stage command:

    oci devops deploy-stage create-invoke-function-stage

    Required parameters:

    • --function-environment-id
    • --is-async
    • --is-validation-enabled
    • --pipeline-id
    • --stage-predecessor-collection

    To get help for this command:

    oci devops deploy-stage create-invoke-function-stage -h

    To create a manual approval stage, run the create-manual-approval-stage command:

    oci devops deploy-stage create-manual-approval-stage

    Required parameters:

    • --approval-policy
    • --pipeline-id
    • --stage-predecessor-collection

    To get help for this command:

    oci devops deploy-stage create-manual-approval-stage -h

    To get all the commands for deploy-stage:

    oci devops deploy-stage -h
  • To create a stage, use the CreateDeployStage operation. Depending on what stages that you want to add to the pipeline, select the following values for stage type:

    • Compute instance group canary deployment stage: COMPUTE_INSTANCE_GROUP_CANARY_DEPLOYMENT
    • Invoke function stage: INVOKE_FUNCTION
    • Compute instance group canary traffic shift stage: COMPUTE_INSTANCE_GROUP_CANARY_TRAFFIC_SHIFT
    • Compute instance group canary approval stage: COMPUTE_INSTANCE_GROUP_CANARY_APPROVAL