使用helm安装ingress:https://kubernetes.github.io/ingress-nginx/deploy/#using-helm
1. 添加ingress的helm仓库
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
查看包
helm search repo ingress-nginx
更新仓库
helm repo update
2. 下载ingress的helm包至本地
helm pull ingress-nginx/ingress-nginx
或者
wget https://github.com/kubernetes/ingress-nginx/releases/download/helm-chart-4.1.0/ingress-nginx-4.1.0.tgz
- 更改对应的配置
tar xf ingress-nginx-4.1.0.tgz
cd ingress-nginx
vim values.yaml
4. 需要修改的位置
a) Controller和admissionWebhook的镜像地址,需要将公网镜像同步至公司内网镜像仓库(和课程不一致的版本,需要自行同步gcr镜像的,可以百度查一下使用阿里云同步gcr的镜像,也可以参考这个连接https://blog.csdn.net/weixin_39961559/article/details/80739352,或者参考这个连接:https://blog.csdn.net/sinat_35543900/article/details/103290782)
下载gcr镜像
docker pull willdockerhub/ingress-nginx-controller:v1.1.2
docker pull ibmcom/defaultbackend-amd64:1.5
docker pull liangjw/kube-webhook-certgen:v1.1.1
docker pull v5cn/ingress-nginx-controller:v1.2.0
修改标签
docker tag v5cn/ingress-nginx-controller:v1.2.0 k8s.gcr.io/ingress-nginx/controller:v1.2.0
docker tag willdockerhub/ingress-nginx-controller:v1.1.2 k8s.gcr.io/ingress-nginx/controller:v1.1.2
docker tag ibmcom/defaultbackend-amd64:1.5 k8s.grc.io/defaultbackend-amd64:1.5
docker tag liangjw/kube-webhook-certgen:v1.1.1 k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.1.1
注释掉digest
b) hostNetwork设置为true
c) dnsPolicy设置为 ClusterFirstWithHostNet
d)
terminationGracePeriodSeconds: 300
# — Node labels for controller pod assignment
## Ref: https://kubernetes.io/docs/user-guide/node-selection
##
nodeSelector添加ingress: “master02”部署至指定节点
e) 类型更改为kind: DaemonSet
f)
ports: http: 80 https: 443 targetPorts: http: http https: https type: ClusterIP 修改这个
LoadBalancer在支持的云环境使用修改为ClusterIP
g)resources,安需修改
5. 部署ingress
给需要部署ingress的节点上打标签
kubectl label node k8s-master02 ingress=ingress-nginx
kubectl create ns ingress-nginx
master节点不可调度
kubectl describe nodes k8s-master02
去除,使master节点可调度
kubectl taint nodes k8s-master02 node-role.kubernetes.io/master:NoSchedule-
helm install ingress-nginx -n ingress-nginx .
6. 将ingress controller部署至Node节点(ingress controller不能部署在master节点,需要安装视频中的步骤将ingress controller部署至Node节点,生产环境最少三个ingress controller,并且最好是独立的节点)
kubectl label node k8s-node01 ingress=ingress-nginx
删除标签,ingress-nginx不符合会删除
kubectl label node k8s-node01 ingress-