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

K8S 上部署 Prometheus + Grafana

文章目录

      • 一、使用 Helm 安装 Prometheus
        • 1. 配置源
        • 2. 下载 prometheus 包
        • 3. 安装 prometheus
        • 4. 卸载
      • 二、使用 Helm 安装 Grafana
        • 1. 配置源
        • 2. 安装 grafana
        • 3. 访问
        • 4. 卸载

一、使用 Helm 安装 Prometheus

1. 配置源

  地址:https://artifacthub.io/packages/helm/prometheus-community/prometheus

# 添加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/prometheus
NAME                                              	CHART VERSION	APP VERSION	DESCRIPTION                                       
prometheus-community/prometheus                   	25.24.0      	v2.53.1    	Prometheus is a monitoring system and time seri...
prometheus-community/prometheus-adapter           	4.10.0       	v0.11.2    	A Helm chart for k8s prometheus adapter           
prometheus-community/prometheus-blackbox-exporter 	8.17.0       	v0.25.0    	Prometheus Blackbox Exporter                      
prometheus-community/prometheus-cloudwatch-expo...	0.25.3       	0.15.5     	A Helm chart for prometheus cloudwatch-exporter   
prometheus-community/prometheus-conntrack-stats...	0.5.10       	v0.4.18    	A Helm chart for conntrack-stats-exporter         
prometheus-community/prometheus-consul-exporter   	1.0.0        	0.4.0      	A Helm chart for the Prometheus Consul Exporter   
prometheus-community/prometheus-couchdb-exporter  	1.0.0        	1.0        	A Helm chart to export the metrics from couchdb...
prometheus-community/prometheus-druid-exporter    	1.1.0        	v0.11.0    	Druid exporter to monitor druid metrics with Pr...
prometheus-community/prometheus-elasticsearch-e...	6.0.0        	v1.7.0     	Elasticsearch stats exporter for Prometheus       
prometheus-community/prometheus-fastly-exporter   	0.4.0        	v8.1.0     	A Helm chart for the Prometheus Fastly Exporter   
prometheus-community/prometheus-ipmi-exporter     	0.4.0        	v1.8.0     	This is an IPMI exporter for Prometheus.          
prometheus-community/prometheus-json-exporter     	0.13.0       	v0.6.0     	Install prometheus-json-exporter                  
prometheus-community/prometheus-kafka-exporter    	2.10.0       	v1.7.0     	A Helm chart to export the metrics from Kafka i...
prometheus-community/prometheus-memcached-exporter	0.3.3        	v0.14.4    	Prometheus exporter for Memcached metrics         
prometheus-community/prometheus-modbus-exporter   	0.1.2        	0.4.1      	A Helm chart for prometheus-modbus-exporter       
prometheus-community/prometheus-mongodb-exporter  	3.5.0        	0.40.0     	A Prometheus exporter for MongoDB metrics         
prometheus-community/prometheus-mysql-exporter    	2.5.3        	v0.15.1    	A Helm chart for prometheus mysql exporter with...
prometheus-community/prometheus-nats-exporter     	2.17.0       	0.15.0     	A Helm chart for prometheus-nats-exporter         
prometheus-community/prometheus-nginx-exporter    	0.2.1        	0.11.0     	A Helm chart for the Prometheus NGINX Exporter    
prometheus-community/prometheus-node-exporter     	4.37.0       	1.8.1      	A Helm chart for prometheus node-exporter         
prometheus-community/prometheus-opencost-exporter 	0.1.1        	1.108.0    	Prometheus OpenCost Exporter                      
prometheus-community/prometheus-operator          	9.3.2        	0.38.1     	DEPRECATED - This chart will be renamed. See ht...
prometheus-community/prometheus-operator-admiss...	0.14.0       	0.75.1     	Prometheus Operator Admission Webhook             
prometheus-community/prometheus-operator-crds     	13.0.1       	v0.75.0    	A Helm chart that collects custom resource defi...
prometheus-community/prometheus-pgbouncer-exporter	0.3.0        	v0.8.0     	A Helm chart for prometheus pgbouncer-exporter    
prometheus-community/prometheus-pingdom-exporter  	2.5.0        	20190610-1 	A Helm chart for Prometheus Pingdom Exporter      
prometheus-community/prometheus-pingmesh-exporter 	0.4.0        	v1.2.1     	Prometheus Pingmesh Exporter                      
prometheus-community/prometheus-postgres-exporter 	6.0.1        	v0.15.0    	A Helm chart for prometheus postgres-exporter     
prometheus-community/prometheus-pushgateway       	2.14.0       	v1.9.0     	A Helm chart for prometheus pushgateway           
prometheus-community/prometheus-rabbitmq-exporter 	1.12.0       	v0.29.0    	Rabbitmq metrics exporter for prometheus          
prometheus-community/prometheus-redis-exporter    	6.3.0        	v1.61.0    	Prometheus exporter for Redis metrics             
prometheus-community/prometheus-smartctl-exporter 	0.10.0       	v0.12.0    	A Helm chart for Kubernetes                       
prometheus-community/prometheus-snmp-exporter     	5.5.0        	v0.26.0    	Prometheus SNMP Exporter                          
prometheus-community/prometheus-sql-exporter      	0.1.0        	v0.5.4     	Prometheus SQL Exporter                           
prometheus-community/prometheus-stackdriver-exp...	4.5.1        	v0.15.1    	Stackdriver exporter for Prometheus               
prometheus-community/prometheus-statsd-exporter   	0.13.1       	v0.26.1    	A Helm chart for prometheus stats-exporter        
prometheus-community/prometheus-systemd-exporter  	0.3.0        	0.6.0      	A Helm chart for prometheus systemd-exporter      
prometheus-community/prometheus-to-sd             	0.4.2        	0.5.2      	Scrape metrics stored in prometheus format and ...
prometheus-community/prometheus-windows-exporter  	0.3.1        	0.25.1     	A Helm chart for prometheus windows-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-25.24.0.tgz# 解包
$ tar -zxvf prometheus-25.24.0.tgz 
prometheus/Chart.yaml
prometheus/Chart.lock
prometheus/values.yaml
prometheus/values.schema.json
prometheus/templates/NOTES.txt
prometheus/templates/_helpers.tpl
prometheus/templates/clusterrole.yaml
prometheus/templates/clusterrolebinding.yaml
prometheus/templates/cm.yaml
prometheus/templates/deploy.yaml
prometheus/templates/extra-manifests.yaml
prometheus/templates/headless-svc.yaml
prometheus/templates/ingress.yaml
prometheus/templates/network-policy.yaml
prometheus/templates/pdb.yaml
prometheus/templates/psp.yaml
prometheus/templates/pvc.yaml
prometheus/templates/rolebinding.yaml
prometheus/templates/service.yaml
prometheus/templates/serviceaccount.yaml
prometheus/templates/sts.yaml
prometheus/templates/vpa.yaml
prometheus/.helmignore
prometheus/README.md
prometheus/ci/01-automount-sa-token-values.yaml
prometheus/ci/02-config-reloader-deployment-values.yaml
prometheus/ci/03-config-reloader-sts-values.yaml
prometheus/ci/04-extra-manifest-values.yaml
prometheus/ci/05-server-deployment-values.yaml
prometheus/ci/06-server-sts-values.yaml
prometheus/ci/07-meta-labels-values.yaml
prometheus/ci/08-sts-pvc-retention-policy-values.yaml
prometheus/ci/09-standalone-deployment-values.yaml
prometheus/ci/10-namespaced-sd-values.yaml
prometheus/ci/11-default-values.yaml
prometheus/charts/alertmanager/Chart.yaml
prometheus/charts/alertmanager/values.yaml
prometheus/charts/alertmanager/values.schema.json
prometheus/charts/alertmanager/templates/NOTES.txt
prometheus/charts/alertmanager/templates/_helpers.tpl
prometheus/charts/alertmanager/templates/configmap.yaml
prometheus/charts/alertmanager/templates/ingress.yaml
prometheus/charts/alertmanager/templates/ingressperreplica.yaml
prometheus/charts/alertmanager/templates/pdb.yaml
prometheus/charts/alertmanager/templates/serviceaccount.yaml
prometheus/charts/alertmanager/templates/serviceperreplica.yaml
prometheus/charts/alertmanager/templates/services.yaml
prometheus/charts/alertmanager/templates/statefulset.yaml
prometheus/charts/alertmanager/templates/tests/test-connection.yaml
prometheus/charts/alertmanager/.helmignore
prometheus/charts/alertmanager/README.md
prometheus/charts/alertmanager/ci/config-reload-values.yaml
prometheus/charts/kube-state-metrics/Chart.yaml
prometheus/charts/kube-state-metrics/values.yaml
prometheus/charts/kube-state-metrics/templates/NOTES.txt
prometheus/charts/kube-state-metrics/templates/_helpers.tpl
prometheus/charts/kube-state-metrics/templates/ciliumnetworkpolicy.yaml
prometheus/charts/kube-state-metrics/templates/clusterrolebinding.yaml
prometheus/charts/kube-state-metrics/templates/crs-configmap.yaml
prometheus/charts/kube-state-metrics/templates/deployment.yaml
prometheus/charts/kube-state-metrics/templates/extra-manifests.yaml
prometheus/charts/kube-state-metrics/templates/kubeconfig-secret.yaml
prometheus/charts/kube-state-metrics/templates/networkpolicy.yaml
prometheus/charts/kube-state-metrics/templates/pdb.yaml
prometheus/charts/kube-state-metrics/templates/podsecuritypolicy.yaml
prometheus/charts/kube-state-metrics/templates/psp-clusterrole.yaml
prometheus/charts/kube-state-metrics/templates/psp-clusterrolebinding.yaml
prometheus/charts/kube-state-metrics/templates/rbac-configmap.yaml
prometheus/charts/kube-state-metrics/templates/role.yaml
prometheus/charts/kube-state-metrics/templates/rolebinding.yaml
prometheus/charts/kube-state-metrics/templates/service.yaml
prometheus/charts/kube-state-metrics/templates/serviceaccount.yaml
prometheus/charts/kube-state-metrics/templates/servicemonitor.yaml
prometheus/charts/kube-state-metrics/templates/stsdiscovery-role.yaml
prometheus/charts/kube-state-metrics/templates/stsdiscovery-rolebinding.yaml
prometheus/charts/kube-state-metrics/templates/verticalpodautoscaler.yaml
prometheus/charts/kube-state-metrics/.helmignore
prometheus/charts/kube-state-metrics/README.md
prometheus/charts/prometheus-node-exporter/Chart.yaml
prometheus/charts/prometheus-node-exporter/values.yaml
prometheus/charts/prometheus-node-exporter/templates/NOTES.txt
prometheus/charts/prometheus-node-exporter/templates/_helpers.tpl
prometheus/charts/prometheus-node-exporter/templates/clusterrole.yaml
prometheus/charts/prometheus-node-exporter/templates/clusterrolebinding.yaml
prometheus/charts/prometheus-node-exporter/templates/daemonset.yaml
prometheus/charts/prometheus-node-exporter/templates/endpoints.yaml
prometheus/charts/prometheus-node-exporter/templates/extra-manifests.yaml
prometheus/charts/prometheus-node-exporter/templates/networkpolicy.yaml
prometheus/charts/prometheus-node-exporter/templates/podmonitor.yaml
prometheus/charts/prometheus-node-exporter/templates/psp-clusterrole.yaml
prometheus/charts/prometheus-node-exporter/templates/psp-clusterrolebinding.yaml
prometheus/charts/prometheus-node-exporter/templates/psp.yaml
prometheus/charts/prometheus-node-exporter/templates/rbac-configmap.yaml
prometheus/charts/prometheus-node-exporter/templates/service.yaml
prometheus/charts/prometheus-node-exporter/templates/serviceaccount.yaml
prometheus/charts/prometheus-node-exporter/templates/servicemonitor.yaml
prometheus/charts/prometheus-node-exporter/templates/verticalpodautoscaler.yaml
prometheus/charts/prometheus-node-exporter/.helmignore
prometheus/charts/prometheus-node-exporter/README.md
prometheus/charts/prometheus-node-exporter/ci/port-values.yaml
prometheus/charts/prometheus-pushgateway/Chart.yaml
prometheus/charts/prometheus-pushgateway/values.yaml
prometheus/charts/prometheus-pushgateway/templates/NOTES.txt
prometheus/charts/prometheus-pushgateway/templates/_helpers.tpl
prometheus/charts/prometheus-pushgateway/templates/deployment.yaml
prometheus/charts/prometheus-pushgateway/templates/extra-manifests.yaml
prometheus/charts/prometheus-pushgateway/templates/ingress.yaml
prometheus/charts/prometheus-pushgateway/templates/networkpolicy.yaml
prometheus/charts/prometheus-pushgateway/templates/pdb.yaml
prometheus/charts/prometheus-pushgateway/templates/pushgateway-pvc.yaml
prometheus/charts/prometheus-pushgateway/templates/secret.yaml
prometheus/charts/prometheus-pushgateway/templates/service.yaml
prometheus/charts/prometheus-pushgateway/templates/serviceaccount.yaml
prometheus/charts/prometheus-pushgateway/templates/servicemonitor.yaml
prometheus/charts/prometheus-pushgateway/templates/statefulset.yaml
prometheus/charts/prometheus-pushgateway/.helmignore
prometheus/charts/prometheus-pushgateway/README.md
3. 安装 prometheus
$ helm install prometheus ./ \-n prometheus \--create-namespace \--set server.ingress.enabled=true \--set server.ingress.hosts='{prometheus.k8s.local}' \--set server.ingress.paths='{/}' \--set server.ingress.pathType=Prefix \--set alertmanager.ingress.enabled=true \--set alertmanager.ingress.hosts='{alertmanager.k8s.local}' \--set alertmanager.ingress.paths='{/}' \--set alertmanager.ingress.pathType=Prefix \--set grafana.ingress.enabled=true \--set grafana.ingress.hosts='{grafana.k8s.local}' \--set grafana.ingress.paths='{/}' \--set grafana.ingress.pathType=Prefix
Error: INSTALLATION FAILED: values don't meet the specifications of the schema(s) in the following chart(s):
alertmanager:
- ingress.hosts.0: Invalid type. Expected: object, given: string# 原因:上面的参数有问题
$ helm install prometheus ./ \-n prometheus \--create-namespace
NAME: prometheus
LAST DEPLOYED: Tue Jul 16 03:55:13 2024
NAMESPACE: prometheus
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
The Prometheus server can be accessed via port 80 on the following DNS name from within your cluster:
prometheus-server.prometheus.svc.cluster.localGet the Prometheus server URL by running these commands in the same shell:export POD_NAME=$(kubectl get pods --namespace prometheus -l "app.kubernetes.io/name=prometheus,app.kubernetes.io/instance=prometheus" -o jsonpath="{.items[0].metadata.name}")kubectl --namespace prometheus port-forward $POD_NAME 9090The Prometheus alertmanager can be accessed via port 9093 on the following DNS name from within your cluster:
prometheus-alertmanager.prometheus.svc.cluster.localGet the Alertmanager URL by running these commands in the same shell:export POD_NAME=$(kubectl get pods --namespace prometheus -l "app.kubernetes.io/name=alertmanager,app.kubernetes.io/instance=prometheus" -o jsonpath="{.items[0].metadata.name}")kubectl --namespace prometheus port-forward $POD_NAME 9093
#################################################################################
######   WARNING: Pod Security Policy has been disabled by default since    #####
######            it deprecated after k8s 1.25+. use                        #####
######            (index .Values "prometheus-node-exporter" "rbac"          #####
###### .          "pspEnabled") with (index .Values                         #####
######            "prometheus-node-exporter" "rbac" "pspAnnotations")       #####
######            in case you still need it.                                #####
#################################################################################The Prometheus PushGateway can be accessed via port 9091 on the following DNS name from within your cluster:
prometheus-prometheus-pushgateway.prometheus.svc.cluster.localGet the PushGateway URL by running these commands in the same shell:export POD_NAME=$(kubectl get pods --namespace prometheus -l "app=prometheus-pushgateway,component=pushgateway" -o jsonpath="{.items[0].metadata.name}")kubectl --namespace prometheus port-forward $POD_NAME 9091For more information on running Prometheus, visit:
https://prometheus.io/$ kubectl get pods,svc,ingress -n prometheus
NAME                                                    READY   STATUS    RESTARTS   AGE
pod/prometheus-alertmanager-0                           0/1     Pending   0          90s
pod/prometheus-kube-state-metrics-649c959fbc-rjq5v      1/1     Running   0          90s
pod/prometheus-prometheus-node-exporter-7jdb2           1/1     Running   0          90s
pod/prometheus-prometheus-node-exporter-p6lm4           1/1     Running   0          90s
pod/prometheus-prometheus-node-exporter-t4hcn           1/1     Running   0          90s
pod/prometheus-prometheus-pushgateway-879d6dd6c-wh7x5   1/1     Running   0          90s
pod/prometheus-server-75d49659f-krzp9                   0/2     Pending   0          90sNAME                                          TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
service/prometheus-alertmanager               ClusterIP   10.68.34.56     <none>        9093/TCP   90s
service/prometheus-alertmanager-headless      ClusterIP   None            <none>        9093/TCP   90s
service/prometheus-kube-state-metrics         ClusterIP   10.68.156.120   <none>        8080/TCP   90s
service/prometheus-prometheus-node-exporter   ClusterIP   10.68.161.251   <none>        9100/TCP   90s
service/prometheus-prometheus-pushgateway     ClusterIP   10.68.229.83    <none>        9091/TCP   90s
service/prometheus-server                     ClusterIP   10.68.120.158   <none>        80/TCP     90s$ kubectl get pvc -n prometheus
NAME                                STATUS    VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
prometheus-server                   Pending                                                     8m57s
storage-prometheus-alertmanager-0   Pending                                                     8m57s# 有些服务一直处在 Pending,原因是存储卷的问题,改为 nfs 就好使
$ helm install prometheus prometheus-community/prometheus -n prometheus --create-namespace --set server.persistentVolume.storageClass=nfs --set alertmanager.persistence.storageClass=nfs$ kubectl get pods,svc,ingress -n prometheus
NAME                                                    READY   STATUS    RESTARTS   AGE
pod/prometheus-alertmanager-0                           1/1     Running   0          55s
pod/prometheus-kube-state-metrics-649c959fbc-zf9zw      1/1     Running   0          55s
pod/prometheus-prometheus-node-exporter-9mz4q           1/1     Running   0          55s
pod/prometheus-prometheus-node-exporter-cpz26           1/1     Running   0          55s
pod/prometheus-prometheus-node-exporter-h2w68           1/1     Running   0          55s
pod/prometheus-prometheus-pushgateway-879d6dd6c-qqr4z   1/1     Running   0          55s
pod/prometheus-server-75d49659f-s624q                   2/2     Running   0          55sNAME                                          TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
service/prometheus-alertmanager               ClusterIP   10.68.150.157   <none>        9093/TCP   55s
service/prometheus-alertmanager-headless      ClusterIP   None            <none>        9093/TCP   55s
service/prometheus-kube-state-metrics         ClusterIP   10.68.130.219   <none>        8080/TCP   55s
service/prometheus-prometheus-node-exporter   ClusterIP   10.68.199.239   <none>        9100/TCP   55s
service/prometheus-prometheus-pushgateway     ClusterIP   10.68.171.40    <none>        9091/TCP   55s
service/prometheus-server                     ClusterIP   10.68.196.144   <none>        80/TCP     55s
$ kubectl get pvc -n prometheus
NAME                                STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
prometheus-server                   Bound    pvc-570e1a01-aecc-4d03-82fd-ed195a1266df   8Gi        RWO            nfs            58s
storage-prometheus-alertmanager-0   Bound    pvc-8c19e194-ff8c-4cc7-8bea-142b1adce5ac   2Gi        RWO            nfs            58s

  最终自定义的参数执行:

