# KubernetesAspireDashboardResourceBuilderExtensions Methods

- Package: [Aspire.Hosting.Kubernetes](/reference/api/csharp/aspire.hosting.kubernetes.md)
- Type: [KubernetesAspireDashboardResourceBuilderExtensions](/reference/api/csharp/aspire.hosting.kubernetes/kubernetesaspiredashboardresourcebuilderextensions.md)
- Kind: `Methods`
- Members: `3`

Provides extension methods for creating Aspire Dashboard resources in the application model.

## WithForwardedHeaders(IResourceBuilder<KubernetesAspireDashboardResource>, bool)

- Name: `WithForwardedHeaders(IResourceBuilder<KubernetesAspireDashboardResource>, bool)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<KubernetesAspireDashboardResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Kubernetes/KubernetesAspireDashboardResourceBuilderExtensions.cs#L128-L130)

Configures whether forwarded headers processing is enabled for the Aspire dashboard container.

```csharp
public static class KubernetesAspireDashboardResourceBuilderExtensions
{
    public static IResourceBuilder<KubernetesAspireDashboardResource> WithForwardedHeaders(
        this IResourceBuilder<KubernetesAspireDashboardResource> builder,
        bool enabled = true)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<KubernetesAspireDashboardResource>`)
  The `ApplicationModel.IResourceBuilder`1` instance.
- `enabled` (`bool`) `optional`
  True to enable forwarded headers, false to disable.

## Returns

`IResourceBuilder<KubernetesAspireDashboardResource>` -- The same `ApplicationModel.IResourceBuilder`1` to allow chaining.

## Remarks

This sets the `ASPIRE_DASHBOARD_FORWARDEDHEADERS_ENABLED` environment variable inside the dashboard container. When enabled, the dashboard will process `X-Forwarded-Host` and `X-Forwarded-Proto` headers which is required when the dashboard is accessed through a reverse proxy or ingress controller.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithOtlpServicePort(IResourceBuilder<KubernetesAspireDashboardResource>, int?, int?)

- Name: `WithOtlpServicePort(IResourceBuilder<KubernetesAspireDashboardResource>, int?, int?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<KubernetesAspireDashboardResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Kubernetes/KubernetesAspireDashboardResourceBuilderExtensions.cs#L97-L109)

Sets the Kubernetes Service ports for the Aspire Dashboard OTLP endpoints.

```csharp
public static class KubernetesAspireDashboardResourceBuilderExtensions
{
    public static IResourceBuilder<KubernetesAspireDashboardResource> WithOtlpServicePort(
        this IResourceBuilder<KubernetesAspireDashboardResource> builder,
        int? grpcPort = null,
        int? httpPort = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<KubernetesAspireDashboardResource>`)
  The `ApplicationModel.IResourceBuilder`1` instance to configure.
- `grpcPort` (`int?`) `optional`
  The Service port for the OTLP gRPC endpoint. If `null`, the Service port defaults to the container port (18889).
- `httpPort` (`int?`) `optional`
  The Service port for the OTLP HTTP endpoint. If `null`, the Service port defaults to the container port (18890).

## Returns

`IResourceBuilder<KubernetesAspireDashboardResource>` -- The `ApplicationModel.IResourceBuilder`1` instance for chaining.

## Remarks

This sets the `port` field on the generated Kubernetes Service for the OTLP endpoints while keeping the `targetPort` as the original container port. Application resources in the cluster send telemetry to these Service ports. Use standard OTLP ports (4317 for gRPC, 4318 for HTTP) if your services are configured with those defaults.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithServicePort(IResourceBuilder<KubernetesAspireDashboardResource>, int?)

- Name: `WithServicePort(IResourceBuilder<KubernetesAspireDashboardResource>, int?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<KubernetesAspireDashboardResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Kubernetes/KubernetesAspireDashboardResourceBuilderExtensions.cs#L67-L73)

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

```csharp
public static class KubernetesAspireDashboardResourceBuilderExtensions
{
    public static IResourceBuilder<KubernetesAspireDashboardResource> WithServicePort(
        this IResourceBuilder<KubernetesAspireDashboardResource> builder,
        int? port = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<KubernetesAspireDashboardResource>`)
  The `ApplicationModel.IResourceBuilder`1` instance to configure.
- `port` (`int?`) `optional`
  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

`IResourceBuilder<KubernetesAspireDashboardResource>` -- The `ApplicationModel.IResourceBuilder`1` instance for chaining.

## 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 [KubernetesEnvironmentResource.DefaultServiceType](/reference/api/csharp/aspire.hosting.kubernetes/kubernetesenvironmentresource/properties.md#defaultservicetype) to `NodePort` or `LoadBalancer`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
