Use placement groups
This guide shows you how to create and manage placement groups using the evroc CLI or Kubernetes API.
Placement groups control how VMs are distributed across physical hardware to improve availability and resilience.
For information about placement groups and how they work, see Placement Groups.
Prerequisites
- Access to an evroc organization and resource group
- evroc CLI installed and configured, or kubectl configured to access the evroc Kubernetes API
Create a placement group
Create a placement group with the spread strategy to ensure VMs run on different physical hosts.
Using the CLI
Create a placement group with the evroc compute placementgroup create command:
evroc compute placementgroup create my-pg --strategy spread
Using the API
Create a placement group by applying a YAML configuration:
apiVersion: compute.evroclabs.net/v1alpha1
kind: PlacementGroup
metadata:
name: my-pg
spec:
strategy:
type: spread
Apply the configuration:
kubectl apply -f placementgroup.yaml
Add a VM to a placement group
Add a VM to a placement group when creating it, or update an existing VM to join a placement group.
Using the CLI
Add a VM to a placement group when creating it:
evroc compute vm create myvm \
--running=true \
--vm-virtual-resources-ref=general.s \
--disk=mybootdisk \
--boot-from=true \
--placement-group=my-pg
Add an existing VM to a placement group (the VM must be stopped first):
evroc compute vm update myvm --running=false
Wait for the VM to stop, then add it to the placement group:
evroc compute vm update myvm --placement-group=my-pg
Start the VM again:
evroc compute vm update myvm --running=true
Using the API
Add a VM to a placement group by including the placement group in the VM specification:
apiVersion: compute.evroclabs.net/v1alpha1
kind: VirtualMachine
metadata:
name: myvm
spec:
running: true
vmVirtualResourcesRef:
vmVirtualResourcesRefName: general.s
placementGroup: my-pg
diskRefs:
- bootFrom: true
name: mybootdisk
Apply the configuration:
kubectl apply -f vm.yaml
To add an existing VM to a placement group, the VM must be stopped first. Update the VM specification to set running: false, apply it, then update again to add the placement group and set running: true.
View placement group details
View information about a placement group, including which VMs are members.
Using the CLI
View detailed placement group information:
evroc compute placementgroup show my-pg --verbose
Sample output:
name: my-pg
resourceGroup: org
...
== Conditions ==========================
- Ready=True (Ready) 176h50m18s
== Status ==============================
virtualMachines:
- name: my-vm
== Spec ================================
strategy:
type: spread
...
Using the API
View placement group details using kubectl:
kubectl describe placementgroup my-pg
Sample output:
Name: my-pg
Namespace: org
...
Spec:
Strategy:
Type: spread
Status:
Conditions:
Last Transition Time: 2025-05-30T08:54:58Z
Message:
Reason: Ready
Status: True
Type: Ready
Virtual Machines:
Name: myvm
...
List placement groups
Using the API
List all placement groups in your resource group:
kubectl get placementgroups
Sample output:
NAME READY REASON
my-pg True Ready
Delete a placement group
Delete placement groups you no longer need. A placement group must not contain any VMs before you can delete it.
Using the CLI
Delete a placement group:
evroc compute placementgroup delete my-pg
Using the API
Delete a placement group using kubectl:
kubectl delete placementgroup my-pg
Next steps
- Learn how to create a virtual machine with a placement group
- See how to manage VM lifecycle including stopping VMs before changing placement groups
- See the Placement Groups API reference for complete field descriptions