$ helm install prometheus prometheus-community/prometheus -n prometheus --create-namespace --set server.persistentVolume.storageClass=nfs --set alertmanager.persistence.storageClass=nfs --set server.service.type=NodePort --set alertmanager.service.type=NodePort --set server.service.nodePort=31203 --set alertmanager.service.nodePort=31757root@k8s-master01:/home/ubuntu# kubectl get svc -n prometheus
NAME                                  TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
prometheus-alertmanager               NodePort    10.68.18.91     <none>        9093:31757/TCP   21s
prometheus-alertmanager-headless      ClusterIP   None            <none>        9093/TCP         21s
prometheus-kube-state-metrics         ClusterIP   10.68.181.212   <none>        8080/TCP         21s
prometheus-prometheus-node-exporter   ClusterIP   10.68.215.203   <none>        9100/TCP         21s
prometheus-prometheus-pushgateway     ClusterIP   10.68.69.2      <none>        9091/TCP         21s
prometheus-server                     NodePort    10.68.254.104   <none>        80:31203/TCP     21s
4. 卸载
$ helm uninstall prometheus -n prometheus
release "prometheus" uninstalledkubectl delete pod -n prometheus `kubectl get pod -n prometheus |awk 'NR>1{print $1}'` --force
kubectl patch ns prometheus -p '{"metadata":{"finalizers":null}}'$ kubectl delete ns prometheus --force
Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
namespace "prometheus" force deleted

