kubernetes:在 LoadBalancer 服务上设置 Https
kubernetes: set Https on LoadBalancer service
我到处都读到要设置 Https 以访问 kubernetes 集群,你需要有一个 Ingress 而不仅仅是一个 LoadBalancer 服务,它也将集群暴露在外面。
我的问题非常理论化:如果一个 Ingress(它确实是)由一个 LoadBalancer 服务、一个 Controller(一个deployment/pod 例如一个 nginx 图像)和一组 规则 (为了正确代理集群内的传入请求),为什么不能我们在 LoadBalancer 前面设置 Https 而不是 Ingress?
作为练习的标题我自己单独构建了三个组件(一个 LoadBalancer,一个 Controller/API 具有一些规则的网关):这三个一起已经得到传入的请求并根据特定规则在集群内代理它们,所以我可以说,我自己构建了一个 Ingress。难道我不能在这个结构中添加https吗,我是否需要在集群前面设置一个冗余部分(一个k8s Ingress)?
不确定我是否完全理解你的问题。
在 Kubernetes
中,您使用 service, which is well described here. Good compare of all services
can be found in this article 暴露了您 cluster/application。
当您创建服务类型 LoadBalancer
时,它会创建 L4 LoadBalancer
。 L4 知道 source IP:port
和 destination IP:port
等信息,但没有任何关于应用层(第 7 层)的信息。 HTTP/HTTPS LoadBalancers
在第 7 层,因此他们知道应用程序。可以找到有关负载平衡的更多信息 here。
Layer 4-based load balancing to direct traffic based on data from network and transport layer protocols, such as IP address and TCP or UDP port
Layer 7-based load balancing to add content-based routing decisions based on attributes, such as the HTTP header and the uniform resource identifier
Ingress 类似于支持 L7 的 LoadBalancer
。
The Ingress is a Kubernetes resource that lets you configure an HTTP load balancer for applications running on Kubernetes, represented by one or more Services. Such a load balancer is necessary to deliver those applications to clients outside of the Kubernetes cluster.
Ingress
也提供了很多优点。例如,如果您的集群中有许多服务,您可以创建一个 LoadBalancer
和 Ingress
,这将能够将流量重定向到适当的服务,并允许您降低创建一些 LoadBalancers
的成本.
为了使 Ingress
资源正常工作,集群必须具有 ingress controller
运行。
The Ingress controller is an application that runs in a cluster and configures an HTTP load balancer according to Ingress resources. The load balancer can be a software load balancer running in the cluster or a hardware or cloud load balancer running externally. Different load balancers require different Ingress controller implementations.
In the case of NGINX, the Ingress controller is deployed in a pod along with the load balancer.
有很多Ingress Controllers,但最受欢迎的是Nginx Ingress Controller
所以我的回答是:
why can't we set Https in front of a LoadBalancer instead of an Ingress?
这不仅涉及使用 HTTPS 保护您的集群,还涉及 Ingress 提供的许多功能和特性。
有关 HTTP(S) 负载平衡的非常好的文档可以在 GKE Docs 上找到。
我到处都读到要设置 Https 以访问 kubernetes 集群,你需要有一个 Ingress 而不仅仅是一个 LoadBalancer 服务,它也将集群暴露在外面。
我的问题非常理论化:如果一个 Ingress(它确实是)由一个 LoadBalancer 服务、一个 Controller(一个deployment/pod 例如一个 nginx 图像)和一组 规则 (为了正确代理集群内的传入请求),为什么不能我们在 LoadBalancer 前面设置 Https 而不是 Ingress?
作为练习的标题我自己单独构建了三个组件(一个 LoadBalancer,一个 Controller/API 具有一些规则的网关):这三个一起已经得到传入的请求并根据特定规则在集群内代理它们,所以我可以说,我自己构建了一个 Ingress。难道我不能在这个结构中添加https吗,我是否需要在集群前面设置一个冗余部分(一个k8s Ingress)?
不确定我是否完全理解你的问题。
在 Kubernetes
中,您使用 service, which is well described here. Good compare of all services
can be found in this article 暴露了您 cluster/application。
当您创建服务类型 LoadBalancer
时,它会创建 L4 LoadBalancer
。 L4 知道 source IP:port
和 destination IP:port
等信息,但没有任何关于应用层(第 7 层)的信息。 HTTP/HTTPS LoadBalancers
在第 7 层,因此他们知道应用程序。可以找到有关负载平衡的更多信息 here。
Layer 4-based load balancing to direct traffic based on data from network and transport layer protocols, such as IP address and TCP or UDP port
Layer 7-based load balancing to add content-based routing decisions based on attributes, such as the HTTP header and the uniform resource identifier
Ingress 类似于支持 L7 的 LoadBalancer
。
The Ingress is a Kubernetes resource that lets you configure an HTTP load balancer for applications running on Kubernetes, represented by one or more Services. Such a load balancer is necessary to deliver those applications to clients outside of the Kubernetes cluster.
Ingress
也提供了很多优点。例如,如果您的集群中有许多服务,您可以创建一个 LoadBalancer
和 Ingress
,这将能够将流量重定向到适当的服务,并允许您降低创建一些 LoadBalancers
的成本.
为了使 Ingress
资源正常工作,集群必须具有 ingress controller
运行。
The Ingress controller is an application that runs in a cluster and configures an HTTP load balancer according to Ingress resources. The load balancer can be a software load balancer running in the cluster or a hardware or cloud load balancer running externally. Different load balancers require different Ingress controller implementations. In the case of NGINX, the Ingress controller is deployed in a pod along with the load balancer.
有很多Ingress Controllers,但最受欢迎的是Nginx Ingress Controller
所以我的回答是:
why can't we set Https in front of a LoadBalancer instead of an Ingress?
这不仅涉及使用 HTTPS 保护您的集群,还涉及 Ingress 提供的许多功能和特性。
有关 HTTP(S) 负载平衡的非常好的文档可以在 GKE Docs 上找到。