# K3sClusterResource.WithAgentCount

- 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`

Sets the number of k3s agent (worker) nodes to add to the cluster.

## Remarks

Agent nodes connect to the server via DCP DNS (`https://{name}:6443`) and use
k3s's built-in retry loop, so no explicit `WaitFor` is needed. The cluster health
check waits for `1 + count` nodes to reach `Ready` state before reporting
healthy. Use `WithLifetime` with `Persistent`
to keep agents alive across AppHost restarts and avoid node password hash mismatches.

## Definition

```go
type K3sClusterResource interface {
    // ... omitted for brevity
    WithAgentCount(count float64) K3sClusterResource
}
```

## Signature

```go
WithAgentCount(count float64) K3sClusterResource
```

## Parameters

- `count` (`float64`) -- The number of agent nodes. Zero or greater. Defaults to `0` (single-node cluster -- the server node acts as both control-plane and worker).

## 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`
