Get the App
SLTechnology News&Howtos  ›  Servers  › 

K8s ingress-nginx

Shulou Source: shulou.com Published: 2022-06-03 09:51:15 12月06日 Update

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

Tags: File configuration dynamic principle end agent scheduling host domain name container commonly used folder time plaintext port type rule trend or part Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft MariaDB MySQL Huawei vpn