1.获取文件

git clone https://github.com/coreos/kube-prometheus.git
cd kube-prometheus
查看分支
git branch -a
切换分支(因为k8s 1.20,可能不支持0.8以上的)
git checkout release-0.8

2.安装operator

cd manifests
cd setup
kubectl apply -f .
until kubectl get servicemonitors —all-namespaces ; do date; sleep 1; echo “”; done

3.安装普罗米修斯

cd ..
kubectl apply -f .
查看svc
kubectl get svc -n monitoring

4.Ingress安装

首先安装helm管理工具:https://helm.sh/docs/intro/install/
华为加速地址:https://mirrors.huaweicloud.com/helm/v3.8.2/
wget https://mirrors.huaweicloud.com/helm/v3.8.2/helm-v3.8.2-linux-amd64.tar.gz
tar -zxvf helm-v3.8.2-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin/helm
验证helm是否成功
helm version 查看版本
添加仓库
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add stable https://charts.helm.sh/stable
helm repo add stable https://burdenbear.github.io/kube-charts-mirror/
helm repo add apphub https://apphub.aliyuncs.com
查看仓库 helm repo list
更新仓库
helm repo update
使用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
3. 更改对应的配置
tar xf ingress-nginx-4.0.17.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
b) hostNetwork设置为true
c) dnsPolicy设置为 ClusterFirstWithHostNet
d)
## Ref: https://kubernetes.io/docs/user-guide/node-selection/
##
nodeSelector添加ingress: “true”部署至指定节点
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=master02
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=true
kubectl label node k8s-master03 ingress-

4.卸载

cd kube-prometheus
kubectl delete —ignore-not-found=true -f manifests/ -f manifests/setup