#!/bin/bash # 添加 Prometheus 社区 Helm 仓库 echo "添加 Prometheus Helm 仓库..." helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update # 创建命名空间 echo "创建 monitoring 命名空间..." kubectl create namespace monitoring # 安装 kube-prometheus-stack (包含 Prometheus, Grafana, Alertmanager) echo "安装 kube-prometheus-stack..." helm install kube-prometheus-stack prometheus-community/kube-prometheus-stack \ --namespace monitoring \ -f values.yaml # 等待部署完成 echo "等待 Prometheus 和 Grafana 启动..." kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=grafana -n monitoring --timeout=300s # 显示状态 echo "" echo "监控系统部署完成!" kubectl get pods -n monitoring kubectl get svc -n monitoring echo "" echo "访问信息:" echo " Grafana: http://grafana.local (需要配置 Ingress)" echo " 默认用户名: admin" echo " 默认密码: prom-operator" echo "" echo " Prometheus: http://prometheus.local (需要配置 Ingress)"