1.根据kubeadm版本选择对应promethues版本并下载
https://github.com/coreos/kube-prometheus/
2.配置修改
1 # 配置修改1 2 [root@k8s-master manifests]# vim grafana-service.yaml 3 apiVersion: v1 4 kind: Service 5 metadata: 6 labels: 7 app: grafana 8 name: grafana 9 namespace: monitoring 10 spec: 11 type: NodePort # 添加内容 12 ports: 13 - name: http 14 port: 3000 15 targetPort: http 16 nodePort: 30100 # 添加内容 17 selector: 18 app: grafana 19 [root@k8s-master manifests]# 20 # 配置修改2 21 [root@k8s-master manifests]# vim prometheus-service.yaml 22 apiVersion: v1 23 kind: Service 24 metadata: 25 labels: 26 prometheus: k8s 27 name: prometheus-k8s 28 namespace: monitoring 29 spec: 30 type: NodePort # 添加内容 31 ports: 32 - name: web 33 port: 9090 34 targetPort: web 35 nodePort: 30200 # 添加内容 36 selector: 37 app: prometheus 38 prometheus: k8s 39 sessionAffinity: ClientIP 40 [root@k8s-master manifests]# 41 # 配置修改3 42 [root@k8s-master manifests]# vim alertmanager-service.yaml 43 apiVersion: v1 44 kind: Service 45 metadata: 46 labels: 47 alertmanager: main 48 name: alertmanager-main 49 namespace: monitoring 50 spec: 51 type: NodePort # 添加内容 52 ports: 53 - name: web 54 port: 9093 55 targetPort: web 56 nodePort: 30300 # 添加内容 57 selector: 58 alertmanager: main 59 app: alertmanager 60 sessionAffinity: ClientIP 61 [root@k8s-master manifests]# 62 # 配置修改4 63 [root@k8s-master manifests]# vim grafana-deployment.yaml 64 # 将apps/v1beta2 改为 apps/v1 65 apiVersion: apps/v1 66 kind: Deployment 67 metadata: 68 labels: 69 app: grafana 70 name: grafana 71 namespace: monitoring 72 spec: 73 replicas: 1 74 selector:
3.替换镜像为国内镜像
1 cd /root/k8s/kube-prometheus-release-0.11/manifests 2 1.备份 3 cp -rpv alertmanager-alertmanager.yaml alertmanager-alertmanager.yaml.bak 4 cp -rpv blackboxExporter-deployment.yaml blackboxExporter-deployment.yaml.bak 5 cp -rpv grafana-deployment.yaml grafana-deployment.yaml.bak 6 cp -rpv kubeStateMetrics-deployment.yaml kubeStateMetrics-deployment.yaml.bak 7 cp -rpv nodeExporter-daemonset.yaml nodeExporter-daemonset.yaml.bak 8 cp -rpv prometheusAdapter-deployment.yaml prometheusAdapter-deployment.yaml.bak 9 cp -rpv prometheusOperator-deployment.yaml prometheusOperator-deployment.yaml.bak 10 cp -rpv prometheus-prometheus.yaml prometheus-prometheus.yaml.bak 11 12 13 2.替换镜像源 14 sed -i -e 's/quay.io/quay.m.daocloud.io/g' -e 's/k8s.gcr.io/k8s-gcr.m.daocloud.io/g' blackboxExporter-deployment.yaml 15 sed -i -e 's/quay.io/quay.m.daocloud.io/g' -e 's/k8s.gcr.io/k8s-gcr.m.daocloud.io/g' grafana-deployment.yaml 16 sed -i -e 's/quay.io/quay.m.daocloud.io/g' -e 's/k8s.gcr.io/k8s-gcr.m.daocloud.io/g' kubeStateMetrics-deployment.yaml 17 sed -i -e 's/quay.io/quay.m.daocloud.io/g' -e 's/k8s.gcr.io/k8s-gcr.m.daocloud.io/g' nodeExporter-daemonset.yaml 18 sed -i -e 's/quay.io/quay.m.daocloud.io/g' -e 's/k8s.gcr.io/k8s-gcr.m.daocloud.io/g' prometheusAdapter-deployment.yaml 19 sed -i -e 's/quay.io/quay.m.daocloud.io/g' -e 's/k8s.gcr.io/k8s-gcr.m.daocloud.io/g' prometheusOperator-deployment.yaml 20 sed -i -e 's/quay.io/quay.m.daocloud.io/g' -e 's/k8s.gcr.io/k8s-gcr.m.daocloud.io/g' prometheus-prometheus.yaml 21 sed -i -e 's/quay.io/quay.m.daocloud.io/g' -e 's/k8s.gcr.io/k8s-gcr.m.daocloud.io/g' alertmanager-alertmanager.yaml
4.安装
1 kubectl apply --server-side -f manifests/setup 2 until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done 3 kubectl apply -f manifests/
5.promethues访问
http://172.16.1.110:30200/
6.删除
kubectl delete --ignore-not-found=true -f manifests/ -f manifests/setup
标签:kube,quay,yaml,promethues,gcr,io,deployment,k8s,安装 From: https://www.cnblogs.com/dxtx/p/18431528