1.通过helm安装
1.添加仓库
[root@master01 ~]# helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
2.更新
[root@master01 ~]# helm repo update
3.拉取ingress
[root@master01 ~]# mkdir -p ingress && cd ingress && helm fetch ingress-nginx/ingress-nginx
4.解压
[root@master01 ~]# tar -xvf ingress-nginx-3.15.2.tgz
2.更改模板
[root@master01 ingress-nginx]# pwd
/root/ingress/ingress-nginx
[root@master01 ingress-nginx]# cat values-prod.yaml
controller:
name: controller
image:
repository: cnych/ingress-nginx
tag: "v0.41.2"
digest:
dnsPolicy: ClusterFirstWithHostNet
hostNetwork: true
publishService: # hostNetwork 模式下设置为false,通过节点IP地址上报ingress status数据
enabled: false
kind: DaemonSet
nodeSelector:
kubernetes.io/os: linux
ingress: "true"
service: # HostNetwork 模式不需要创建service
enabled: false
defaultBackend:
enabled: true
name: defaultbackend
image:
repository: cnych/ingress-nginx-defaultbackend
tag: "1.5"
3.创建命名空间,安装ingress-nginx
1.创建命名空间
[root@master01 ~]# kubectl create ns ingress-nginx
2.指定节点打标签,指定调度
[root@master01 ~]# kubectl label node node01 ingress=true
3.安装ingress
[root@master01 ingress]# pwd
/root/ingress
[root@master01 ~]# helm install --namespace ingress-nginx ingress-nginx ./ingress-nginx -f ./ingress-nginx/values-prod.yaml
4.查看ingress pod是否成功
[root@master01 ingress]# kubectl get pod -n ingress-nginx -owide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
ingress-nginx-controller-nzl8h 1/1 Running 0 16m 192.168.0.121 node01 <none> <none>
ingress-nginx-defaultbackend-796bdb7766-p4qj8 1/1 Running 0 16m 10.244.2.158 node02 <none> <none>
[root@master01 ingress]# kubectl get svc -n ingress-nginx
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ingress-nginx-controller-admission ClusterIP 10.100.115.15 <none> 443/TCP 17m
ingress-nginx-defaultbackend ClusterIP 10.108.152.89 <none> 80/TCP 17m
4.简单测试下
ingress-nginx安装