I'm a beginner in both Terraform and Kubernetes, and I'm facing an issue with routing between an AWS EKS cluster and an API Gateway. I've set up an internal Network LoadBalancer service in Kubernetes that connects to the API Gateway using a VPC Link. However, I'm encountering a problem where instead of routing the request to the root URL of my application, it's sending a request to /dev/echo at the pod level. As a result, I'm getting a returned 404 error because the page is not available at that URL.
Here the log on pod
Here are the relevant components:
Load Balancer Service File (Kubernetes):
apiVersion: v1
kind: Service
metadata:
name: echoserver
namespace: default
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: nlb-ip
service.beta.kubernetes.io/aws-load-balancer-scheme: internal
spec:
ports:
- port: 80
protocol: TCP
type: LoadBalancer
selector:
run: php-apache
Terraform Code for VPC Link Integration (AWS API Gateway):
resource "aws_apigatewayv2_integration" "eks" {
api_id = aws_apigatewayv2_api.main.id
integration_uri = "arn:aws:elasticloadbalancing:ap-south-1:256807339053:listener/net/k8s-default-echoserv-63ab2d9787/45a287074471516b/401efbd2b547f71b"
integration_type = "HTTP_PROXY"
integration_method = "ANY"
connection_type = "VPC_LINK"
connection_id = aws_apigatewayv2_vpc_link.eks.id
}
resource "aws_apigatewayv2_route" "get_echo" {
api_id = aws_apigatewayv2_api.main.id
route_key = "GET /echo"
target = "integrations/${aws_apigatewayv2_integration.eks.id}"
}
request_parameters: This block enables configuration of request parameter mappings.
resource "aws_apigatewayv2_integration" "eks" {
api_id = aws_apigatewayv2_api.main.id
integration_uri = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
integration_type = "HTTP_PROXY"
integration_method = "ANY"
connection_type = "VPC_LINK"
connection_id = aws_apigatewayv2_vpc_link.eks.id
request_parameters = {
"overwrite:path" = "/"
}
}