- Newest
- Most votes
- Most comments
To configure an Ingress resource in EKS that routes traffic based on content-type headers between your HTTP and gRPC services, you'll need to use specific ALB annotations. This is a bit complex because you're trying to route based on headers rather than paths.
Here's how you can approach this:
- First, create an Ingress resource with the appropriate ALB annotations:
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: dual-protocol-ingress annotations: alb.ingress.kubernetes.io/scheme: internet-facing alb.ingress.kubernetes.io/target-type: ip alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS":443}]' alb.ingress.kubernetes.io/ssl-redirect: "443" alb.ingress.kubernetes.io/actions.grpc-route: > {"type":"forward","forwardConfig":{"targetGroups":[{"serviceName":"grpc-service","servicePort":9000,"weight":1}]}} alb.ingress.kubernetes.io/conditions.grpc-route: > [{"field":"http-header","httpHeaderConfig":{"httpHeaderName":"Content-Type","values":["application/grpc","application/grpc+proto"]}}] alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:<region>:<account-id>:certificate/<certificate-id> spec: ingressClassName: alb rules: - host: example.com http: paths: - path: / pathType: Prefix backend: service: name: http-service port: number: 8080 - path: / pathType: Prefix backend: k8s: name: grpc-route port: name: use-annotation
For the gRPC service, you'll also need to add these annotations to ensure proper handling of gRPC traffic:
alb.ingress.kubernetes.io/backend-protocol-version: "GRPC"
This configuration:
- Creates an internet-facing ALB
- Sets up IP-based target groups
- Configures HTTPS on port 443
- Creates a conditional rule that routes traffic with Content-Type headers of "application/grpc" or "application/grpc+proto" to your gRPC service
- Routes all other traffic to your HTTP service
Make sure your gRPC service is properly configured to handle HTTP/2 traffic, as gRPC requires HTTP/2. Also, ensure you have a valid SSL certificate in ACM for your domain, as gRPC requires TLS.
If you're still experiencing issues, check the AWS Load Balancer Controller logs for any errors or misconfiguration details.
Sources
Deploy a gRPC-based application on an Amazon EKS cluster and access it with an Application Load Balancer - AWS Prescriptive Guidance
Beanstalk gRPC communication failure | AWS re:Post
Route application and HTTP traffic with Application Load Balancers - Amazon EKS
Unpacking Cluster Networking for Amazon EKS Hybrid Nodes | AWS re:Post
Relevant content
- asked a year ago
- asked 3 years ago
- asked 2 years ago
- AWS OFFICIALUpdated 3 years ago
