简体   繁体   English

使用 nginx pod 作为反向代理与 nginx 入口的区别

[英]Difference between using nginx pod as reverser proxy vs nginx ingress

So if I have 10 services that I need to expose to the outside world and use path-based routing to connect to different services, I can create an Nginx pod and service type LoadBalancer所以如果我有 10 个服务需要暴露给外界并使用基于路径的路由来连接不同的服务,我可以创建一个 Nginx pod 和服务类型LoadBalancer

I can then create Nginx configurations and can redirect to different services depending upon the URL path.然后我可以创建 Nginx 配置,并可以根据 URL 路径重定向到不同的服务。 After exploring more, I came to know about Nginx ingress which can also do the same.在探索更多之后,我开始了解 Nginx ingress 也可以做同样的事情。 What is the difference between the two approaches and which approach is better?这两种方法有什么区别,哪种方法更好?

In both cases, you are running an Nginx reverse proxy in a Kubernetes pod inside the cluster.在这两种情况下,您都在集群内的 Kubernetes pod 中运行 Nginx 反向代理。 There is not much technical difference between them.它们之间没有太大的技术差异。

If you run the proxy yourself, you have complete control over the Nginx version and the configuration, which could be desirable if you have very specific needs and you are already an Nginx expert.如果您自己运行代理,您可以完全控制 Nginx 版本和配置,如果您有非常特殊的需求并且您已经是 Nginx 专家,这可能是可取的。 The most significant downside is that you need to manually reconfigure and redeploy the central proxy if you add or change a service.最显着的缺点是,如果您添加或更改服务,则需要手动重新配置和重新部署中央代理。

If you use Kubernetes ingress, the cluster maintains the Nginx configuration for you, and it regenerates it based on Ingress objects that can be deployed per-service.如果您使用 Kubernetes 入口,集群会为您维护 Nginx 配置,并根据可以为每个服务部署的入口对象重新生成它。 This is easier to maintain if you are not an Nginx expert, and you can add and remove services without touching the centralized configuration.如果您不是 Nginx 专家,这更易于维护,并且您可以在不接触集中配置的情况下添加和删除服务。

The Kubernetes ingress system in principle can also plug in alternate proxies; Kubernetes ingress 系统原则上也可以插入备用代理; it is not limited to Nginx.它不仅限于 Nginx。 However, its available configuration is somewhat limited, and some of the other proxies I've looked at recommend using their own custom Kubernetes resources instead of the standard Ingress objects.然而,它的可用配置有些有限,我看过的其他一些代理建议使用他们自己的自定义 Kubernetes 资源而不是标准的 Ingress 对象。

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

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