Skip to content
Docs Try Aspire
Docs Try

KubernetesIngressResource Constructors

Class Constructors 1 member
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.
Constructor(string, KubernetesEnvironmentResource) Section titled Constructor(string, KubernetesEnvironmentResource)
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.
public class KubernetesIngressResource
{
public KubernetesIngressResource(
string name,
KubernetesEnvironmentResource environment)
{
// ...
}
}
name string The name of the ingress resource.
environment KubernetesEnvironmentResource The parent Kubernetes environment resource.

Create an ingress using KubernetesIngressExtensions.AddIngress and configure routes using KubernetesIngressExtensions.WithRoute.

At publish time, the ingress generates a Kubernetes networking.k8s.io/v1 Ingress resource in the Helm chart output with rules derived from the configured routes.

var k8s = builder.AddKubernetesEnvironment("k8s");
var ingress = k8s.AddIngress("public")
.WithIngressClass("nginx");
var api = builder.AddProject<MyApi>("api");
ingress.WithRoute("/api", api.GetEndpoint("http"));