简体   繁体   English

api 网关模式微服务-本地开发

[英]api gateway pattern microservices - local development

My question is regarding utilizing the API gateway pattern with microservices as it relates to local development on individual developer machines.我的问题是关于将 API 网关模式与微服务结合使用,因为它与单个开发人员机器上的本地开发有关。

We have a small microservice architecture setup which consists of an API gateway (We were using Envoy but are flipping to NGINX) with a single microservice behind the gateway (soon to be many more microservices).我们有一个小型微服务架构设置,其中包含一个 API 网关(我们使用 Envoy,但正在转向 NGINX),网关后面有一个微服务(很快就会有更多微服务)。

This is a very basic microservice environment we are using to test out our microservice architecuture including our API gateway and K8s deployment to QA.这是一个非常基本的微服务环境,我们用来测试我们的微服务架构,包括我们的 API 网关和 K8s 部署到 QA。

The API gateway and microservice are containerized into docker containers and are launched on local development machines (visual studio/c# ) utilizing docker compose right now. API 网关和微服务被容器化到 docker 容器中,并立即在使用 docker 组合的本地开发机器 (visual studio/c#) 上启动。

When we docker compose locally we spin up both the api gateway and the microservice(s) which sit behind the gateway.当我们 docker 在本地编写时,我们同时启动 api 网关和位于网关后面的微服务。 On our local dev machines we then test calls through the api gateway container so that developers can verify the api gateway is configured properly and flowing traffic as expected through the microservice(s) sitting behind it.然后,在我们的本地开发机器上,我们通过 api 网关容器测试调用,以便开发人员可以验证 api 网关的配置是否正确,并通过位于其后面的微服务按预期流动流量。

We were curious ( Heres the Question) if other dev teams using an API Gateway pattern typically launch the api gateway locally when developing on dev machines and test the gateway on their local machines prior to pushing the containers to a QA environment.我们很好奇(这是问题),如果其他使用 API 网关模式的开发团队通常在开发机器上开发时在本地启动 api 网关,并在将容器推送到 QA 环境之前在其本地机器上测试网关。

We thought the NGINX API gateway would deploy directly into Kubernetes which we would like to run in our QA/Prod environments and we felt that local developer testing of the traffic through the API Gateway would be helpful prior to deploying to K8s in QA. We thought the NGINX API gateway would deploy directly into Kubernetes which we would like to run in our QA/Prod environments and we felt that local developer testing of the traffic through the API Gateway would be helpful prior to deploying to K8s in QA.

However, NGINX appears to have a separate ingress controller image which is used in Kubernetes and the configuration of the API gateway seems that it may not match the configuration of the NGInX ingress controller. However, NGINX appears to have a separate ingress controller image which is used in Kubernetes and the configuration of the API gateway seems that it may not match the configuration of the NGInX ingress controller. So we are second guessing ourselves as to whether it is beneficial to launch the API gateway at all locally on our development machines while doing development or not.因此,我们在进行第二次猜测,是否在开发时在我们的开发机器上本地启动 API 网关是否有益。 We'd like to hear what other teams do.我们想听听其他团队是怎么做的。

Running it locally is a good approach when your gateway is difficult to debug when running on remote machines.当您的网关在远程机器上运行时难以调试时,在本地运行它是一种好方法。

To have a good distributed developer experience, I think, is necessary to have a good instrumentation to log and validate all the api gateway routes and it's behaviors.我认为,要获得良好的分布式开发人员体验,就必须拥有良好的工具来记录和验证所有 api 网关路由及其行为。

Without that it could be painful.没有它可能会很痛苦。 Local debugging can lack some of real infrastructure scenarios.本地调试可能缺少一些真实的基础架构场景。 And discovering it in production is not an option:)在生产中发现它不是一种选择:)

Adding to Kubernetes part, NGINX Ingress controller is generally used as it handles most API gateway use cases in Kubernetes. Adding to Kubernetes part, NGINX Ingress controller is generally used as it handles most API gateway use cases in Kubernetes. But there are cases, when both an Ingress controller and an API gateway can be used, here's some useful info on it: https://www.nginx.com/blog/how-do-i-choose-api-gateway-vs-ingress-controller-vs-service-mesh/ But there are cases, when both an Ingress controller and an API gateway can be used, here's some useful info on it: https://www.nginx.com/blog/how-do-i-choose-api-gateway-vs -ingress-controller-vs-service-mesh/

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

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