Kubernetes部署Prometheus+Grafana监控简录
部署步骤较为简单,如下:# 在k8s的master节点进行部署cd /optgit clone https://github.com/coreos/kube-prometheus.gitcd kube-prometheus/# 需要搂出来所有的镜像信息,使用阿里云镜像服务做中转加速,镜像信息简单搂取脚本如下:find . -name "*.yaml" -exec grep 'im...
·
- 部署步骤较为简单,如下:
# 在k8s的master节点进行部署
cd /opt
git clone https://github.com/coreos/kube-prometheus.git
# git clone https://github.com/imirsh/kube-prometheus.git
cd kube-prometheus/
# 需要搂出来所有的镜像信息,使用阿里云镜像服务做中转加速,镜像信息简单搂取脚本如下:
find . -name "*.yaml" -exec grep 'image: ' {} \;|awk '{print $NF}'|sort|uniq
find . -name "*.yaml" -exec grep 'quay.io' {} \;|awk '{print $NF}'|sort|uniq
# 替换镜像
find . -name "*.yaml" -exec sed -i 's|gcr.io/google_containers/metrics-server-amd64:v0.2.0|registry.cn-hangzhou.aliyuncs.com/vinc-auto/metrics-server-amd64:v0.2.0|g' {} \;
find . -name "*.yaml" -exec sed -i 's|grafana/grafana:6.6.0|registry.cn-hangzhou.aliyuncs.com/vinc-auto/grafana:6.6.0|g' {} \;
find . -name "*.yaml" -exec sed -i 's|jimmidyson/configmap-reload:v0.3.0|registry.cn-hangzhou.aliyuncs.com/vinc-auto/configmap-reload:v0.3.0|g' {} \;
find . -name "*.yaml" -exec sed -i 's|luxas/autoscale-demo:v0.1.2|registry.cn-hangzhou.aliyuncs.com/vinc-auto/autoscale-demo:v0.1.2|g' {} \;
find . -name "*.yaml" -exec sed -i 's|quay.io/coreos/k8s-prometheus-adapter-amd64:v0.5.0|registry.cn-hangzhou.aliyuncs.com/vinc-auto/k8s-prometheus-adapter-amd64:v0.5.0|g' {} \;
find . -name "*.yaml" -exec sed -i 's|quay.io/coreos/kube-rbac-proxy:v0.4.1|registry.cn-hangzhou.aliyuncs.com/vinc-auto/kube-rbac-proxy:v0.4.1|g' {} \;
find . -name "*.yaml" -exec sed -i 's|quay.io/coreos/kube-state-metrics:v1.9.5|registry.cn-hangzhou.aliyuncs.com/vinc-auto/kube-state-metrics:v1.9.5|g' {} \;
find . -name "*.yaml" -exec sed -i 's|quay.io/coreos/prometheus-config-reloader:v0.38.0|registry.cn-hangzhou.aliyuncs.com/vinc-auto/prometheus-config-reloader:v0.38.0|g' {} \;
find . -name "*.yaml" -exec sed -i 's|quay.io/coreos/prometheus-operator:v0.38.0|registry.cn-hangzhou.aliyuncs.com/vinc-auto/prometheus-operator:v0.38.0|g' {} \;
find . -name "*.yaml" -exec sed -i 's|quay.io/fabxc/prometheus_demo_service|registry.cn-hangzhou.aliyuncs.com/vinc-auto/prometheus_demo_service:latest|g' {} \;
find . -name "*.yaml" -exec sed -i 's|quay.io/prometheus/alertmanager:v0.20.0|registry.cn-hangzhou.aliyuncs.com/vinc-auto/alertmanager:v0.20.0|g' {} \;
find . -name "*.yaml" -exec sed -i 's|quay.io/prometheus/node-exporter:v0.18.1|registry.cn-hangzhou.aliyuncs.com/vinc-auto/node-exporter:v0.18.1|g' {} \;
find . -name "*.yaml" -exec sed -i 's|quay.io/prometheus/prometheus:v2.15.2|registry.cn-hangzhou.aliyuncs.com/vinc-auto/prometheus:v2.15.2|g' {} \;
# 安装 prometheus-operator
kubectl apply -f manifests/setup
# 安装 promethes metric adapter
kubectl apply -f manifests/
# 查看运行状态
kubectl get pods -n monitoring
kubectl top pods -n monitoring
# 修改 ClusterIP 为 NodePort,固定 nodePort 为 32100
# 浏览器访问测试 http://192.168.199.101:32100/graph
kubectl edit svc prometheus-k8s -n monitoring
# 修改 ClusterIP 为 NodePort,固定 nodePort 为 32200
# 浏览器访问 http://192.168.199.101:32200,用户名密码均为 admin
kubectl edit svc grafana -n monitoring
[TOC]
更多推荐
已为社区贡献9条内容
所有评论(0)