Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of load balancing Mechanism Ingress in kubernetes

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail the example analysis of the load balancing mechanism Ingress in kubernetes. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

One: preface

At the beginning of its design, Kubernetes fully considered the mechanism of service discovery and load balancing for containers, provided Service resources, and adapted to different application scenarios through kube-proxy and cloud provider. With the proliferation of kubernetes users and the continuous enrichment of user scenarios, some new load balancing mechanisms have emerged. Currently, what is the load balancing in kubernetes? The causes can be divided into the following mechanisms:

1.Service (NodePort): directly use Service to provide load balancing within cluster. This is achieved by exposing a port on each node in the cluster, and then mapping this port to a specific service. Although there are many ports for each node (the default value range is 30000-32767), they may not be used in practice due to security and ease of use (confusion due to too many services, and port conflicts).

2.Ingress Controller: Service is still used to provide load balancing within cluster, but external access is provided through custom LB.

3.Service Load Balancer: expose services by applying to the underlying cloud platform to create a load balancer. At present, the cloud platforms supported by LoadBlancer Service are relatively perfect, such as foreign GCE, DigitalOcean, domestic Aliyun, private cloud OpenStack, and so on. Because LoadBlancer Service is deeply integrated with cloud platforms, it can only be used on some cloud platforms.

4.Custom Load Balancer: custom load balancer and replace kube-proxy. It is generally used in physical deployment of Kubernetes to facilitate access to the company's existing external services.

Two: Service

Service is an abstraction of a set of Pods that provides the same functionality and provides a unified entry point for them. With the help of Service, applications can easily achieve service discovery and load balancing, and achieve zero downtime upgrade. Service selects the service backend through tags, usually with Replication Controller or Deployment to ensure the normal operation of the backend container.

There are three types of Service:

1.Cluster Ip: default type, which automatically assigns a virtual IP that can only be accessed within cluster

2.NodePort: bind a port to each machine for Service on a ClusterIp basis, so that you can access the service through: NodePort.

3.LoadBalancer: based on NodePort, create an external load balancer with cloud provider and forward the request to: NodePort

Three: Ingress Controller

Although Service solves the problems of service discovery and load balancing, when accessing externally, the NodePort type needs to build additional load balancers on the outside, and LoadBalancer requires Kubernetes to run on the supported cloud provider. Ingress is designed to address these limitations.

Ingress is a collection of rules that allow traffic outside the cluster to reach the Service within the cluster through certain rules. Request--- > ingress--- > service.

Ingress consists of three components:

1. Reverse proxy load balancer: common load balancing software, such as nginx, Haproxy, etc.

2.Ingress Controller: kubernetes API interacts with each other, perceives the changes of backend service and pod in real time. Ingress Controller generates configuration combined with Ingress below, and then updates the reverse proxy load balancer and refreshes its configuration to achieve dynamic service discovery and update.

3.Ingress: a set of rules; defines the corresponding relationship between the domain name and the service of Kubernetes; this rule will be combined with Ingress Controller, and Ingress Controller will dynamically write it to the load balancer configuration to achieve overall service discovery and load balancing.

Four: Service Load Balancer

Before the advent of Ingress, Service Load Balancer who recommended a way to address the limitations of Service. Service Load Balancer runs haproxy in the container, monitors the changes of service and endpoint, and provides layer-4 and layer-7 load balancing services through the container IP.

Five: Custom Load Balancer

Custom components, instead of kube-proxy, to do load balancing. Such as nginx plus, kube2haproxy and so on.

Six: Endpoints

There are several situations where you need to use service without selector

1. When using databases outside the kubernetes cluster.

Service from other namespace or kubernetes clusters is used in 2.service

3. Migrate between the workload of the kubernetes and the back end outside the cluster.

Seven: Traefik

Traefik is? Open source reverse proxy and load balancing? With. Is it the most? The advantage is to be able to work with Chang? The direct integration of micro-service system can be realized. Dynamic dynamic configuration. ? Before? Hold Docker,Swarm, Mesos/Marathon, Mesos, Kubernetes, Consul, Etcd, Zookeeper,BoltDB, Rest API and other back-end models.

This is the end of the article on "sample analysis of load balancing mechanism Ingress in kubernetes". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report