二、使用 Helm 安装 Grafana

1. 配置源

  地址:https://artifacthub.io/packages/helm/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               	8.3.4        	11.1.0     	The leading tool for querying and visualizing t...
grafana/grafana-agent         	0.41.0       	v0.41.1    	Grafana Agent                                     
grafana/grafana-agent-operator	0.4.0        	0.41.1     	A Helm chart for Grafana Agent Operator           
grafana/grafana-sampling      	0.1.1        	v0.40.2    	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 Jul 16 06:01:14 2024
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.                            #####
#################################################################################$ kubectl get all -o wide -n grafana
NAME                           READY   STATUS    RESTARTS   AGE     IP              NODE        NOMINATED NODE   READINESS GATES
pod/grafana-5b6798c77d-jlkvt   1/1     Running   0          2m37s   172.20.58.239   worker-02   <none>           <none>NAME              TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE     SELECTOR
service/grafana   ClusterIP   10.68.48.202   <none>        80/TCP    2m37s   app.kubernetes.io/instance=grafana,app.kubernetes.io/name=grafanaNAME                      READY   UP-TO-DATE   AVAILABLE   AGE     CONTAINERS   IMAGES                             SELECTOR
deployment.apps/grafana   1/1     1            1           2m37s   grafana      docker.io/grafana/grafana:11.1.0   app.kubernetes.io/instance=grafana,app.kubernetes.io/name=grafanaNAME                                 DESIRED   CURRENT   READY   AGE     CONTAINERS   IMAGES                             SELECTOR
replicaset.apps/grafana-5b6798c77d   1         1         1       2m37s   grafana      docker.io/grafana/grafana:11.1.0   app.kubernetes.io/instance=grafana,app.kubernetes.io/name=grafana,pod-template-hash=5b6798c77d

  最终自定义的参数执行:

