安装ingress-nginx

yaml安装

1
2
3
4
5
6
7
# 下载
wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.46.0/deploy/static/provider/cloud/deploy.yaml \
-O ingress-nginx.yaml
# 修改配置
vi ingress-nginx.yaml
# 提交
kubectl apply -f ingress-nginx.yaml

helm安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 添加仓库
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
# 搜索版本
helm search repo ingress-nginx
# 下载指定版本
helm pull ingress-nginx/ingress-nginx --version 3.32.0
tar zxvf ingress-nginx-3.32.0.tgz
cd ingress-nginx
cp values.yaml values-override.yaml
# 修改配置
vi values-override.yaml
###
controller:
hostNetwork: true
nodeSelector:
kubernetes.io/hostname: k8s-01
###
# 安装部署
helm install --create-namespace --namespace cmp-ingress-nginx ingress-nginx -f values-override.yaml .
# 检测版本
kubectl -n cmp-ingress-nginx exec -it \
$(kubectl -n cmp-ingress-nginx get pods -l app.kubernetes.io/name=ingress-nginx -o jsonpath='{.items[0].metadata.name}') \
-- /nginx-ingress-controller --version