简体   繁体   English

通过 API 网关公开在 EKS 中运行的 Kubernetes 服务

[英]Expose Kubernetes services running in EKS through API Gateway

I am new to Kubernetes and AWS and exploring different AWS technologies for a project.我是 Kubernetes 和 AWS 的新手,正在为一个项目探索不同的 AWS 技术。 One thing I am doing as part of that is to see how we can have routes in API Gateway connect to an EKS cluster (in a VPC).作为其中的一部分,我正在做的一件事是查看如何让 API Gateway 中的路由连接到 EKS 集群(在 VPC 中)。

This is what I have working:这就是我的工作:

  • An EKS Cluster EKS 集群
  • In the EKS Cluster I have nginx ingress-controller running在 EKS 集群中,我运行了 nginx 入口控制器
  • I have an EC2 inside the VPC and verified that I can reach a service running in the cluster through EC2 by using the ingress-controller url我在 VPC 中有一个 EC2,并验证我可以使用 ingress-controller url 通过 EC2 访问在集群中运行的服务

This is what I am trying:这就是我正在尝试的:

  • I tried to create an API Gateway route to access the same service using the ingress-controller url -> To achieve that, I am trying the steps here (because my cluster is in a VPC): https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-nlb-for-vpclink-using-console.html我尝试使用 ingress-controller url 创建 API 网关路由以访问相同的服务 -> 为此,我正在尝试此处的步骤(因为我的集群位于 VPC 中): https : //docs.aws.amazon .com/apigateway/latest/developerguide/set-up-nlb-for-vpclink-using-console.html
  • One thing that is not clear to me is that, how do I specify the ingress-controller url as a target for the NLB?我不清楚的一件事是,如何将入口控制器 url 指定为 NLB 的目标? The only targets that I can specify are EC2 instances, but I want to direct the traffic through the ingress-controller (which is a service of type loadbalancer in K8s).我可以指定的唯一目标是 EC2 实例,但我想通过入口控制器(这是 K8s 中的负载均衡器类型的服务)引导流量。

If I am doing this wrong way, please advice the right way of exposing EKS cluster in API Gateway through the nginx ingress controller.如果我这样做是错误的,请建议通过 nginx 入口控制器在 API 网关中公开 EKS 集群的正确方法。 Thanks!谢谢!

I have found the problem.我找到了问题所在。 When using nginx-ingress-controller, I just had to specify the annotation that it is of type "nlb"使用 nginx-ingress-controller 时,我只需要指定它的类型为“nlb”的注释

service.beta.kubernetes.io/aws-load-balancer-type: nlb service.beta.kubernetes.io/aws-load-balancer-type: nlb

Once I deploy the ingress controller with this annotation, it automatically creates an nlb in aws and sets the target according to the ingress defined!一旦我使用此注释部署入口控制器,它会自动在 aws 中创建一个 nlb 并根据定义的入口设置目标! I was creating a new nlb myself and then trying to point to the ingress-controller which is not needed (nor the right way).我自己创建了一个新的 nlb,然后尝试指向不需要的入口控制器(也不是正确的方法)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM