k8流量在内部是怎么流动的?
How does k8 traffic flow internally?
我有 LB 的入口和服务。当来自外部的流量首先到达入口,然后它是直接使用入口 LB 进入 pods,还是进入服务并通过选择器获取 pod ip,然后进入 pods?如果是第一种方式,服务有什么用?哪种服务或入口在部署中使用 readinessProbe?
所有设置都在 GCP 中
我是K8网络的新手。
服务类型 LoadBalancer
是您的云提供的外部源,不在 Kubernetes 集群中。他们可以使用节点选择器将请求转发给您的 pods,但您不能制定路径规则或重定向、重写,因为这是由 Ingress 提供的。
Service is an abstraction which defines a logical set of Pods and a policy by which to access them (sometimes this pattern is called a micro-service). The set of Pods targeted by a Service is usually determined by a selector (see below for why you might want a Service without a selector).
Internet
|
[ LoadBalancer ]
--|-----|--
[ Services ]
--| |--
[ Pod1 ] [ Pod2 ]
当您使用 Ingress 时,是入口控制器的 component 控制器,它基本上是一个配置为处理您定义的规则的 pod .
要使用入口,您需要为您的路径配置一个服务,然后该服务将通过配置选择器到达 pods。您可以根据路径、主机名配置一些规则,并将它们重定向到您想要的服务。像这样:
Internet
|
[ Ingress ]
--|-----|--
[ Services ]
--| |--
[ Pod1 ] [ Pod2 ]
Ingress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster. Traffic routing is controlled by rules defined on the Ingress resource.
This article 对公开服务的所有方式进行了很好的解释。
readnessProbe 在您的 pod/deployment 规范中配置,kubelet 负责评估您的容器是否健康。
The kubelet uses readiness probes to know when a Container is ready to start accepting traffic. A Pod is considered ready when all of its Containers are ready. One use of this signal is to control which Pods are used as backends for Services. When a Pod is not ready, it is removed from Service load balancers.
kube-proxy 负责转发 pods 的请求。
例如,如果您在不同的节点中有 2 个 pods,kube-proxy 将处理防火墙规则 (iptables) 并在您的节点之间分配流量。集群中的每个节点都有一个 kube-proxy 运行.
kube-proxy 可以通过 3 种方式配置:userspace mode, iptables mode and ipvs mode.
If kube-proxy is running in iptables mode and the first Pod that’s selected does not respond, the connection fails. This is different from userspace mode: in that scenario, kube-proxy would detect that the connection to the first Pod had failed and would automatically retry with a different backend Pod.
参考文献:
https://kubernetes.io/docs/concepts/services-networking/service/
https://kubernetes.io/docs/concepts/services-networking/ingress/
取决于您的 LoadBalancer 服务是否暴露 Ingress 控制器或您的应用程序Pods(第一种是正确的方法)。
通常Services和Ingresses的使用方式是这样的:
LoadBalancer Service -> Ingress -> ClusterIP Service -> Pods
在这种情况下,来自 Internet 的流量首先会到达您的云提供商的负载均衡器(由 LoadBalancer 服务创建),后者将其转发到 Ingress 控制器(一个或多个 Pods运行 集群中的 NGINX),然后将其转发给您的应用程序 Pods(通过从 ClusterIP 服务获取 Pods' IP 地址)。
不知道你现在有没有这个星座:
Ingress -> LoadBalancer Service -> Pods
在这种情况下,您不需要 LoadBalancer 服务。您只需要一个 Ingress 后面的 ClusterIP 服务,然后您通常使用 LoadBalancer 服务公开 Ingress。
我有 LB 的入口和服务。当来自外部的流量首先到达入口,然后它是直接使用入口 LB 进入 pods,还是进入服务并通过选择器获取 pod ip,然后进入 pods?如果是第一种方式,服务有什么用?哪种服务或入口在部署中使用 readinessProbe?
所有设置都在 GCP 中
我是K8网络的新手。
服务类型 LoadBalancer
是您的云提供的外部源,不在 Kubernetes 集群中。他们可以使用节点选择器将请求转发给您的 pods,但您不能制定路径规则或重定向、重写,因为这是由 Ingress 提供的。
Service is an abstraction which defines a logical set of Pods and a policy by which to access them (sometimes this pattern is called a micro-service). The set of Pods targeted by a Service is usually determined by a selector (see below for why you might want a Service without a selector).
Internet
|
[ LoadBalancer ]
--|-----|--
[ Services ]
--| |--
[ Pod1 ] [ Pod2 ]
当您使用 Ingress 时,是入口控制器的 component 控制器,它基本上是一个配置为处理您定义的规则的 pod . 要使用入口,您需要为您的路径配置一个服务,然后该服务将通过配置选择器到达 pods。您可以根据路径、主机名配置一些规则,并将它们重定向到您想要的服务。像这样:
Internet
|
[ Ingress ]
--|-----|--
[ Services ]
--| |--
[ Pod1 ] [ Pod2 ]
Ingress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster. Traffic routing is controlled by rules defined on the Ingress resource.
This article 对公开服务的所有方式进行了很好的解释。
readnessProbe 在您的 pod/deployment 规范中配置,kubelet 负责评估您的容器是否健康。
The kubelet uses readiness probes to know when a Container is ready to start accepting traffic. A Pod is considered ready when all of its Containers are ready. One use of this signal is to control which Pods are used as backends for Services. When a Pod is not ready, it is removed from Service load balancers.
kube-proxy 负责转发 pods 的请求。
例如,如果您在不同的节点中有 2 个 pods,kube-proxy 将处理防火墙规则 (iptables) 并在您的节点之间分配流量。集群中的每个节点都有一个 kube-proxy 运行.
kube-proxy 可以通过 3 种方式配置:userspace mode, iptables mode and ipvs mode.
If kube-proxy is running in iptables mode and the first Pod that’s selected does not respond, the connection fails. This is different from userspace mode: in that scenario, kube-proxy would detect that the connection to the first Pod had failed and would automatically retry with a different backend Pod.
参考文献:
https://kubernetes.io/docs/concepts/services-networking/service/
https://kubernetes.io/docs/concepts/services-networking/ingress/
取决于您的 LoadBalancer 服务是否暴露 Ingress 控制器或您的应用程序Pods(第一种是正确的方法)。
通常Services和Ingresses的使用方式是这样的:
LoadBalancer Service -> Ingress -> ClusterIP Service -> Pods
在这种情况下,来自 Internet 的流量首先会到达您的云提供商的负载均衡器(由 LoadBalancer 服务创建),后者将其转发到 Ingress 控制器(一个或多个 Pods运行 集群中的 NGINX),然后将其转发给您的应用程序 Pods(通过从 ClusterIP 服务获取 Pods' IP 地址)。
不知道你现在有没有这个星座:
Ingress -> LoadBalancer Service -> Pods
在这种情况下,您不需要 LoadBalancer 服务。您只需要一个 Ingress 后面的 ClusterIP 服务,然后您通常使用 LoadBalancer 服务公开 Ingress。