文章目录
一、资源准备
1.拉取资源包并解压
helm pull bitnami/nginx-ingress-controller %拉取包
tar zxf nginx-ingress-controller-7.5.0.tgz %解压(需要在/helm目录下)
2.拉取相关镜像
拉取nginx-ingress-controller镜像并上传到harbor仓库:
docker load -i nginx-ingress-controller-0.44.0.tar %直接load -i 已经下载好的包
docker push reg.westos.org/bitnami/nginx-ingress-controller:0.44.0-debian-10-r28
docker push reg.westos.org/bitnami/nginx:1.19.8-debian-10-r6
拉取metallb相关镜像并上传到harbor仓库:
docker load -i metallb.tar %直接load -i 已经下载好的包
docker tag metallb/speaker:v0.9.5 reg.westos.org/metallb/speaker:v0.9.5
docker push reg.westos.org/metallb/speaker:v0.9.5
docker tag metallb/controller:v0.9.5 reg.westos.org/metallb/controller:v0.9.5
docker push reg.westos.org/metallb/controller:v0.9.5
二、nginx-ingress部署
1.编辑values.yaml文件
global: %指定全局
imageRegistry: reg.westos.org %harbor
2.每个结点上安装ipvsadm
yum install -y ipvsadm
3.master节点上更改为ipvs模式
kubectl edit configmap -n kube-system kube-proxy
strictARP: true
mode: "ipvs"
kubectl get pod -n kube-system |grep kube-proxy | awk '{system("kubectl delete pod "$1" -n kube-system")}' %重启容器使上述更改生效
三、metallb部署
1.编辑metallb.yaml创建namespace:
mkdir metallb
vim metallb.yaml:添加下述内容
kind: Namespace
metadata:
name: metallb-system
labels:
app: metallb
kubectl apply -f metallb.yaml
kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"
2.编辑config.yaml并应用
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools: %地址池
- name: default
protocol: layer2 %二层协议
addresses:
- 172.25.1.100-172.25.1.200
kubectl apply -f config.yaml
四、安装
cd nginx-ingress-controller/
kubectl create namespace nginx-ingress-controller
helm install nginx-ingress-controller . -n nginx-ingress-controller
kubectl -n nginx-ingress-controller get pod
kubectl -n nginx-ingress-controller get all