# withClusterLifetime

- Module: [CommunityToolkit.Aspire.Hosting.Kind](/reference/api/typescript/communitytoolkit.aspire.hosting.kind.md)
- Version: `13.5.1-beta.736`
- Kind: `method`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/tree/3ebe72753ae604ec3c9e343865740e6f8512e1b6)

Sets the cluster lifetime. When `Session` (the default), the cluster is deleted on graceful shutdown or other process-exit signals on a best-effort basis. When `Persistent`, the cluster survives AppHost restarts and is reused on next startup.

## Definition

```typescript
interface KindClusterResource {
  // ... omitted for brevity
  withClusterLifetime(lifetime: ClusterLifetime): IKindResource
}
```

## Parameters

- `lifetime` ([ClusterLifetime](/reference/api/typescript/communitytoolkit.aspire.hosting.kind/clusterlifetime.md))

## Returns

`IKindResource` `builder`

## Applies to

- [KindClusterResource](/reference/api/typescript/communitytoolkit.aspire.hosting.kind/kindclusterresource.md)
- [KindEnvironmentResource](/reference/api/typescript/communitytoolkit.aspire.hosting.kind/kindenvironmentresource.md)
