安装
1.master 节点
wget https://github.com/kubernetes/ingress-nginx/blob/nginx-0.20.0/deploy/mandatory.yaml
sed -i 's#k8s.gcr.io/defaultbackend-amd64#registry.cn-qingdao.aliyuncs.com/kubernetes_xingej/defaultbackend-amd64#g' mandatory.yaml
sed -i 's#quay.io/kubernetes-ingress-controller/nginx-ingress-controller#registry.cn-qingdao.aliyuncs.com/kubernetes_xingej/nginx-ingress-controller#g' mandatory.yaml
修改: deployment 字段 增加副本数: replicas:3 修改host 模式以及dns策略: hostNetwork: true dnsPolicy: ClusterFirst
replicas: 3replicas: 3
spec:
hostNetwork: true
dnsPolicy: ClusterFirst
spec:
hostNetwork: true
dnsPolicy: ClusterFirst
2.下载镜像 (node节点)
docker pull registry.cn-qingdao.aliyuncs.com/kubernetes_xingej/defaultbackend-amd64:1.5
docker pull registry.cn-qingdao.aliyuncs.com/kubernetes_xingej/nginx-ingress-controller:0.20.0
3.master 节点
kubectl create -f mandatory.yaml 生成ingress 与ingress nginx contorller pod
4.查看 控制器
kubectl get deployment -n ingress-nginx
5.查看pod
kubectl get pod -n ingress-nginx -o wide
6.node节点查看端口
netstat -ntpl |grep 80 #已经监听
7.master 节点增加nginx ingress 配置:
# cat nginx-ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ssxz-ingress-nginx
annotations:
kubernetes.io/ingress.class: "nginx" #定义为nginx ingress类型
ingress.kubernetes.io/ssl-redirect: "False"
spec:
rules:
- host: p2vtest.178.com #域名
http:
paths:
- path:
backend:
serviceName: ssxz-service-nginx #对应后端服务service 名称
servicePort: http
https 配置实例:
创建 secret
kubectl create secret tls tls-ssxz-secret --key 178.key --cert 178.pem
ingress nginx 配置实例:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ssxz-ingress-nginx
annotations:
kubernetes.io/ingress.class: "nginx"
ingress.kubernetes.io/ssl-redirect: "False"
spec:
tls:
- hosts:
- p2vtest.178.com
secretName: tls-ssxz-secret
rules:
- host: p2vtest.178.com
http:
paths:
- path:
backend:
serviceName: ssxz-service-nginx
servicePort: http