# WithServicePort

- Module: [Aspire.Hosting.Kubernetes](/reference/api/go/aspire.hosting.kubernetes.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: [`KubernetesAspireDashboardResource`](/reference/api/go/aspire.hosting.kubernetes/kubernetesaspiredashboardresource.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/2d325b13709752ba6d9a943635c5e2940a2530c0)

Sets the Kubernetes Service port for the Aspire Dashboard HTTP endpoint.

## Remarks

This sets the `port` field on the generated Kubernetes Service while keeping the
`targetPort` as the original container port. This is useful when placing the dashboard
behind an ingress controller that expects a specific Service port (for example, port 80).
To access the dashboard from outside the cluster, use `kubectl port-forward` or
configure the environment's `DefaultServiceType`
to `NodePort` or `LoadBalancer`.

## Definition

```go
func (KubernetesAspireDashboardResource) WithServicePort(options ...*WithServicePortOptions) KubernetesAspireDashboardResource
```

## Parameters

- `options` (`...*WithServicePortOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*WithServicePortOptions` argument.

- `Port` (`*float64`) -- The Service port number. Cluster-internal clients will connect to this port, which routes to the dashboard's container port (18888). If `null`, the Service port defaults to the container port.

## Returns

[`KubernetesAspireDashboardResource`](/reference/api/go/aspire.hosting.kubernetes/kubernetesaspiredashboardresource.md) -- The resource builder.

Returns a handle; failures surface later via `Err()`.

## Applies to

- [`KubernetesAspireDashboardResource`](/reference/api/go/aspire.hosting.kubernetes/kubernetesaspiredashboardresource.md)
