Overview of Amazon VPC Lattice Gateway API Controller
mainGateway and HTTPRoute, to the underlying AWS VPC Lattice infrastructure.repository·main·Indexed 42 days ago
https://github.com/aws/aws-application-networking-k8sA Kubernetes implementation of the Kubernetes Gateway API used to orchestrate AWS VPC Lattice resources. It maps Kubernetes objects like Gateway and HTTPRoute to AWS networking infrastructure and provides custom resources in the application-networking.k8s.aws/v1alpha1 API group, including AccessLogPolicy, IAMAuthPolicy, ServiceExport, ServiceImport, and ServiceNetwork.
Gateway and HTTPRoute, to the underlying AWS VPC Lattice infrastructure.The Amazon VPC Lattice Gateway API Controller is an implementation of the Kubernetes Gateway API. It allows you to manage Amazon VPC Lattice resources—such as VPC Lattice Services, service networks, and Target Groups—using standard Kubernetes APIs and Custom Resource Definitions (CRDs).
When installed in a cluster, the controller watches for Gateway API resources (like Gateway and HTTPRoute) and automatically provisions the corresponding Amazon VPC Lattice objects. This provides a Kubernetes-native experience for managing network connectivity, service discovery, and security without requiring custom code or sidecar proxies.
A ServiceExport resource enables a Kubernetes Service for multi-cluster traffic setup within the AWS Gateway API Controller. When you create a ServiceExport, the controller internally creates a standalone VPC Lattice target group.
Key behaviors:
ServiceImport resource.ServiceExport even without ServiceImport if you only need the VPC Lattice target groups created (e.g., for use in VPC Lattice setups outside of Kubernetes).Note: ServiceExport is not a direct implementation of the Kubernetes Multicluster Service APIs; instead, the AWS Gateway API Controller uses its own version of the resource for Gateway API integration.
GRPCRoute is a custom resource defined in the Kubernetes Gateway API that specifies how gRPC traffic should be routed. It allows for routing rules based on match criteria such as service names and specific gRPC methods. This ensures gRPC traffic is directed to the correct backend services within a Kubernetes environment via VPC Lattice.A ServiceImport is a resource used to refer to a Service or VPC Lattice target group located outside the current cluster. It allows you to distribute traffic across multiple VPCs, multiple clusters, or between EKS-native backends and existing VPC Lattice target groups (such as those pointing to ECS, Lambda, EC2, or ALB).
ServiceImport is used as a backendRef within Gateway API routes (HTTPRoute, GRPCRoute, or TLSRoute). It is not an implementation of the Kubernetes Multicluster Service APIs, but a custom resource used by the AWS Gateway API Controller for VPC Lattice integration.
Key Constraints:
ServiceImport; it must be used as a backendRef in a route.BackendRef ports are not respected; you must use the port annotation on the corresponding ServiceExport instead.ManagedBy, will not register targets on it, and will not delete it.You can use a TargetGroupPolicy to configure protocol, protocol version, and health check settings for a ServiceExport. When a policy targets a ServiceExport, the configuration is automatically propagated to all target groups across all clusters participating in the multi-cluster service mesh.
Protocol Overriding:
If you use exportedPorts, the TargetGroupPolicy settings for protocol and protocolVersion will override the default protocol inferred from the routeType. For example, you can set routeType: HTTP in the ServiceExport but use protocol: HTTPS in the TargetGroupPolicy to enable secure communication between VPC Lattice and your backend pods.
# ServiceExport with HTTP routeType
apiVersion: application-networking.k8s.aws/v1alpha1
kind: ServiceExport
metadata:
name: secure-service
spec:
exportedPorts:
- port: 443
routeType: HTTP # Default would be HTTP/1
---
# TargetGroupPolicy overriding to HTTPS
apiVersion: application-networking.k8s.aws/v1alpha1
kind: TargetGroupPolicy
metadata:
name: https-override
spec:
targetRef:
group: "application-networking.k8s.aws"
kind: ServiceExport
name: secure-service
protocol: HTTPS # Overrides HTTP from routeType
protocolVersion: HTTP2 # Overrides HTTP1 default
healthCheck:
enabled: true
path: "/health"
protocol: HTTPS
protocolVersion: HTTP2
statusMatch: "200-299"The controller uses a finalizer to ensure that Lattice resources are properly cleaned up before the Kubernetes Custom Resource (CR) is removed.
Deletion of a ServiceNetwork CR will be blocked if:
Gateway with the same name exists and is controlled by the Lattice gateway controller.If deletion is blocked due to active associations, the specific Lattice API error message will be surfaced in the CR status field.
The AWS Gateway API controller supports Pod readiness gates to ensure a pod is registered to the VPC Lattice and healthy before it is considered 'Ready' by Kubernetes.
This is critical for achieving zero-downtime rolling deployments, especially when:
Healthy in the VPC Lattice target group.By setting a readiness condition on the pods, the controller prevents a rolling update from terminating old pods until the new pods are confirmed Healthy in the VPC Lattice target group and ready to receive traffic. The condition status is set to True only when the corresponding target in the VPC Lattice target group shows a Healthy state.
If multiple clusters have services with the same name, use annotations to differentiate them in the federation.
application-networking.k8s.aws/service-name annotation on the ServiceExport to point to the actual Kubernetes Service name, while giving the ServiceExport a unique metadata.name.application-networking.k8s.aws/export-name annotation on the ServiceImport to reference the specific ServiceExport name from the remote cluster.# In cluster1 (Exporting)
apiVersion: application-networking.k8s.aws/v1alpha1
kind: ServiceExport
metadata:
name: checkout-cluster1
annotations:
application-networking.k8s.aws/federation: "amazon-vpc-lattice"
application-networking.k8s.aws/service-name: "checkout"
spec:
exportedPorts:
- port: 80
routeType: HTTP
---
# In cluster2 (Importing)
apiVersion: application-networking.k8s.aws/v1alpha1
kind: ServiceImport
metadata:
name: checkout-import-1
annotations:
application-networking.k8s.aws/export-name: "checkout-cluster1"
application-networking.k8s.aws/aws-eks-cluster-name: "cluster1"
spec:
type: ClusterSetIP
ports:
- port: 80
protocol: TCPThe controller enables several networking and security patterns across VPCs and accounts:
A Kubernetes Service defines a logical set of Pods (a microservice) and the policy used to access them. The target Pods are identified via a selector.
ClusterIP (default), NodePort, and LoadBalancer.selector and type fields cannot be updated after the Service is created.ExternalName service type is not supported by this controller.The HTTPRoute resource allows you to define and manage the routing of HTTP and HTTPS traffic within your Kubernetes cluster using the AWS Gateway API Controller. It enables traffic to be directed to backends based on path matching, HTTP methods, and header matching.
sectionName in parentRefs must refer to an http or https listener in the parent Gateway.