# K3sClusterResource.WithDataVolume

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

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
type K3sClusterResource interface {
    // ... omitted for brevity
    WithDataVolume(options ...*WithDataVolumeOptions) K3sClusterResource
}
```

## Signature

```go
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()`.

## Defined on

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