$ helm install grafana grafana/grafana -n grafana --create-namespace --set service.type=NodePort --set service.nodePort=31830$ kubectl get svc -n grafana
NAME      TYPE       CLUSTER-IP    EXTERNAL-IP   PORT(S)        AGE
grafana   NodePort   10.68.140.2   <none>        80:31830/TCP   40s
3. 访问

  web 访问:https://yourIp:31830

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

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

在这里插入图片描述
在这里插入图片描述

4. 卸载
$ helm uninstall grafana -n grafana
release "grafana" uninstalledkubectl delete pod -n grafana `kubectl get pod -n grafana|awk 'NR>1{print $1}'` --force
kubectl patch ns grafana -p '{"metadata":{"finalizers":null}}'
kubectl delete ns grafana --force

参考:【云原生】Prometheus+Grafana on K8s 环境部署

相关文章:

K8S 上部署 Prometheus + Grafana

文章目录 一、使用 Helm 安装 Prometheus1. 配置源2. 下载 prometheus 包3. 安装 prometheus4. 卸载 二、使用 Helm 安装 Grafana1. 配置源2. 安装 grafana3. 访问4. 卸载 一、使用 Helm 安装 Prometheus 1. 配置源 地址&#xff1a;https://artifacthub.io/packages/helm/pro…...

