Chapter 24, Nine Analysis takes you to easily explode Istio-k8s traffic into the hostNetwork of the cluster

Series of articles:


General Catalog Index: Nine Analysis Takes You Easy to Complete the Istio Service Grid Series Tutorial

table of Contents

1 Introduction

2 Invitation

3 k8s traffic enters cluster mode

4 hostNetwork sample

5 hostNetwork impact

    5.1 Pod IP and Port

    5.2 Number of nodes and number of pod copies

6 hostNetwork usage scenarios


1 Introduction

        If you have any questions about the blog, please let me know.1.png


2 Invitation

        You can search for "Nine Analysis" from station b to get free, more vivid video materials:clipboard2.png


3 k8s traffic enters cluster mode

        If the traffic outside the k8s cluster is going to enter k8s, there are usually the following ways:

hostNetwork

NodePort

ClusterIP

LoadBalancer

Ingress

hostPort

        This section focuses on the hostNetwork method.


4 hostNetwork sample

        Screenshot below:clipboard3.png

        hostNetwork can only act on Pods. If the Pod opens hostNetwork: true, the Pod directly uses the network space of the current host. If the process in the Pod needs to open the network listening interface, it will be directly opened on the current host. As shown in the figure above, a busybox container is running in a Pod. The httpd process in the busybox container will open the 8888 network listening port, and the port will be directly opened on the host where the Pod is located.


5 hostNetwork impact

5.1 Pod IP and Port

        If the Pod adopts a host network strategy (hostNetwork: true), its IP is the host's IP, and its Port is the host's Port. As shown below:clipboard4.png

5.2 Number of nodes and number of pod copies

        If the pod adopts a host network strategy (hostNetwork: true), the number of pod copies cannot exceed the number of nodes, because the pod will eventually use the network namespace of the node. If the number of pod copies is greater than the number of nodes, some pods cannot be created successfully. As shown below:clipboard5.png

        It can be seen from the above figure that because of the use of hostNetwork, it is not possible to run two pods on the same Node node (k8s-w-202) at the same time, because the pod uses the same network port 8888. The following log screenshot shows:clipboard6.png

        Since then, we can know that the use of hostNetwork has considerable limitations. First of all, Pod may be completely exploded, so if you directly use IP to deal with Pod, there will be unpredictable consequences. In addition, as the number of programs running on the host increases, the probability of port conflicts will greatly increase, so the adoption of hostNetwork must be cautious.


6 hostNetwork usage scenarios

        In general, the scenario of using hostNetwork is mostly used to operate or manage the network environment of the host machine, such as the network plug-ins that we often use, such as flannel, canal, etc. These network plug-ins can completely control the network on each node in the cluster. For example, other pods (hotNetwork: false) can be connected to the overlay network. The following figure shows the configuration of my canal network plugin pod:clipboard7.png

Guess you like

Origin blog.51cto.com/14625168/2488662