Kubernetes Service Access principle

Source: Internet
Author: User
Tags k8s

There are three types of IP in the k8s cluster:

1: Host's physical NIC IP, e.g. 192.168.255.*

2:CNI the IP of the network card created, such as 172.16.*.*

3: Virtual IP (i.e. Clusterip, cannot ping through, connect via proxy), 172.19.*.*

If you view the network card on any one machine name can see so many network cards. Such as.

Eth0 is the real network card: IP segment 192.168.255.*

The k8s is a network card created to flatten the pod management, and this is 172.16.1.1 so other nodes may be 172.16.2.1,172.16.3.1

Other network cards that see many veth are actually connected to the network card. A veth represents a pod, so the pod IP of this node is 172.16.1.*

Pods of different nodes, such as 172.16.2.5->172.16.1.3, are directly accessible, and the underlying implementation (tunneling technology) can be used without much attention.

The pod itself is stateless. That is, after the pod restart, his IP has changed, so the introduction of a service as the target of services access, the service IP is also a virtual thing, such as a nginx pod, it associated with a service called My-nginx, Then here is a process for access.

1: Any one pod access My-nginx

2: Obtain the cluster IP address from the DNS server configured in/etc/resolv.conf. Can see 172.19.0.10 this as a DNS server, when the cluster installation has been fixed, when the application is created automatically write service and cluster IP such a mapping relationship, then the pod gets my-nginx cluster IP

3:k8s will create a proxy service at each node, created by proxy iptable rules, of course, when Nginx created the rules and created, when the pod connection Culster IP will be forwarded to the Nginx pod IP, So you connect through the service +port, but the direct ping service is not ping, iptable only implement TCP/UDP forwarding

Kubernetes Service Access principle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.