Create a placement group

Here, we combine API operations to create a new placement group and add existing Linodes to it.

Before you begin

  • Review Placement groups and compliance to understand the placement group concept.

  • Review the Technical specifications for details on what's supported.

  • A user running this workflow needs the add_linodes grant and read-write permission to the Linodes you want to add to the group. Talk to your local account administrator about grant and permissions management.

Get details

First, you need to verify some things and gather a few values. Specifically, this includes information on the region where you want to create the placement group and details on the Linodes you want to include in it.

  1. Run the List regions operation.

  2. Store the id as your regionId, as well as the label for the region where your target Linodes live.

    {
      "data": [
        {
          "capabilities": [
            "Linodes",
            "NodeBalancers",
            "Block Storage",
            "Object Storage",
            "Placement Groups",
            "Block Storage Encryption",
            "Linode Interfaces"
          ],
          "country": "us",
          "id": "us-mia", <== Store.
          "label": "Miami, FL, USA", <== Store.
          "monitors": {
            "alerts": [
              "dbaas"
            ],
            "metrics": [
              "dbaas"
            ]
          },
          "placement_group_limits": {
            "maximum_linodes_per_flexible_pg": 5,
            "maximum_linodes_per_pg": 5,
            "maximum_pgs_per_customer": 10
          },
          "resolvers": {
            "ipv4": "192.0.2.0,192.0.2.1",
            "ipv6": "2001:0db8::,2001:0db8::1"
          },
          "site_type": "core",
          "status": "ok"
        }
      ],
      "page": 1,
      "pages": 1,
      "results": 1
    }
    

    📘

    Currently, only specific regions support placement groups.

  3. Run the Get a region operation using the stored regionId.

  4. Store these values from the response:

    • maximum_linodes_per_pg. This represents the maximum number of Linodes you can add to a single placement group, using the strict placement group policy, in that region.

    • maximum_linodes_per_flexible_pg. This represents the maximum number of Linodes you can add to a single placement group, using the flexible placement group policy, in that region.

    "placement_group_limits": {
      "maximum_linodes_per_pg": 5, <== Store
      "maximum_linodes_per_flexible_pg": 5, <== Store.
      "maximum_pgs_per_customer": 10
    },
    

    📘

    Currently, you can have a maximum of 5 Linodes in a placement group.

  5. Run the List Linodes operation, and include --header X-Filter 'region: <regionId>' in the request. This filters the response based on the target region.

  6. Identify the specific Linodes you want to includeup to the maximum_linodes_per_pg or maximum_linodes_per_flexible_pgand store the id value for each.

    {
      "data": [
        {
          "alerts": {
            "cpu": 180,
            "io": 10000,
            "network_in": 10,
            "network_out": 10,
            "transfer_quota": 80
          },
          "backups": {
            "available": true,
            "enabled": true,
            "last_successful": "2018-01-01T00:01:01",
            "schedule": {
              "day": "Saturday",
              "window": "W22"
            }
          },
          "capabilities": [
            "Block Storage Encryption"
          ],
          "created": "2018-01-01T00:01:01",
          "disk_encryption": "disabled",
          "has_user_data": true,
          "host_uuid": "1a2bcd34e5f67gh8ij901234567kl89mn01opqr2",
          "hypervisor": "kvm",
          "id": 123, <== Store.
          ...
       }
    

Create the placement group

Now, you're ready to create your new placement group.

  1. Run the Create placement group operation. Include the following values in the request:

    • label. Give your placement group an easily recognizable name.

    • region. Set this to the label you stored for your region.

    • placement_group_type. Set this to the affinity that meets your model.

    • placement_group_policy. Define how to enforce compliance for your placement group, when adding Linodes to it in the future. Set to strict for strict enforcement or flexible for flexible enforcement.

    📘

    • Currently, only anti-affinity (anti-affinity:local) is available for placement_group_type.

    • Once you create your placement group, you can't change its placement_group_policy enforcement setting.

    {
      "placement_group_policy": "strict",
      "placement_group_type": "anti_affinity:local",
      "label": "PG_Miami_failover",
      "region": "us-mia"
    }
    
  2. From the response, store the id as your placementId.

    {
      "id": 528, <== Store.
      "is_compliant": true,
      "label": "PG_Miami_failover",
      "members": [
        {
          "is_compliant": true,
          "linode_id": 123
        }
      ],
      "placement_group_policy": "strict",
      "placement_group_type": "anti-affinity:local",
      "region": "us-mia"
    }
    

Add Linodes to the group

With your placement group created, now you can add your Linodes to it.

  1. Run the Assign a placement group operation, using the stored placementId. In the request, populate the linodes array with a comma-separated list of the stored id values for each Linode you want to include.

    {
       "linodes": [
         123, 456, 789
       ]
    }
    
  2. Wait a few minutes and run the Get a placement group operation, using the stored placementId. The response shows the status of the migration in its members array and migrations object:

    • members. Any linode_id shown here represents a Linode that has been successfully added to the placement group. The is_compliant object describes its current compliance.

    • migrations. The inbound object contains the linode_id value for each Linode that is in the process of being moved to the group. Once finished, this linode_id will be moved to the members array.

    {
      "id": 528,
      "is_compliant": true,
      "label": "PG_Miami_failover",
      "members": [
        {
          "is_compliant": true,
          "linode_id": 123
        }
      ],
      "migrations": {
        "inbound": [
          {
            "linode_id": 456
          },
          {
            "linode_id": 789
        ],
        "outbound": []
      },
      "placement_group_policy": "strict",
      "placement_group_type": "anti-affinity:local",
      "region": "us-mia"
    }