简体   繁体   English

将kubernetes流量暴露给80(http)和443(https)

[英]Expose kubernetes traffic to 80 (http) and 443 (https)

Currently, my kubernetes cluster (sitting on AWS ) has a simple setup with a Deployment , which has a web container listens on 80 and 443 . 目前,我的kubernetes集群(坐在AWS上 )有一个简单的设置, Deployment有一个Web容器侦听80443

The cluster also has a NodePort service, which exposes the traffic to public on ports 30080 and 30443 . 群集还具有NodePort服务,该服务将流量暴露给端口3008030443上的公共流量。 I am trying to figure out a way to accept public traffic on 80 and 443 . 我试图找出一种接受80443公共交通的方法。

What could be a good way to do that? 有什么好办法呢?

My thoughts about possible solutions : 我对可能解决方案的看法

  1. Manually configure a ELB on AWS, which could map 80 and 443 traffic to 30080 and 30443 ports. 在AWS上手动配置ELB ,可以将80443流量映射到3008030443端口。

  2. Use LoadBalancer supported by kubernetes , but I have some issues of integrating my cluster with AWS described here . 使用kubernetes支持的LoadBalancer ,但是我在此处描述了将集群与AWS集成的一些问题。 I'd rather try other possible solutions than being stuck on this one. 我宁愿尝试其他可能的解决方案而不是被困在这个问题上。

  3. I've seen many posts talking about Ingress service, but various posts have totally different setup. 我看过很多关于Ingress服务的帖子,但各种帖子都有完全不同的设置。 I wonder what could be a good use case for Ingress in my setup. 我想知道在我的设置中什么可能是Ingress一个很好的用例。 Is Ingress supposed to replace my NodePort service in my case? 在我的情况下Ingress应该替换我的NodePort服务吗?

Thanks 谢谢

As soon as the NodePort service is bound to specified ports on all cluster nodes, you just need to deliver traffic to any of these nodes, or to all of them. 只要NodePort服务绑定到所有群集节点上的指定端口,您只需将流量传递到任何这些节点或所有节点。 Sometimes it could lead to additional delay, but from the connectivity perspective, it should work fine. 有时它可能会导致额外的延迟,但从连接的角度来看,它应该可以正常工作。

You can configure Load Balancer manually, then add all cluster nodes to its pool and configure health checks for them to exclude a node from the pool when a particular node fails. 您可以手动配置Load Balancer ,然后将所有群集节点添加到其池中,并为它们配置运行状况检查,以便在特定节点发生故障时从池中排除节点。

Ingress actually works in a similar way. Ingress实际上以类似的方式工作。 All traffic that comes to a specific port of any node is forwarded to the Ingress pod . 到达任何节点的特定端口的所有流量都将转发到Ingress pod Ingress controller looks for created Ingress objects and configures the Ingress pod according to the specifications in these objects. Ingress控制器查找创建的Ingress对象,并根据这些对象中的规范配置Ingress pod Actually, Ingress controller and Ingress pod in my example are the same thing. 实际上,我的例子中的Ingress控制器Ingress pod是一回事。

Ingress can provide additional logic for managing the traffic on the HTTP level, like path based routing, adjusting the request before sending it to the service, serving like SSL endpoint, etc. Ingress可以提供额外的逻辑来管理HTTP级别的流量,如基于路径的路由,在将请求发送到服务之前调整请求,提供SSL端点等服务。
But anyway, you should deliver external traffic to the nodes somehow. 但无论如何,你应该以某种方式向节点提供外部流量。 At this point, we are returning to the Load Balancer configuration. 此时,我们将返回Load Balancer配置。

In some cases, when your cluster is deployed on the cloud that provides Load Balancer service, Ingress controller takes care about creating cloud Load Balancer also. 在某些情况下,当您的群集部署在提供Load Balancer服务的云上时,Ingress控制器也会负责创建云负载均衡器

Did you use kops to deploy your Kubernetes cluster on AWS? 您是否使用kops在AWS上部署Kubernetes集群?

Usually, kops create a cluster that integrates with AWS without any problems, so you can use the LoadBalancer type of Service. 通常,kops会创建一个与AWS集成而没有任何问题的集群,因此您可以使用LoadBalancer类型的服务。 Doing everything manually you can make small configuration mistake that would be hard to find and correct. 手动执行所有操作可能会导致很难找到并纠正的小配置错误。

Please check out the very good article: 请查看非常好的文章:

How to create Ingress on AWS: 如何在AWS上创建Ingress:

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

相关问题 我的 https:443 服务器如何为 http:80 提供服务? - How is my https:443 server serving http:80 also? 暴露非80或443端口的AWS - Expose non 80 or 443 port on aws ElasticBeanstalk 在具有 Terraform 的共享 ALB 中使用 HTTPS:443 而不是 HTTP:80 创建默认侦听器规则 - ElasticBeanstalk Create Default Listener Rule with HTTPS:443 instead of HTTP:80 in Shared ALB with Terraform 将 http 流量重定向到 https - Redirect http traffic to https 在ELB上使用Nginx将HTTP流量重定向到https - Redirect http traffic to https using Nginx on ELB Nginx不会将流量从http重定向到https - Nginx not redirecting traffic from http to https 使用AWS ELB将所有http流量重新路由到https - Rerouting all http traffic to https with AWS ELB AWS EC2:无法使用letsencrypt和nginx通过docker到达端口80或443(https) - AWS EC2: Cannot reach port 80 or 443 (https) using letsencrypt and nginx via docker 在AWS上使用HTTPS将Kubernetes部署向世界公开的方式是什么? - What's the way to expose a Kubernetes deployment to the world using HTTPS on AWS? mod_rewrite-明确请求HTTP时,端口80不会更改为443 - mod_rewrite - Port 80 does not change to 443 when HTTP is explicitly requested
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM