- Getting Started with Kubernetes
- Jonathan Baier Jesse White
- 394字
- 2021-06-10 19:47:13
Advanced services
Let's explore the IP strategy as it relates to services and communication between containers. If you recall, in the Services section of Chapter 2, Pods, Services, Replication Controllers, and Labels, you learned that Kubernetes is using kube-proxy to determine the proper pod IP address and port serving each request. Behind the scenes, kube-proxy is actually using virtual IPs and iptables to make all this magic work.
kube-proxy now has two modes—userspace and iptables. As of now, 1.2 iptables is the default mode. In both modes, kube-proxy is running on every host. Its first duty is to monitor the API from the Kubernetes master. Any updates to services will trigger an update to iptables from kube-proxy. For example, when a new service is created, a virtual IP address is chosen and a rule in iptables is set, which will direct its traffic to kube-proxy via a random port. Thus, we now have a way to capture service-destined traffic on this node. Since kube-proxy is running on all nodes, we have cluster-wide resolution for the service VIP (short for virtual IP). Additionally, DNS records can point to this VIP as well.
In the userspace mode, we have a hook created in iptables, but the proxying of traffic is still handled by kube-proxy. The iptables rule is only sending traffic to the service entry in kube-proxy at this point. Once kube-proxy receives the traffic for a particular service, it must then forward it to a pod in the service's pool of candidates. It does this using a random port that was selected during service creation.
Refer to the following diagram for an overview of the flow:

In the iptables mode, the pods are coded directly in the iptable rules. This removes the dependency on kube-proxy for actually proxying the traffic. The request will go straight to iptables and then on to the pod. This is faster and removes a possible point of failure. Readiness probe, as we discussed in the Health Check section of Chapter 2, Pods, Services, Replication Controllers, and Labels, is your friend here as this mode also loses the ability to retry pods.
- 電力自動化實用技術問答
- 網絡服務器架設(Windows Server+Linux Server)
- Hands-On Machine Learning on Google Cloud Platform
- 計算機網絡應用基礎
- Security Automation with Ansible 2
- 機器學習流水線實戰
- Spark大數據技術與應用
- 基于ARM 32位高速嵌入式微控制器
- 網絡化分布式系統預測控制
- 基于32位ColdFire構建嵌入式系統
- 面向對象程序設計綜合實踐
- Hands-On Data Warehousing with Azure Data Factory
- R Machine Learning Projects
- 嵌入式Linux系統實用開發
- Mastering Predictive Analytics with scikit:learn and TensorFlow