Kubernetes学习(七)

hubanbei00的家园 2020-02-18

 Ingress

一、资料信息

Ingress-Nginx github 地址:https://github.com/kubernetes/ingress-nginx

Ingress-Nginx 官方网站:https://kubernetes.github.io/ingress-nginx/

进入官方下载

wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml

Kubernetes学习(七)

 Kubernetes学习(七)

二、部署 Ingress-Nginx

https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.28.0/deploy/static/provider/baremetal/service-nodeport.yamlhttps://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml

kubectl apply -f mandatory.yaml

kubectl apply -f service-nodeport.yaml

Ingress HTTP 代理访问

deployment、Service、Ingress Yaml 文件

apiVersion: extensions/v1beta1

kind: Deployment

metadata:

name: nginx-dm

spec:

  replicas: 2

template:

 metadata:

labels:

 name: nginx

 spec:

 containers:

 - name: nginx

 image: wangyanglinux/myapp:v1

 imagePullPolicy: IfNotPresent

 ports:

 - containerPort: 80

apiVersion: v1

kind: Service

metadata:

 name: nginx-svc

spec:

 ports:

 - port: 80

 targetPort: 80

 protocol: TCP

 selector:

 name: nginx

apiVersion: extensions/v1beta1

kind: Ingress

metadata:

   name: nginx-test

spec:

 rules:

- host: www1.atguigu.com

 http:

paths:

 - path: /

backend:

 serviceName: nginx-svc

 servicePort: 80

过程如下

1.执行
mandatory.yaml
2.执行
service-nodeport.yaml
3.执行deployment
deployment.yaml
4.执行ingress
ingress.http.yaml

master机器解析IP后可以通过 curl 访问但是本机解析后通过浏览器访问大部分都是失败的,原因未知

相关推荐