Deploying to an Instance Group

Create a pipeline to deploy artifacts to instance groups.

Prerequisites

The prerequisites to deploy artifacts to an instance group are as follows:

  • Have a deployment pipeline, an instance group environment to deploy to, and artifacts. Artifacts can be defined inline or located in the Artifact Registry.

    DevOps deployment supports deploying multiple artifacts in a stage. For instance group deployment, a deployment configuration file defines the commands and runs steps to download application package artifact from the specified artifact registry and place in the target compute instance file system. See Deployment Configuration File.

  • 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 Deploy - Instance Group, and then click Next.
    5. Enter a name and description for the stage. Adding a description is optional.
    6. For Environment, select an existing instance group.
    7. 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.

    8. (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.

    9. (Optional) Click Select load balancer. The load balancer must be available in the Console.
      1. Select the load balancer region and compartment.
      2. Select a load balancer from the available list.

      Load balancer distributes production traffic during deployment. For more information, see Load Balancer Management.

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

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

    11. To automatically roll back to the last successful release version if the validation fails, select Yes. For more information, see Rolling Back a Deployment.
    12. 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 aren't running, at a time.
      • Rollout by count: Enter the count value. This value controls the maximum number of instances that are deployed, or aren't running, at a time.
    13. (Optional) For Delay between batches, enter a duration in seconds.
    14. (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.
    15. (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 the 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.

    16. To add the stage to the pipeline, click Add.

      A stage preview provides a snapshot of the configuration.

    Add more stages sequentially or in parallel to the pipeline, as needed. To deploy the build output to the target environment, run the deployment pipeline.

    You can add 100 parallel stages to the deployment pipeline but the Run Command plugin supports only five commands on one instance. So you must have enough instances to run 100 parallel instance group deployments.

    To automatically trigger a deployment from the build pipeline, you can add a Trigger Deployment stage to the build pipeline.

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

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

    Required parameters for the create-deploy-compute-instance-group-stage command:

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

    To get all the commands for deploy-stage:

    oci devops deploy-stage -h

    To get help for the create-deploy-compute-instance-group-stage command:

    oci devops deploy-stage create-deploy-compute-instance-group-stage -h
  • To create an Instance Group deployment stage for the pipeline, use the CreateDeployStage operation. For the deployStageType attribute, specify the COMPUTE_INSTANCE_GROUP_ROLLING_DEPLOYMENT value.