在k8s中部署Prometheus--更新中
啊
·
下载kubernetes中的Prometheus文件相关源码
https://github.com/kubernetes/kubernetes.git
cp -rf kubernetes/cluster/addons/prometheus/ /root/
cd prometheus/
(1)先部署promethethus配置文件
kubectl create -f prometheus-rbac.yaml
kubectl create -f prometheus-rules.yaml
kubectl create -f prometheus-configmap.yaml
kubectl get storageclass # 确定有配置storageclass
vi prometheus-statefulset.yaml
kubectl create -f prometheus-statefulset.yaml
kubectl create -f prometheus-service.yaml
(需添加的内容:配置动态存储方式)
此处使用pvc动态存储方式,修改 prometheus-statefulset.yaml为
storageClassName: managed-nfs-storage
kubectl get svc -n kube-system
wget https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz
tar zxf node_exporter-0.17.0.linux-amd64.tar.gz
mv node_exporter-0.17.0.linux-amd64 /usr/local/node_exporter
cat <<EOF >/usr/lib/systemd/system/node_exporter.service
[Unit]
Description=https://prometheus.io
[Service]
Restart=on-failure
ExecStart=/usr/local/node_exporter/node_exporter --collector.systemd --collector.systemd.unit-whitelist=(docker|kubelet|kube-proxy|flanneld).service
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable node_exporter
systemctl restart node_exporter
kubectl exec -it prometheus-0 sh -c prometheus-server -n kube-system
# 进入promethues的pod中
/prometheus $ more /etc/config/prometheus.yml
kubectl create -f kube-state-metrics-rbac.yaml
kubectl create -f kube-state-metrics-deployment.yaml
kubectl create -f kube-state-metrics-service.yaml
kubectl get pods -n kube-system
kubectl create -f alertmanager-configmap.yaml
kubectl create -f alertmanager-pvc.yaml
kubectl create -f alertmanager-deployment.yaml
kubectl create -f alertmanager-service.yaml
grafana展示
kubectl create -f grafana.yaml
更多推荐
已为社区贡献8条内容
所有评论(0)