<a id="howto-cluster-groups"></a>

# How to set up cluster groups


            <p class="youtube_link">
              <a href="https://www.youtube.com/watch?v=t_3YJo_xItM" target="_blank">
                <span title="LXD cluster groups" class="play_icon">▶</span>
                <span title="LXD cluster groups">Watch on YouTube</span>
              </a>
            </p>
        
Cluster members can be assigned to [Cluster groups](https://canonical.com/lxd/docs/default/explanation/clusters/index.html.md#cluster-groups).
By default, all cluster members belong to the `default` group.

To create a cluster group, use the [`lxc cluster group create`](https://canonical.com/lxd/docs/default/reference/manpages/lxc/cluster/group/create/index.html.md#lxc-cluster-group-create-md) command.
For example:

```none
lxc cluster group create gpu
```

To assign a cluster member to one or more groups, use the [`lxc cluster group assign`](https://canonical.com/lxd/docs/default/reference/manpages/lxc/cluster/group/assign/index.html.md#lxc-cluster-group-assign-md) command.
This command removes the specified cluster member from all the cluster groups it currently is a member of and then adds it to the specified group or groups.

For example, to assign `server1` to only the `gpu` group, use the following command:

```none
lxc cluster group assign server1 gpu
```

To assign `server1` to the `gpu` group and also keep it in the `default` group, use the following command:

```none
lxc cluster group assign server1 default,gpu
```

To add a cluster member to a specific group without removing it from other groups, use the [`lxc cluster group add`](https://canonical.com/lxd/docs/default/reference/manpages/lxc/cluster/group/add/index.html.md#lxc-cluster-group-add-md) command.

For example, to add `server1` to the `gpu` group and also keep it in the `default` group, use the following command:

```none
lxc cluster group add server1 gpu
```

## Launch an instance on a cluster group member

With cluster groups, you can target an instance to run on one of the members of the cluster group, instead of targeting it to run on a specific member.

#### NOTE
[`scheduler.instance`](https://canonical.com/lxd/docs/default/reference/cluster_member_config/index.html.md#cluster-cluster:scheduler.instance) must be set to either `all` (the default) or `group` to allow instances to be targeted to a cluster group.

See [Automatic placement of instances](https://canonical.com/lxd/docs/default/explanation/clusters/index.html.md#clustering-instance-placement) for more information.

To launch an instance on a member of a cluster group, follow the instructions in [Launch an instance on a specific cluster member](https://canonical.com/lxd/docs/default/howto/cluster_manage_instance/index.html.md#cluster-target-instance), but use the group name prefixed with `@` for the `--target` flag.
For example:

```none
lxc launch ubuntu:24.04 c1 --target=@gpu
```