雷军的逆天改命与顺势而为

雷军年度演讲前&#xff0c;朋友李翔提了一个问题&#xff1a;雷军造车是属于顺势而为还是逆势而为&#xff1f;评论互动区有一个总结&#xff0c;很有意思&#xff0c;叫“顺势逆袭”。 大致意思是产业趋势下小米从手机到IOT再切入汽车&#xff0c;是战略的必然&#xff0c;不…...

Leetcode 11. 盛最多水的容器

Leetcode 11. 盛最多水的容器 Leetcode 11. 盛最多水的容器 一、题目描述二、我的想法 一、题目描述 给定一个长度为 n 的整数数组 height 。有 n 条垂线&#xff0c;第 i 条线的两个端点是 (i, 0) 和 (i, height[i]) 。 找出其中的两条线&#xff0c;使得它们与 x 轴共同构成…...

Java笔试分享

1、设计模式&#xff08;写>3种常用的设计模式&#xff09; 设计模式是在软件工程中解决常见问题的经验性解决方案。以下是一些常用的设计模式&#xff1a; 单例模式&#xff08;Singleton&#xff09;&#xff1a; 意图&#xff1a;确保一个类只有一个实例&#xff0c;并…...

LeetCode:对称的二叉树(C语言)

1、问题概述&#xff1a;给一个二叉树&#xff0c;看是否按轴对称 2、示例 示例 1&#xff1a; 输入&#xff1a;root [1,2,2,3,4,4,3] 输出&#xff1a;true 示例 2&#xff1a; 输入&#xff1a;root [1,2,2,null,3,null,3] 输出&#xff1a;false 3、分析 &#xff08;1&a…...

