KubernetesGatewayResource
Class net8.0
Represents a Kubernetes Gateway API Gateway as a first-class resource in the Aspire application model. A Gateway defines listeners (ports, protocols, TLS) and HTTPRoutes attach to it for routing.
namespace Aspire.Hosting.Kubernetes;
public class KubernetesGatewayResource : Aspire.Hosting.ApplicationModel.Resource, Aspire.Hosting.ApplicationModel.IResource, Aspire.Hosting.ApplicationModel.IResourceWithParent, Aspire.Hosting.ApplicationModel.IResourceWithParent<Aspire.Hosting.Kubernetes.KubernetesEnvironmentResource>{ // ...} ResourceIResourceIResourceWithParentIResourceWithParent<KubernetesEnvironmentResource>
Remarks
Section titled Remarks Create a gateway using KubernetesGatewayExtensions.AddGateway and configure routes using KubernetesGatewayExtensions.WithRoute.
At publish time, the gateway generates a gateway.networking.k8s.io/v1 Gateway resource with auto-inferred listeners and one or more HTTPRoute resources in the Helm chart output.
Constructors1
Section titled ConstructorsProperties2
Section titled PropertiesGatewayClassNameget; setReferenceExpression? Gets or sets the GatewayClass name that selects which controller implementation handles this gateway.
Parentget Gets the parent Kubernetes environment resource.
Examples
Section titled Examplesvar k8s = builder.AddKubernetesEnvironment("k8s");var gateway = k8s.AddGateway("public") .WithGatewayClass("azure-alb-external");
var api = builder.AddProject<MyApi>("api");gateway.WithRoute("/api", api.GetEndpoint("http"));