<a id="howto-cluster-links-manage"></a>

# How to manage cluster links

<a id="howto-cluster-links-view"></a>

## View cluster links

CLI

To list all cluster links (that you have permission to see), run:

```none
lxc cluster link list
```

The `list` view shows each link’s addresses, identity status, and type.

To view the full configuration of a specific cluster link, run:

```none
lxc cluster link show <cluster-link-name>
```

To view detailed information about the state of a specific cluster link, run:

```none
lxc cluster link info <cluster-link-name>
```

The `info` view shows the link type and the status of each linked cluster member.

API

To list all cluster links (that you have permission to see), send the following request:

```none
lxc query --request GET /1.0/cluster/links
```

To display detailed information about each cluster link, use [Recursion](https://canonical.com/lxd/docs/latest/rest-api/index.html.md#rest-api-recursion):

```none
lxc query --request GET /1.0/cluster/links?recursion=1
```

See [`GET /1.0/cluster/links`](/lxd/latest/api/#/cluster-links/cluster_links_get) and [`GET /1.0/cluster/links?recursion=1`](/lxd/latest/api/#/cluster-links/cluster_links_get_recursion1) for more information.

To view the full configuration of a specific cluster link, run:

```none
lxc query --request GET /1.0/cluster/links/<name>
```

See [`GET /1.0/cluster/links/{name}`](/lxd/latest/api/#/cluster-links/%7Bname%7D/cluster_link_get) for more information.

To view detailed information about the state of a specific cluster link, run:

```none
lxc query --request GET /1.0/cluster/links/<name>/state
```

See [`GET /1.0/cluster/links/{name}/state`](/lxd/latest/api/#/cluster-links/%7Bname%7D/state/cluster_link_state_get) for more information.

UI

Click Clustering in the navigation sidebar, then select Links from the expanded drop-down list.

<a id="howto-cluster-links-permissions"></a>

## Manage cluster link permissions

To modify the permissions of a cluster link, add its identity to authentication groups. See [Manage permissions](https://canonical.com/lxd/docs/latest/explanation/authorization/index.html.md#manage-permissions) for more information.

For example, you can create an authentication group with server viewer permissions and add the cluster link identity to it:

```bash
lxc auth group create viewers
lxc auth group permission add viewers server viewer
lxc auth identity group add tls/<cluster-link-name> viewers
```

Alternatively, for bidirectional links you can specify an authentication group when creating the link, which will automatically assign the cluster link identity to that group:

```bash
lxc cluster link create <cluster-link-name> --auth-group <group name>
```

For unidirectional links, `--auth-group` is not supported on the initiating cluster (Cluster A has no identity for B) when running `lxc cluster link create`. Instead, specify the authentication group on the target cluster (Cluster B) with `--group` when issuing the identity token with `lxc auth identity create`:

```bash
lxc auth identity create cluster-link/<name-for-cluster-a> --group <group name>
```

<a id="howto-cluster-links-configure"></a>

## Configure a cluster link

See [Cluster link configuration](https://canonical.com/lxd/docs/latest/reference/cluster_link_config/index.html.md#ref-cluster-link-config) for more details on cluster link configuration options.

CLI

There are multiple ways to update the configuration for a cluster link.

To edit the entire configuration of a cluster link at once in your default text editor, enter the following command:

```none
lxc cluster link edit <cluster-link-name>
```

You can also update a single property for a cluster link by using the `set` command with the `--property` flag:

```none
lxc cluster link set <cluster-link-name> --property <key>=<value>
```

For example, to update the `description` property:

```none
lxc cluster link set cluster_b --property description="Backup cluster in data center 2"
```

Cluster links have the following properties:

<!-- Include content from [../metadata.txt](../metadata.txt) -->

<a id="cluster-link-properties:config"></a>
`config`

Cluster link configuration map

[<i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i>](#cluster-link-properties:config)

| **Key:**      | `config`   |
|---------------|------------|
| **Type:**     | string set |
| **Required:** | no         |

<a id="cluster-link-properties:description"></a>
`description`

Description of the cluster link

[<i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i>](#cluster-link-properties:description)

| **Key:**      | `description`   |
|---------------|-----------------|
| **Type:**     | string          |
| **Required:** | no              |

<a id="cluster-link-properties:name"></a>
`name`

Name of the cluster link

[<i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i>](#cluster-link-properties:name)

| **Key:**      | `name`   |
|---------------|----------|
| **Type:**     | string   |
| **Required:** | yes      |

<a id="cluster-link-properties:type"></a>
`type`

Type of the cluster link

[<i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i>](#cluster-link-properties:type)

| **Key:**      | `type`   |
|---------------|----------|
| **Type:**     | string   |
| **Required:** | yes      |

You can also update a single configuration option for a cluster link.

```none
lxc cluster link set <cluster-link-name> <key>=<value>
```

API

There are multiple ways to update the configuration for a cluster link.

To edit the entire configuration of a cluster link at once, send the following request:

```none
lxc query --request PUT /1.0/cluster/links/<name> --data "<link_configuration>"
```

See [`PUT /1.0/cluster/links/{name}`](/lxd/latest/api/#/cluster-links/%7Bname%7D/cluster_link_put) for more information.

To modify a specific property of a cluster link, send the following request:

```none
lxc query --request PATCH /1.0/cluster/links/<name> --data '{"<key>": "<value>"}'
```

Example:

```none
lxc query --request PATCH /1.0/cluster/links/cluster_b --data '{"description": "Backup cluster in data center B"}'
```

See [`PATCH /1.0/cluster/links/{name}`](/lxd/latest/api/#/cluster-links/%7Bname%7D/cluster_link_patch) for more information.

Cluster links have the following properties:

<!-- Include content from [../metadata.txt](../metadata.txt) -->`config`

Cluster link configuration map

[<i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i>](#cluster-link-properties:config)

| **Key:**      | `config`   |
|---------------|------------|
| **Type:**     | string set |
| **Required:** | no         |
`description`

Description of the cluster link

[<i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i>](#cluster-link-properties:description)

| **Key:**      | `description`   |
|---------------|-----------------|
| **Type:**     | string          |
| **Required:** | no              |
`name`

Name of the cluster link

[<i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i>](#cluster-link-properties:name)

| **Key:**      | `name`   |
|---------------|----------|
| **Type:**     | string   |
| **Required:** | yes      |
`type`

Type of the cluster link

[<i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i>](#cluster-link-properties:type)

| **Key:**      | `type`   |
|---------------|----------|
| **Type:**     | string   |
| **Required:** | yes      |

You can also update a single configuration option for a cluster link.

```none
lxc query --request PATCH /1.0/cluster/links/<name> --data '{"config": <config>}'
```

See [`PATCH /1.0/cluster/links/{name}`](/lxd/latest/api/#/cluster-links/%7Bname%7D/cluster_link_patch) for more information.

UI

Click Clustering in the navigation sidebar, then select Links from the expanded drop-down list.

To edit a cluster link, click on the pencil icon at the end of that cluster link’s row.

<a id="howto-cluster-links-delete"></a>

## Delete a cluster link

A cluster link cannot be deleted or renamed while a replicator, an image registry, or a project’s [`replica.cluster`](https://canonical.com/lxd/docs/latest/reference/projects/index.html.md#project-replica:replica.cluster) setting references it.
The link’s `used_by` field lists these references.

CLI

To delete a cluster link, run:

```none
lxc cluster link delete <cluster-link-name>
```

API

To delete a cluster link, run:

```none
lxc query --request DELETE /1.0/cluster/links/<name>
```

See [`DELETE /1.0/cluster/links/{name}`](/lxd/latest/api/#/cluster-links/%7Bname%7D/cluster_link_delete) for more information.

UI

Click Clustering in the navigation sidebar, then select Links from the expanded drop-down list.

To delete a cluster link, click on the trash can icon at the end of that cluster link’s row.