Postman中的API Schema验证:确保响应精准无误

Postman中的API Schema验证&#xff1a;确保响应精准无误 在API开发和测试过程中&#xff0c;验证响应数据的准确性和一致性是至关重要的。Postman提供了一个强大的功能——API Schema验证&#xff0c;它允许开发者根据预定义的JSON Schema来检查API响应。本文将详细介绍如何在…...

深入浅出WebRTC—GCC

GoogCcNetworkController 是 GCC 的控制中心&#xff0c;它由 RtpTransportControllerSend 通过定时器和 TransportFeedback 来驱动。GoogCcNetworkController 不断更新内部各个组件的状态&#xff0c;并协调组件之间相互配合&#xff0c;向外输出目标码率等重要参数&#xff0…...

leetcode日记(49)旋转链表

其实不难&#xff0c;就是根据kk%len判断需要旋转的位置&#xff0c;再将后半段接在前半段前面就行。 /*** Definition for singly-linked list.* struct ListNode {* int val;* ListNode *next;* ListNode() : val(0), next(nullptr) {}* ListNode(int x) : …...

InteliJ IDEA最新2024版下载安装与快速配置激活使用教程+jdk下载配置

第一步&#xff1a;下载ideaIC-2024.1.4 方法1&#xff1a;在线链接 IntelliJ IDEA – the Leading Java and Kotlin IDE (jetbrains.com) 选择社区版进行下载 方法2&#xff1a;百度网盘 链接&#xff1a;https://pan.baidu.com/s/1ydS6krUX6eE_AdW4uGV_6w?pwdsbfm 提取…...

