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

K8s ingress-nginx

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

Share

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

Kubernetes Ingess is composed of two parts, Ingress Controller and Ingress services. The commonly used Ingress Controller is ingress-nginx. The working principle is:

Ingress Controller will dynamically perceive the rule changes of Ingress in the cluster, then read, dynamically generate the configuration file of Nginx, and finally inject it into the pod running nginx, then automatically reload, and the configuration takes effect.

Kubernetes Ingress is used because it is a layer 7 scheduling, and the https session can be unloaded directly, and the pod at the back end of the agent can directly use the plaintext http protocol.

The type of Service NodePort is 4-tier scheduling, which can not be done. However, https is a trend now, so we still have to choose Ingress when kubernetes exposes its services.

Let's take a look at the deployment of Ingress:

Schematic diagram

1. Create a backend container and service

First of all, create a folder specifically for Igress yaml files, mkdir ingress.

Vim myapp.yaml

ApiVersion: apps/v1kind: Deploymentmetadata: name: myappspec: replicas: 3 selector: matchLabels: app: myapp template: metadata: labels: app: myappspec: containers:-name: myapp-ding image: ikubernetes/myapp:v2---apiVersion: v1kind: Servicemetadata: name: myapp # ingress depends on this to match spec: selector: app: myapp type: ClusterIP ports:-port: 80 targetPort: 802. Configure ingress configuration file apiVersion: extensions/v1beta1kind: Ingressmetadata: name: ingress-ding namespace: default annotations: kubernetes.io/ingress.class: "nginx" spec: rules:-host: www.yang.com # Virtual Machine Host Domain http: paths:-path: backend: serviceName: myapp # name servicePort of service backend proxy: 80 # backend service port

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

Servers

Wechat

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

12
Report