- 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.
- 大學(xué)計算機信息技術(shù)導(dǎo)論
- Introduction to DevOps with Kubernetes
- 會聲會影X5視頻剪輯高手速成
- Getting Started with Clickteam Fusion
- TestStand工業(yè)自動化測試管理(典藏版)
- Dreamweaver CS3網(wǎng)頁設(shè)計50例
- 大數(shù)據(jù)時代的數(shù)據(jù)挖掘
- Multimedia Programming with Pure Data
- 四向穿梭式自動化密集倉儲系統(tǒng)的設(shè)計與控制
- Building a BeagleBone Black Super Cluster
- R Machine Learning Projects
- Artificial Intelligence By Example
- Data Analysis with R(Second Edition)
- Cloudera Hadoop大數(shù)據(jù)平臺實戰(zhàn)指南
- 從零開始學(xué)ASP.NET