当前位置: 首页 > news >正文

K8S上使用helm部署 Prometheus + Grafana

一、使用 Helm 安装 Prometheus
1. 配置源

  地址:prometheus 27.19.0 · prometheus/prometheus-community

# 添加repo
$ helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
"prometheus-community" has been added to your repositories$ helm repo update prometheus-community
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "prometheus-community" chart repository
Update Complete. ⎈Happy Helming!⎈$ helm search repo prometheus-community
NAME                                                    CHART VERSION   APP VERSION     DESCRIPTION                                       
prometheus-community/alertmanager                       1.19.0          v0.28.1         The Alertmanager handles alerts sent by client ...
prometheus-community/alertmanager-snmp-notifier         1.0.0           v2.0.0          The SNMP Notifier handles alerts coming from Pr...
prometheus-community/jiralert                           1.7.2           v1.3.0          A Helm chart for Kubernetes to install jiralert   
prometheus-community/kube-prometheus-stack              72.7.0          v0.82.2         kube-prometheus-stack collects Kubernetes manif...
prometheus-community/kube-state-metrics                 5.33.2          2.15.0          Install kube-state-metrics to generate and expo...
prometheus-community/prom-label-proxy                   0.12.2          v0.11.0         A proxy that enforces a given label in a given ...
prometheus-community/prometheus                         27.16.0         v3.4.0          Prometheus is a monitoring system and time seri...
prometheus-community/prometheus-adapter                 4.14.1          v0.12.0         A Helm chart for k8s prometheus adapter           
prometheus-community/prometheus-blackbox-exporter       9.7.0           v0.26.0         Prometheus Blackbox Exporter                      
prometheus-community/prometheus-cloudwatch-expo...      0.27.0          0.16.0          A Helm chart for prometheus cloudwatch-exporter   
prometheus-community/prometheus-conntrack-stats...      0.5.19          v0.4.27         A Helm chart for conntrack-stats-exporter         

2. 下载 prometheus 包

# 拉包
$ helm pull prometheus-community/prometheus$ ll
total 88
drwxr-xr-x 2 root   root    4096 Jul 16 03:12 ./
drwxrwxr-x 9 ubuntu ubuntu  4096 Jul 16 03:10 ../
-rw-r--r-- 1 root   root   80137 Jul 16 03:12 prometheus-27.16.0.tgz# 解包
$ tar -zxvf prometheus-27.16.0.tgz ###修改存储,需修改2处
vim values.yaml## Prometheus server data Persistent Volume Storage Class## If defined, storageClassName: <storageClass>## If set to "-", storageClassName: "", which disables dynamic provisioning## If undefined (the default) or set to null, no storageClassName spec is##   set, choosing the default provisioner.  (gp2 on AWS, standard on##   GKE, AWS & OpenStack)##storageClass: "managed-nfs-storage"  ###修改为自己的动态存储名称## Subdirectory of Prometheus server data Persistent Volume to mount## Useful if the volume's root directory is not empty##subPath: ""vim charts/alertmanager/values.yaml persistence:enabled: true## Persistent Volume Storage Class## If defined, storageClassName: <storageClass>## If set to "-", storageClassName: "", which disables dynamic provisioning## If undefined (the default) or set to null, no storageClassName spec is## set, choosing the default provisioner.##storageClass: "managed-nfs-storage" ###修改为自己的动态存储名称accessModes:- ReadWriteOncesize: 50Mi#####部署helm install prometheus ./ -n prometheus
二、使用 Helm 安装 Grafana
1. 配置源

  地址:grafana 9.2.2 · grafana/grafana

$ helm repo add grafana https://grafana.github.io/helm-charts
"grafana" has been added to your repositories$ helm repo update grafana
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "grafana" chart repository
Update Complete. ⎈Happy Helming!⎈$ helm search repo grafana/grafana
NAME                            CHART VERSION   APP VERSION     DESCRIPTION                                       
grafana/grafana                 9.2.2           12.0.1          The leading tool for querying and visualizing t...
grafana/grafana-agent           0.42.0          v0.42.0         Grafana Agent                                     
grafana/grafana-agent-operator  0.5.1           0.44.2          A Helm chart for Grafana Agent Operator           
grafana/grafana-operator        v5.18.0         v5.18.0         Helm chart for the Grafana Operator               
grafana/grafana-sampling        1.1.5           v1.7.5          A Helm chart for a layered OTLP tail sampling a...

 2. 安装 grafana

$  helm install grafana grafana/grafana -n grafana --create-namespace
NAME: grafana
LAST DEPLOYED: Tue Jun  3 13:51:47 2025
NAMESPACE: grafana
STATUS: deployed
REVISION: 1
NOTES:
1. Get your 'admin' user password by running:kubectl get secret --namespace grafana grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo2. The Grafana server can be accessed via port 80 on the following DNS name from within your cluster:grafana.grafana.svc.cluster.localGet the Grafana URL to visit by running these commands in the same shell:export POD_NAME=$(kubectl get pods --namespace grafana -l "app.kubernetes.io/name=grafana,app.kubernetes.io/instance=grafana" -o jsonpath="{.items[0].metadata.name}")kubectl --namespace grafana port-forward $POD_NAME 30003. Login with the password from step 1 and the username: admin
#################################################################################
######   WARNING: Persistence is disabled!!! You will lose your data when   #####
######            the Grafana pod is terminated.                            #####
#################################################################################

 3. 访问

web 访问:https://yourip:port

账号:admin,密码通过下面命令获取

$ kubectl get secret --namespace grafana grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
0D0NfEWWFx9qsBiKR8PuFVxf6PPa9o8YGhZZaNXY

http://www.xdnf.cn/news/779545.html

相关文章:

  • Grafana-State timeline状态时间线
  • 乐播视频v4.0.0纯净版体验:高清流畅的视听盛宴
  • Tailwind CSS 实战:基于 Kooboo 构建 AI 对话框页面(六):图片上传功能
  • Linux(线程概念)
  • 《深入解析SPI协议及其FPGA高效实现》-- 第三篇:FPGA实现关键技术与优化
  • Docker 安装 Centos
  • Python与数据分析期末复习笔记
  • Web3如何重塑数据隐私的未来
  • LeetCode 139. 单词拆分(Word Break) - 动态规划深度解析
  • SVM详解
  • GROM快速上手
  • Java线程状态及其流转
  • 互联网大厂智能体平台体验笔记字节扣子罗盘、阿里云百炼、百度千帆 、腾讯元器、TI-ONE平台、云智能体开发平台
  • C++仿RabbitMQ实现消息队列
  • jwt token验证
  • 【Linux】线程互斥
  • Apache Druid
  • 安全-JAVA开发-第一天
  • AbMole| 3-Methyladenine (3-MA) (M2296;3-甲基腺嘌呤)
  • 仓颉项目调试配置与多文件场景下的问题解析
  • Kafka 和Redis 在系统架构中的位置
  • MySQL计算精度计算加减乘除取模方式和方法总计
  • MATLAB实战:视觉伺服控制实现方案
  • VS下C++及C#项目打包发布方法
  • 第1章_数据分析认知_知识点笔记
  • 连接关键点:使用 ES|QL 联接实现更丰富的可观测性洞察
  • qt控制台程序与qt窗口程序在读取数据库中文字段的差异!!巨坑
  • UniRig:如何在矩池云一站式解决 3D 模型绑定难题
  • 1.1Nodejs和浏览器中的二进制处理
  • 高密度电子设备的黄金搭档: 双面沉金PCB线路板