Instances.placement.scriptlet and (anti) affinity rules

Was playing around with instances.placement.scriptlet on LXD 6.5 and it seems like they are no longer supported starting with the next version.

That is a big shame. It was quite a recent addition to LXD (5.11). I was hoping to create some logic to make sure my grouped instances are spread evenly over my LXD cluster.

What I’m looking to achieve is that by default instances are spread out based on their name without digits (so web1, web2 and web3 will be seen as the same “group” web ) or group instances based on a user.placement_affinity key. That way everyone can just create instances and I can sleep well knowing clustered resources are spread out.

Idea was to also add user.zone or user.rack labels on my cluster members to initially prefer servers in separate locations inside the datacenter rather than servers that are in the same server rack (and by that extension network switch/power source)

I wasn’t even sure if all of this information would have been available from within the instances.placement.scriptlet functionality. Running a python script with the above logic every 30 minutes is more of a workaround. I would have preferred to get this done by LXD so that it can take it into account when evacuating a cluster member as well. (Wouldn’t want my sql master and slave on the same cluster member.)

Will I have to do this with external scripts/logic ?

Hi @vosdev

Thanks for sharing what you are aiming to achieve with instance placement. We are currently working on a new placement-groups feature that will enable configurable instance placement policies in relation to cluster members (essentially affinity and anti-affinity, however the naming is still subject to change). Placement groups will be considered during cluster evacuation.

We are aiming to have this out in the next feature release.

2 Likes

Awesome! Then I will wait with creating external scripts moving my instances around for now :slight_smile:

Checked the git repo and saw 2 closed PRs related to this (by you) but I will keep an eye out!

Will my logic described in the original post be (somewhat) possible with these new placement groups?

Spreading instances across cluster members will be possible with placement-groups. Affinity for a specific group of cluster members will not be possible initially, but this is something we are considering for a future iteration of the feature.

1 Like

Placement groups are now in latest/edge. Please see https://documentation.ubuntu.com/lxd/latest/howto/cluster_placement_groups/ for additional information.

1 Like

I’ll be able to do most of my balancing (affinity or anti-affinity) that I had planned with this feature! Lovely :slight_smile:

1 Like

Please let us know if you find any issues with it! thanks!

1 Like