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 andread-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.
-
Run the List regions operation.
-
Store the
id
as yourregionId
, as well as thelabel
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.
-
Run the Get a region operation using the stored
regionId
. -
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.
-
-
Run the List Linodes operation, and include
--header X-Filter 'region: <regionId>'
in the request. This filters the response based on the target region. -
Identify the specific Linodes you want to include—up to the
maximum_linodes_per_pg
ormaximum_linodes_per_flexible_pg
—and store theid
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.
-
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 thelabel
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 tostrict
for strict enforcement orflexible
for flexible enforcement.
-
Currently, only anti-affinity (
anti-affinity:local
) is available forplacement_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" }
-
-
From the response, store the
id
as yourplacementId
.{ "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.
-
Run the Assign a placement group operation, using the stored
placementId
. In the request, populate thelinodes
array with a comma-separated list of the storedid
values for each Linode you want to include.{ "linodes": [ 123, 456, 789 ] }
-
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 itsmembers
array andmigrations
object:-
members
. Anylinode_id
shown here represents a Linode that has been successfully added to the placement group. Theis_compliant
object describes its current compliance. -
migrations
. Theinbound
object contains thelinode_id
value for each Linode that is in the process of being moved to the group. Once finished, thislinode_id
will be moved to themembers
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" }
-