The ingress of Kubernetes

Source: Internet
Author: User

Www.cnblogs.com/hellojackyleon/p/8420911.html
Apiversion:extensions/v1beta1kind:deploymentmetadata:name:default-http-backend Labels:app:default-http-backend       Namespace:ingress-nginxspec:replicas:1 Template:metadata:labels:app:default-http-backend Spec: terminationgraceperiodseconds:60 containers:-Name:default-http-backend # any image is Permissab Le as long as: # 1. It serves a 404 page at/# 2.        It serves on A/healthz endpoint image:registry.cn-hangzhou.aliyuncs.com/google_containers/defaultbackend:1.4 LivenessProbe:httpGet:path:/healthz port:8080 scheme:http I Nitialdelayseconds:30 timeoutseconds:5 Ports:-containerport:8080 Resources:li mits:cpu:10m memory:20mi requests:cpu:10m memory:20mi---apivers Ion:v1kind:servicemetadata:name:default-http-backend Namespace:ingress-ngiNX Labels:app:default-http-backendspec:ports:-port:80 targetport:8080 Selector:app:default-http-back End

[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-lb Namespace:ingress-nginxspec: Replicas:1 template:metadata:labels:name:nginx-ingress-lb Annotations:prometheus.io/port      : ' 10254 ' prometheus.io/scrape: ' True ' spec:terminationgraceperiodseconds:60 hostnetwork:true Containers:-image:registry.cn-hangzhou.aliyuncs.com/google_containers/nginx-ingress-controller:0.8.3 Name: NGINX-INGRESS-LB ReadinessProbe:httpGet:path:/healthz port:10254 Sche          Me:http LivenessProbe:httpGet:path:/healthz port:10254 scheme:http         Initialdelayseconds:10 timeoutseconds:1 Ports:-containerport:80 hostport:80       -containerport:443 hostport:443 ENV:-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:8080 args:-/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:  replicas:3  selector:    matchlabels:      App:nginx  Template:    metadata:      Labels:        app:nginx    Spec:      containers:      -Name:nginx        image : nginx:1.10        Ports:        -containerport: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

My app for Cat <<eof | Kubectl Create-f-

Apiversion:extensions/v1beta1

Kind:ingress

Metadata

Name:simple

Annotations

Nginx.ingress.kubernetes.io/rewrite-target:/

Spec

Rules

-Host:test.io

-http:

Paths

-Path:/

Backend:

Servicename:veewap

serviceport:8080

Eof

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.