【23】Android高级知识之Window(四) - ThreadedRenderer

一、概述 在上一篇文章中已经讲了setView整个流程中&#xff0c;最开始的addToDisplay和WMS跨进程通信的整个过程做了什么。继文章Android基础知识之Window(二)&#xff0c;这算是另外一个分支了&#xff0c;接着讲分析在performTraversals的三个操作中&#xff0c;最后触发pe…...

Java-根据前缀-日期-数字-生成流水号(不重复)

&#x1f388;边走、边悟&#x1f388;迟早会好 小伙伴们在日常开发时可能会遇到的业务-生成流水号&#xff0c;在企业中可以说是比较常见的需求&#xff0c; 可以采用"前缀日期数字"的方式&#xff08;ps:此方式是需要用到缓存的&#xff09;前缀&#xff1a;为了…...

跟李沐学AI:卷积层

从全连接层到卷积 多层感知机十分适合处理表格数据&#xff0c;其中行对应样本&#xff0c;列对应特征。但对于图片等数据&#xff0c;全连接层会导致参数过多。卷积神经网络&#xff08;convolutional neural networks&#xff0c;CNN&#xff09;是机器学习利用自然图像中一…...

使用RedisTemplate操作executePipelined

前言 RedisTemplate 是 Spring 提供的用于操作 Redis 的模板类&#xff0c;它封装了 Redis 的连接、连接池等管理&#xff0c;并提供了一系列的操作方法来简化 Redis 的使用。其中&#xff0c;executePipelined 方法是 RedisTemplate 中的一个高级特性&#xff0c;用于支持 Re…...

react-native从入门到实战系列教程一环境安装篇

充分阅读官网的环境配置指南&#xff0c;严格按照他的指导作业&#xff0c;不然你一直只能在web或沙箱环境下玩玩 极快的网络和科学上网&#xff0c;必备其中的一个较好的心理忍受能力&#xff0c;因为上面一点就可以让你放弃坚持不懈&#xff0c;努力尝试 成功效果 三大件 …...

【Gin】精准应用:Gin框架中工厂模式的现代软件开发策略与实施技巧(下)

【Gin】精准应用&#xff1a;Gin框架中工厂模式的现代软件开发策略与实施技巧(下) 大家好 我是寸铁&#x1f44a; 【Gin】精准应用&#xff1a;Gin框架中工厂模式的现代软件开发策略与实施技巧(下)✨ 喜欢的小伙伴可以点点关注 &#x1f49d; 前言 本次文章分为上下两部分&…...

国科大作业考试资料-人工智能原理与算法-2024新编-第十二次作业整理

袋子里面有3个有偏差的硬币a、b和c,抛掷硬币正面朝上的概率分别是20%、60%和80%。从袋子里随机取出一个硬币(3个硬币被取出的概率是相等的),并把取出的硬币抛掷3次,得到抛掷结果依次是X1 , X2和 X3。 a. 画出对应的贝叶斯网络并定义必要的CPT表。 b. 如果抛掷结果是2次正…...

《0基础》学习Python——第二十一讲__网络爬虫/<4>爬取豆瓣电影电影信息

爬取网页数据&#xff08;获取网页信息全过程&#xff09; 1、爬取豆瓣电影的电影名称、导演、主演、年份、国家、评价 2、首先我们先爬取页面然后再获取信息 1、爬取网页源码 import requests from lxml import etree if __name__ __main__:#UA伪装head{User-Agent:Mozilla/…...

【C++初阶】string类

【C初阶】string类 &#x1f955;个人主页&#xff1a;开敲&#x1f349; &#x1f525;所属专栏&#xff1a;C&#x1f96d; &#x1f33c;文章目录&#x1f33c; 1. 为什么学习string类&#xff1f; 1.1 C语言中的字符串 1.2 实际中 2. 标准库中的string类 2.1 string类 2.…...

RAS--APEI 报错解析流程(2)

RAS--APEI 报错解析流程(1) 除了APEI 中除了GHES会记录错误&#xff0c;在Post过程中的错误通常是通过BERT Table汇报 1.BERT Boot Error Record Table is used to report unhandled errors that occurred in a previous boot&#xff0c;it is reported as a ‘one-time polle…...

