Helm 安装 Kubernetes 监控套件

快速安装(无持久化)

[root@master ~]# helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
[root@master ~]# helm repo update
[root@master ~]# helm search  repo  kube-prometheus-stack 
NAME                                            CHART VERSION   APP VERSION     DESCRIPTION                                       
prometheus-community/kube-prometheus-stack      57.0.3          v0.72.0         kube-prometheus-stack collects Kubernetes manif...

[root@master ~]# helm install op prometheus-community/kube-prometheus-stack --namespace kube-monitor --create-namespace
NAME: op
LAST DEPLOYED: Wed Mar 20 16:52:30 2024
NAMESPACE: kube-monitor
STATUS: deployed
REVISION: 1
NOTES:
kube-prometheus-stack has been installed. Check its status by running:
  kubectl --namespace kube-monitor get pods -l "release=op"

Visit https://github.com/prometheus-operator/kube-prometheus for instructions on how to create & configure Alertmanager and Prometheus instances using the Operator.
  • 查看版本: helm search repo prometheus-community/kube-prometheus-stack --versions

  • 安裝指定版本: helm install my-prometheus prometheus-community/kube-prometheus-stack --version <version_number>

- 获取密码

[root@master ~]# kubectl get secret op-grafana -n kube-monitor -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
prom-operator

NodPort 方式暴露

# Gafana 暴露
[root@master ~]# kubectl edit svc op-grafana -n kube-monitor
service/op-grafana edited
[root@master ~]# kubectl get svc op-grafana -n kube-monitor -o yaml |grep -i nodeport
    nodePort: 30300     # 自定义暴露端口,默认随机
  type: NodePort        # 类型模式

# Prometheus 暴露
[root@master ~]# kubectl edit svc op-kube-prometheus-stack-prometheus -n kube-monitor
service/op-kube-prometheus-stack-prometheus edited
[root@master ~]# kubectl get svc op-kube-prometheus-stack-prometheus -n kube-monitor -o yaml |grep -i nodeport
    nodePort: 30301
    nodePort: 31177
  type: NodePort

Ingress-nginx 方式

使用local pv持久化存储数据

参考: Helm 安装prometheus-stack 使用local pv持久化存储数据-CSDN博客

多节点存储持久化

  • 去除节点亲和性即可

其他方式

  • influxdb存储prometheus数据

  • mysql存储grafana数据

Last updated