Ingress in k8s

Insert picture description here

  • Service is an abstraction of the real back-end service, a Service can represent multiple same back-end services
  • Ingress is a reverse proxy rule, used to specify which Service HTTP/S requests should be forwarded to. For example, according to different Host and url paths in the request, the request falls on a different Service.
  • Ingress Controller is a reverse proxy program, which is responsible for parsing the reverse proxy rules of Ingress. If there are changes in Ingress, all Ingress Controllers will update their corresponding forwarding rules in time. When the Ingress Controller receives the request, it will follow These rules forward the request to the corresponding Service.

Kubernetes does not have its own Ingress Controller. It is just a standard. There are many specific implementations that need to be installed separately. The commonly used ones are Nginx Ingress Controller and Traefik Ingress Controller. So Ingress is an abstraction of forwarding rules.
The implementation of Ingress Controller needs to forward the request to the corresponding Service according to these Ingress rules.

Deployment method

  • Ingress Controller is deployed in Deployment mode. Add a Service to it, the type is LoadBalancer. This will automatically generate an IP address, which can be accessed through this IP, and generally this IP is highly available (provided that the cluster supports LoadBalancer, usually cloud Only supported by service providers, self-built clusters generally do not)
  • Use one or some nodes in the cluster as edge nodes, and add labels to the nodes to identify them. Ingress Controller is deployed in DaemonSet mode, and nodeSelector is used to bind to the edge nodes to ensure that each edge node starts an Ingress Controller instance. Use hostPort directly In these edge node hosts expose ports, and then we can access the ports exposed by the Ingress Controller in the edge nodes, so that the outside can access the Ingress Controller
  • The Ingress Controller is deployed in the deployment method. Add a Service to it. The type is NodePort. After the deployment is completed, a port will be given. We can view this port through kubectl get svc. This port can be accessed by every node in the cluster. You can access the Ingress Controller by accessing this port of the cluster node. But there are so many nodes in the cluster, and the ports are not 80 and 443, which is too uncomfortable. Generally, we will build a load balancer in front, such as using Nginx, to forward the request to the port of each node in the cluster, so that we can access Nginx It is equivalent to accessing the Ingress Controller

How to install niginx-ingress:

Installation of ingress in win10 desktop version docker

surroundings
  • docker version: v20.10.2
  • kubernetes version: v1.19.3
  • Install command
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.44.0/deploy/static/provider/cloud/deploy.yaml

refers:
https://cloud.tencent.com/developer/article/1326535
https://blog.csdn.net/yao_zhuang/article/details/113461189
https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/
https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/

Guess you like

Origin blog.csdn.net/yao_zhuang/article/details/113915766