# WithDataVolume

- Module: [CommunityToolkit.Aspire.Hosting.K3s](/reference/api/go/communitytoolkit.aspire.hosting.k3s.md)
- Version: `13.6.1`
- Kind: `method`
- Defined on: [`K3sClusterResource`](/reference/api/go/communitytoolkit.aspire.hosting.k3s/k3sclusterresource.md)
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/tree/d9c2addac6f527ef2e33712d290b84574b455a3b)

Mounts a named Docker volume at the k3s data directory so cluster state persists across AppHost restarts.

## Remarks

The volume covers `/var/lib/rancher/k3s`, which contains the SQLite database,
TLS certificates, and kubeconfig. Without this volume the cluster starts fresh on
every AppHost launch. Combine with `ContainerLifetime.Persistent` on the cluster
resource and its dependent Helm releases to avoid re-installing charts on every start.

## Definition

```go
func (K3sClusterResource) WithDataVolume(options ...*WithDataVolumeOptions) K3sClusterResource
```

## Parameters

- `options` (`...*WithDataVolumeOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*WithDataVolumeOptions` argument.

- `Name` (`*string`) -- Optional volume name. When `null` (the default) a name is generated from the application and resource names.

## Returns

[`K3sClusterResource`](/reference/api/go/communitytoolkit.aspire.hosting.k3s/k3sclusterresource.md) -- The same builder, for chaining.

Returns a handle; failures surface later via `Err()`.

## Applies to

- [`K3sClusterResource`](/reference/api/go/communitytoolkit.aspire.hosting.k3s/k3sclusterresource.md)
