# K3sServiceEndpointResource Constructors

- Package: [CommunityToolkit.Aspire.Hosting.K3s](/reference/api/csharp/communitytoolkit.aspire.hosting.k3s.md)
- Type: [K3sServiceEndpointResource](/reference/api/csharp/communitytoolkit.aspire.hosting.k3s/k3sserviceendpointresource.md)
- Kind: `Constructors`
- Members: `1`

Represents a Kubernetes Service exposed from a k3s cluster as an Aspire endpoint resource.

<a id="constructor"></a>
<a id="constructor-string-string-int-string-k3sclusterresource"></a>

## K3sServiceEndpointResource(string, string, int, string, K3sClusterResource)

- Name: `Constructor(string, string, int, string, K3sClusterResource)`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d479e13473b1d29d06b974f144a0049289a3cb5c/src/CommunityToolkit.Aspire.Hosting.K3s/K3sServiceEndpointResource.cs#L28-L57)

Represents a Kubernetes Service exposed from a k3s cluster as an Aspire endpoint resource.

```csharp
public sealed class K3sServiceEndpointResource
{
    public K3sServiceEndpointResource(
        string name,
        string serviceName,
        int servicePort,
        string @namespace,
        K3sClusterResource cluster)
    {
        // ...
    }
}
```

## Parameters

- `name` (`string`)
- `serviceName` (`string`)
- `servicePort` (`int`)
- `namespace` (`string`)
- `cluster` ([K3sClusterResource](/reference/api/csharp/communitytoolkit.aspire.hosting.k3s/k3sclusterresource.md))

## Remarks

An in-process WebSocket port-forward bridges the cluster service to a host port when the cluster is ready. Dependent resources receive the service URL via the standard Aspire service-discovery environment variable `services__{name}__url`:

- Host processes receive `http(s)://localhost:{port}`.
- Containers receive `http(s)://host.docker.internal:{port}`.

Use `WaitFor(endpoint)` on dependent resources to ensure the port-forward is active before they start.
