Blue-Green Instance Group Deployment
Create deployment pipeline using Blue-Green release strategy for instance group deployment.
Prerequisites
The prerequisites are as follows:
- Have a deployment pipeline, two instance group environments to deploy to (active and standby), 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:
- In the Console, open the navigation menu, and click Compute. Under Compute, click Instances.
- Select an instance from the instance group to deploy to. Note
DevOps only supports instance group deployments to Oracle Linux and CentOS. - Click the Oracle Cloud Agent tab.
-
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 doesn't 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.
- Open the navigation menu and click Developer Services. Under DevOps, click Projects.
- Select a project, and a deployment pipeline.
- To add a stage to the pipeline, click the + icon and select Add stage.
- For stage type, select Blue/Green Strategy, and then click Next.
- Select Instance group for deployment type.
- Enter a name and description for the stage. Adding a description is optional.
- For Environment A, select the instance group where the application is deployed. For Environment B, select another instance group identical to Environment A.
- Click Select Artifact and select the 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.
- (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.
- Click Select load balancer.
- Select the load balancer region and compartment.
- Select a load balancer from the available list.
Load balancer switches the traffic between the active and standby environments during the deployment. For more information, see Load Balancer Management.
- 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.
- Enter a value for the backend port.
This is the port of the instances where the application is running.
- (Optional) Select a test load balancer, listener, and backend port to test the new application before shifting the production traffic.
This helps to avoid any risk of deployment failure during production.
- 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.
- (Optional) For Delay between batches, enter a duration in seconds.
- (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.
- Click Next.
- You can opt to validate the deployment run or choose not to validate by
selecting None.
Select Run a custom logic through a function to validate the application by invoking a function. Enter the following values:
- Enter a name and description for the stage. Adding a description is optional.
- For Environment, select an existing function to invoke.
The read-only Function name field displays the function that is called in the pipeline.
- (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}"}
- Parameters:
- 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.
- 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
orfalse
. If the return value istrue
, 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.
- (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.
- You can enable or disable a manual approval for the deployment. If you want to enable an approval, enter the following values:
- Enter a name and description for the stage. Adding a description is optional.
- Enter the number of approvers.
- (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.
- To add the stage to the pipeline, click Add.
A modal window opens displaying status of various stage configurations that are part of the blue-green instance group deployment strategy. They can include, blue-green instance group deployment, invoke function, approval, and traffic shift 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 blue-green stage, run the
create-deploy-compute-instance-group-blue-green-stage
command:oci devops deploy-stage create-deploy-compute-instance-group-blue-green-stage
Required parameters:
--environment-id-a
--environment-id-b
--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-blue-green-stage -h
To create an instance group blue-green traffic shift stage, run the
create-compute-instance-group-blue-green-traffic-shift-stage
command:oci devops deploy-stage create-compute-instance-group-blue-green-traffic-shift-stage
Required parameters:
--compute-instance-group-blue-green-stage-id
--pipeline-id
--stage-predecessor-collection
To get help for this command:
oci devops deploy-stage create-compute-instance-group-blue-green-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 load balancer traffic shift stage, run the
create-load-balancer-traffic-shift-stage
command:oci devops deploy-stage create-load-balancer-traffic-shift-stage
Required parameters:
--blue-backend-ips
--green-backend-ips
--load-balancer-config
--traffic-shift-target
--rollout-policy
--pipeline-id
--stage-predecessor-collection
To get help for this command:
oci devops deploy-stage create-load-balancer-traffic-shift-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 blue-green deployment stage:
COMPUTE_INSTANCE_GROUP_BLUE_GREEN_DEPLOYMENT
- Compute instance group blue-green traffic shift stage:
COMPUTE_INSTANCE_GROUP_BLUE_GREEN_TRAFFIC_SHIFT
- Invoke function stage:
INVOKE_FUNCTION
- Manual approval stage:
MANUAL_APPROVAL
- Compute instance group blue-green deployment stage: