Creating a Compute Instance Group Environment

Learn how to create a reference to an instance group environment.

Prerequisites

Before you begin, you need these things:

  • Create a compute instance.

    If you are creating an instance through a private network, then Network Address Translation (NAT) gateway must be set up. For more information, see NAT Gateway.

    Note

    DevOps only supports instance group deployments to Oracle Linux and CentOS.
  • If any of your commands in the instance group deployment configuration artifact require sudo privileges, then you have to grant ocarun user with sudo privileges. Follow these steps:
    1. Follow the steps for creating an instance.
    2. To configure advanced settings, click Show Advanced Options.
    3. For Initialization Script, enter the following cloud-init script to grant the sudo privilege:
      #cloud-config
      users:
       - default
       - name: ocarun
         sudo: ALL=(ALL) NOPASSWD:ALL
    4. When you finish configuring the instance, click Create.

    For more information, see Running Commands on an Instance.

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

Using the Console

  1. Open the navigation menu and click Developer Services. Under DevOps, click Projects.
  2. Select an existing project, or create a DevOps project.
  3. Click Create environment.
  4. For Environment type, select Instance Group.
  5. Enter a name and optional description for the environment.
  6. (Optional) To add tags to the environment, 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 that resource.

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

    For more information, see Resource Tags.

  7. Click Next.
  8. To add instances, select one of the following options:
    1. Filter - Manually select the instances for the instance group.
    2. Query - Specify a query to select instances at runtime.
      Queries apply search conditions to specific resource types and let you filter results. For more information, see Search Language Syntax.
  9. If you select Filter option, then follow these steps to add instances:
    1. Click Add instance.
    2. Use the Region and Compartment fields to select compute hosts from a specific region and compartment.
      Note

      Each instance group can have compute hosts only from one region at a time.
    3. Use the Filter by state, Filter by shape, and Filter by text fields to further narrow down the search for compute hosts.
    4. Select instances from the displayed list to create an instance group, and click Add instance.
    5. Select the instance group to reference.
      To remove instance from the group, click Remove instance. Removing instance from the group does not result in deletion of these instances. They remain in running state.
  10. If you select Query option, then follow these steps to add instances:
    1. Click Edit query.
    2. Use the Region field to select compute hosts from a specific region.
    3. Enter the query to add instances at runtime.
      DevOps includes the instances that match the query output during the deployment run. You can use this option to dynamically add instances for instance group deployment at runtime. Freeform tags can be used to tag the required resources in the query, for example, freeformTags.key = 'app' && freeformTags.value = 'helloword'.
    1. Click Add instance query.
  11. Click Create environment.

A reference to the selected instance group environment is created. You can create a deployment pipeline to deploy artifacts to instance groups.

Using the CLI

To create a reference to an instance group environment, run the create-compute-instance-environment command:

oci devops deploy-environment create-compute-instance-environment

Required parameters for the create-compute-instance-environment command:

  • --compute-instance-group-selectors
  • --project-id

To get all the commands for deploy-environment:

oci devops deploy-environment -h

To get help for the create-compute-instance-environment command:

oci devops deploy-environment create-compute-instance-environment -h

Using the API

To create a reference to an instance group environment, use the CreateDeployEnvironment operation. For the deployEnvironmentType attribute, specify the COMPUTE_INSTANCE_GROUP value.