微软蓝屏事件对企业数字化转型有什么影响?

引言&#xff1a;从北京时间2024年7月19日&#xff08;周五&#xff09;下午2点多开始&#xff0c;全球大量Windows用户出现电脑崩溃、蓝屏死机、无法重启等情况。事发后&#xff0c;网络安全公司CrowdStrike称&#xff0c;收到大量关于Windows电脑出现蓝屏报告&#xff0c;公司…...

Linux 文件类型,目录与路径,文件与目录管理

文件类型 后面的字符表示文件类型标志 普通文件&#xff1a;-&#xff08;纯文本文件&#xff0c;二进制文件&#xff0c;数据格式文件&#xff09; 如文本文件、图片、程序文件等。 目录文件&#xff1a;d&#xff08;directory&#xff09; 用来存放其他文件或子目录。 设备…...

【Go】3、Go语言进阶与依赖管理

前言 本系列文章参考自稀土掘金上的 【字节内部课】公开课&#xff0c;做自我学习总结整理。 Go语言并发编程 Go语言原生支持并发编程&#xff0c;它的核心机制是 Goroutine 协程、Channel 通道&#xff0c;并基于CSP&#xff08;Communicating Sequential Processes&#xff0…...

C# 类和继承(抽象类)

抽象类 抽象类是指设计为被继承的类。抽象类只能被用作其他类的基类。 不能创建抽象类的实例。抽象类使用abstract修饰符声明。 抽象类可以包含抽象成员或普通的非抽象成员。抽象类的成员可以是抽象成员和普通带 实现的成员的任意组合。抽象类自己可以派生自另一个抽象类。例…...

unix/linux,sudo,其发展历程详细时间线、由来、历史背景

sudo 的诞生和演化,本身就是一部 Unix/Linux 系统管理哲学变迁的微缩史。来,让我们拨开时间的迷雾,一同探寻 sudo 那波澜壮阔(也颇为实用主义)的发展历程。 历史背景:su的时代与困境 ( 20 世纪 70 年代 - 80 年代初) 在 sudo 出现之前,Unix 系统管理员和需要特权操作的…...

智能分布式爬虫的数据处理流水线优化:基于深度强化学习的数据质量控制

在数字化浪潮席卷全球的今天&#xff0c;数据已成为企业和研究机构的核心资产。智能分布式爬虫作为高效的数据采集工具&#xff0c;在大规模数据获取中发挥着关键作用。然而&#xff0c;传统的数据处理流水线在面对复杂多变的网络环境和海量异构数据时&#xff0c;常出现数据质…...

处理vxe-table 表尾数据是单独一个接口,表格tableData数据更新后,需要点击两下,表尾才是正确的

修改bug思路&#xff1a; 分别把 tabledata 和 表尾相关数据 console.log() 发现 更新数据先后顺序不对 settimeout延迟查询表格接口 ——测试可行 升级↑&#xff1a;async await 等接口返回后再开始下一个接口查询 ________________________________________________________…...

C++课设:简易日历程序(支持传统节假日 + 二十四节气 + 个人纪念日管理)

名人说:路漫漫其修远兮,吾将上下而求索。—— 屈原《离骚》 创作者:Code_流苏(CSDN)(一个喜欢古诗词和编程的Coder😊) 专栏介绍:《编程项目实战》 目录 一、为什么要开发一个日历程序?1. 深入理解时间算法2. 练习面向对象设计3. 学习数据结构应用二、核心算法深度解析…...

android13 app的触摸问题定位分析流程

一、知识点 一般来说,触摸问题都是app层面出问题,我们可以在ViewRootImpl.java添加log的方式定位;如果是touchableRegion的计算问题,就会相对比较麻烦了,需要通过adb shell dumpsys input > input.log指令,且通过打印堆栈的方式,逐步定位问题,并找到修改方案。 问题…...

pycharm 设置环境出错

pycharm 设置环境出错 pycharm 新建项目&#xff0c;设置虚拟环境&#xff0c;出错 pycharm 出错 Cannot open Local Failed to start [powershell.exe, -NoExit, -ExecutionPolicy, Bypass, -File, C:\Program Files\JetBrains\PyCharm 2024.1.3\plugins\terminal\shell-int…...

绕过 Xcode?使用 Appuploader和主流工具实现 iOS 上架自动化

iOS 应用的发布流程一直是开发链路中最“苹果味”的环节&#xff1a;强依赖 Xcode、必须使用 macOS、各种证书和描述文件配置……对很多跨平台开发者来说&#xff0c;这一套流程并不友好。 特别是当你的项目主要在 Windows 或 Linux 下开发&#xff08;例如 Flutter、React Na…...