K3sServiceEndpointExtensions Methods
AddServiceEndpoint(IResourceBuilder<K3sClusterResource>, string, string, int, string, string?)Section titled AddServiceEndpoint(IResourceBuilder<K3sClusterResource>, string, string, int, string, string?)extensionIResourceBuilder<K3sServiceEndpointResource>public static class K3sServiceEndpointExtensions{ public static IResourceBuilder<K3sServiceEndpointResource> AddServiceEndpoint( this IResourceBuilder<K3sClusterResource> builder, string name, string serviceName, int servicePort, string @namespace = "default", string? scheme = null) { // ... }}Parameters
builderIResourceBuilder<K3sClusterResource>The k3s cluster resource builder.namestringThe Aspire resource name for this endpoint.serviceNamestring The name of the Kubernetes Service to forward, as it appears in kubectl get svc. servicePortint The port number declared on the Kubernetes Service (the port field, not targetPort). Must be in the range 1–65535. namespacestringoptional The Kubernetes namespace that contains the Service. Defaults to default. schemestring?optional The URL scheme ( http or https) for the injected environment variable. When null (the default), the scheme is inferred from the port: ports 443 and 8443 use https, all others use http. Returns
IResourceBuilder<K3sServiceEndpointResource>A builder for the K3sServiceEndpointResource.Exceptions
ArgumentNullExceptionbuilder, name, or serviceName is null. ArgumentExceptionserviceName or namespace is empty or whitespace. ArgumentOutOfRangeExceptionservicePort is not in the range 1–65535. Remarks
An in-process WebSocket port-forward is started when the cluster becomes ready, binding to 0.0.0.0:{allocatedHostPort} so both host processes and DCP-network containers can reach the service.
The endpoint transitions to Running only after the target Kubernetes Service has at least one ready pod. Sequence chart installs or manifest applies before this resource using WaitForCompletion on HelmReleaseResource or K8sManifestResource to prevent the port-forward from polling indefinitely.
Use WithReference(endpoint) on a dependent resource builder to inject the service URL as services__{name}__url. Host processes receive http(s)://localhost:{port}; containers receive http(s)://host.docker.internal:{port}.