The ingress of Kubernetes

Source: Internet
Author: User





1, Ingress Components Introduction

Nginx ingress controller

Ingress solves the problem of the domain name and service after the new service is added, basically a Ingress object, which is loaded by creating and updating with Yaml.
Ingress Controller is to ingress this change to generate a nginx configuration, and then this configuration through the Kubernetes API written to the Nginx pod, and then reload.

Ingress nginx kubernetes
2. generate a default backend and forward to the default backend page if you encounter a URL that cannot be resolved

Kubernetes ingress nginx master
Nginx ingress controller kubernetes
apiversion:extensions/V1beta1kind:Deploymentmetadata:name:default-http-Backend Labels:app:default-http-Backendnamespace: ingress-Nginxspec:replicas:1Template:metadata:labels:app:default-http-Backend Spec:terminationgraceperiodseconds: -Containers:-Name:default-http-Backend # any image isPermissable as Long  as:        # 1. It serves a404Page at/ # 2. It serves $On A/Healthz Endpoint image:registry.cn-hangzhou.aliyuncs.com/google_containers/defaultbackend:1.4LivenessProbe:httpGet:path:/Healthz Port:8080scheme:http initialdelayseconds: -timeoutseconds:5Ports:-Containerport:8080resources:limits:cpu:10m memory:20mi requests:cpu:10m Memory:20mi---ApiVersion:v1kind:Servicemetadata:name:default-http-Backendnamespace: ingress-nginx Labels:app:default-http-Backendspec:ports:-Port: theTargetport:8080Selector:app:default-http-backend

Nginx ingress controller setup

[Email protected] ingress]# Kubectl create-f Default-backend.yaml
Deployment "Default-http-backend" created
Service "Default-http-backend" created
[Email protected] ingress]#











[[email protected] ingress]# Kubectl get pods-n ingress-nginx-o wide
NAME ready STATUS Restarts IP NODE
Default-http-backend-5d8887b7f-l8r29 1/1 Running 0 28s 10.0.91.6 192.168.10.221

















3. Deploy ingress Controller



[email protected] ingress]# cat nginx-ingress-Controller.yaml ApiVersion:v1kind:ReplicationControllermetadata:name:nginx-ingress-lb Labels:name:nginx-ingress-lbnamespace: ingress-Nginxspec:replicas:1Template:metadata:labels:name:nginx-ingress-lb Annotations:prometheus.io/port:'10254'Prometheus.io/scrape:'true'Spec:terminationgraceperiodseconds: -hostnetwork:trueContainers:-Image:registry.cn-hangzhou.aliyuncs.com/google_containers/nginx-ingress-controller:0.8.3Name:nginx-ingress-lb ReadinessProbe:httpGet:path:/Healthz Port:10254scheme:http LivenessProbe:httpGet:path:/Healthz Port:10254scheme:http initialdelayseconds:Tentimeoutseconds:1Ports:-Containerport: theHostport: the-Containerport:443Hostport:443env:-name:pod_name ValueFrom:fieldRef:fieldPath:metadata.name-name:pod_namespace valueFrom:fieldRef:fieldPath:metadata.namespace-name:kubernetes_master value:http://192.168.10.220:8080args:-/nginx-ingress-Controller- --default-backend-service=$ (Pod_namespace)/default-http-backend#---apiserver-host=http://192.168.10.220:8080 


[[email protected] ingress]# Kubectl get pod-n ingress-nginx-o wide
NAME ready STATUS Restarts IP NODE
Default-http-backend-5d8887b7f-l8r29 1/1 Running 0 21m 10.0.91.6 192.168.10.221
NGINX-INGRESS-LB-GJ4SG 1/1 Running 0 1m 192.168.10.221 192.168.10.221


















4, this experiment through the Nginx container, here through the Ingress do entrance Access Svc



[email protected] ~]# cat nginx-deployment.yaml apiversion:apps/v1beta2kind:deploymentmetadata:  Name:nginx-deployment namespace: ingress-nginxspec: 3  selector:    matchlabels:      app:nginx  Template:    metadata:      Labels:        app:nginx    Spec:      containers: - name:nginx        image:nginx:1.10  Ports: 80 



[Email protected] ~]# Kubectl create-f Nginx-deployment.yaml











[email protected] ~]# cat Nginx-service.yaml
Apiversion:v1
Kind:service
Metadata
Name:nginx-service
Namespace:ingress-nginx
Labels
App:nginx
Spec
Ports
-port:88
Targetport:80
Selector
App:nginx
























[Email protected] ~]# Kubectl create-f Nginx-service.yaml











[email protected] ~]# cat Ingress-nginx.yaml
Apiversion:extensions/v1beta1
Kind:ingress
Metadata
Name:nginxservice
Namespace:ingress-nginx
Spec
Rules
-Host:test.io
http
Paths
-Path:/
Backend:
Servicename:nginx-service
Serviceport:80
-Path:/
# backend:
# Servicename:kubernetes-dashboard
# serviceport:80
[Email protected] ~]# Kubectl create-f Ingress-nginx.yaml





























Native write host file to access, external write host file, point to node IP can

















The ingress of Kubernetes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.