# KubernetesIngressResource

- Module: [Aspire.Hosting.Kubernetes](/reference/api/typescript/aspire.hosting.kubernetes.md)
- Version: `13.4.0-preview.1.26281.18`
- Kind: `handle`
- Source: [GitHub](https://github.com/microsoft/aspire)

Represents a Kubernetes Ingress as a first-class resource in the Aspire application model. An Ingress defines HTTP routing rules that direct external traffic to services in the cluster.

## Definition

```typescript
interface KubernetesIngressResource
  extends IResource,
    IResourceWithParent,
    KubernetesEnvironmentResource]] {
  withDefaultBackend(endpoint: EndpointReference): KubernetesIngressResource;
  withHostname(hostname: string): KubernetesIngressResource;
  withIngressAnnotation(
      key: string,
      value: string): KubernetesIngressResource;
  withIngressAnnotationParam(
      key: string,
      value: ParameterResource): KubernetesIngressResource;
  withIngressClass(className: string): KubernetesIngressResource;
  withIngressClassParam(className: ParameterResource): KubernetesIngressResource;
  withIngressHostAndPath(
      host: string,
      path: string,
      endpoint: EndpointReference,
      pathType?: IngressPathType): KubernetesIngressResource;
  withIngressHostnameParam(hostname: ParameterResource): KubernetesIngressResource;
  withIngressPath(
      path: string,
      endpoint: EndpointReference,
      pathType?: IngressPathType): KubernetesIngressResource;
  withIngressTlsAuto(): KubernetesIngressResource;
  withIngressTlsParam(secretName: ParameterResource): KubernetesIngressResource;
  withTls(secretName: string): KubernetesIngressResource;
}
```

## Methods

- [withDefaultBackend](/reference/api/typescript/aspire.hosting.kubernetes/kubernetesingressresource/withdefaultbackend.md) -- `method` -- Sets the default backend for the ingress. The default backend handles requests that do not match any of the defined routing rules.
    ```typescript
  withDefaultBackend(endpoint: EndpointReference): KubernetesIngressResource
  ```
- [withHostname](/reference/api/typescript/aspire.hosting.kubernetes/kubernetesingressresource/withhostname.md) -- `method` -- Adds a hostname that this ingress matches. Multiple hostnames can be added by calling this method repeatedly. If no hostnames are configured, the ingress matches all hosts.
    ```typescript
  withHostname(hostname: string): KubernetesIngressResource
  ```
- [withIngressAnnotation](/reference/api/typescript/aspire.hosting.kubernetes/kubernetesingressresource/withingressannotation.md) -- `method` -- Adds a Kubernetes metadata annotation to the generated Ingress resource. These are key-value pairs in the `metadata.annotations` field of the K8S Ingress, commonly used to configure ingress controller-specific behavior.
    ```typescript
  withIngressAnnotation(key: string, value: string): KubernetesIngressResource
  ```
- [withIngressAnnotationParam](/reference/api/typescript/aspire.hosting.kubernetes/kubernetesingressresource/withingressannotationparam.md) -- `method` -- Adds a Kubernetes metadata annotation with a parameter value that will be resolved at deploy time.
    ```typescript
  withIngressAnnotationParam(key: string, value: ParameterResource): KubernetesIngressResource
  ```
- [withIngressClass](/reference/api/typescript/aspire.hosting.kubernetes/kubernetesingressresource/withingressclass.md) -- `method` -- Sets the Kubernetes ingress class name that selects which ingress controller handles this ingress resource.
    ```typescript
  withIngressClass(className: string): KubernetesIngressResource
  ```
- [withIngressClassParam](/reference/api/typescript/aspire.hosting.kubernetes/kubernetesingressresource/withingressclassparam.md) -- `method` -- Sets the Kubernetes ingress class name using a parameter that will be resolved at deploy time.
    ```typescript
  withIngressClassParam(className: ParameterResource): KubernetesIngressResource
  ```
- [withIngressHostAndPath](/reference/api/typescript/aspire.hosting.kubernetes/kubernetesingressresource/withingresshostandpath.md) -- `method` -- Adds a host-scoped path rule to the ingress. The rule matches traffic for the specified host and path, forwarding it to the given endpoint's backing Kubernetes service.
    ```typescript
  withIngressHostAndPath(host: string, path: string, endpoint: EndpointReference, pathType?: IngressPathType): KubernetesIngressResource
  ```
- [withIngressHostnameParam](/reference/api/typescript/aspire.hosting.kubernetes/kubernetesingressresource/withingresshostnameparam.md) -- `method` -- Adds a hostname using a parameter that will be resolved at deploy time.
    ```typescript
  withIngressHostnameParam(hostname: ParameterResource): KubernetesIngressResource
  ```
- [withIngressPath](/reference/api/typescript/aspire.hosting.kubernetes/kubernetesingressresource/withingresspath.md) -- `method` -- Adds a path-based rule to the ingress. The rule matches all hosts and forwards traffic matching the specified path to the given endpoint's backing Kubernetes service.
    ```typescript
  withIngressPath(path: string, endpoint: EndpointReference, pathType?: IngressPathType): KubernetesIngressResource
  ```
- [withIngressTlsAuto](/reference/api/typescript/aspire.hosting.kubernetes/kubernetesingressresource/withingresstlsauto.md) -- `method` -- Configures TLS termination with an auto-generated secret name derived from the ingress name.
    ```typescript
  withIngressTlsAuto(): KubernetesIngressResource
  ```
- [withIngressTlsParam](/reference/api/typescript/aspire.hosting.kubernetes/kubernetesingressresource/withingresstlsparam.md) -- `method` -- Configures TLS termination using a parameter for the secret name.
    ```typescript
  withIngressTlsParam(secretName: ParameterResource): KubernetesIngressResource
  ```
- [withTls](/reference/api/typescript/aspire.hosting.kubernetes/kubernetesingressresource/withtls.md) -- `method` -- Configures TLS for a Kubernetes Ingress using a K8S secret
    ```typescript
  withTls(secretName: string): KubernetesIngressResource
  ```
