K8s可视化监控告警【2】--Grafana部署

秒速五厘米 2023-06-30 13:53 43阅读 0赞

1. app部署

  1. apiVersion: v1
  2. kind: ReplicationController
  3. metadata:
  4. name: grafana-core
  5. namespace: kube-system
  6. labels:
  7. monitor: grafana
  8. component: core
  9. spec:
  10. replicas: 1
  11. template:
  12. metadata:
  13. labels:
  14. monitor: grafana
  15. component: core
  16. spec:
  17. tolerations:
  18. - key: node-role.kubernetes.io/master
  19. operation: Equal
  20. effect: NoSchedule
  21. containers:
  22. - image: grafana/grafana:4.2.0
  23. name: grafana-core
  24. imagePullPolicy: IfNotPresent
  25. # env:
  26. resources:
  27. # keep request = limit to keep this container in guaranteed class
  28. limits:
  29. cpu: 100m
  30. memory: 100Mi
  31. requests:
  32. cpu: 100m
  33. memory: 100Mi
  34. env:
  35. # The following env variables set up basic auth twith the default admin user and admin password.
  36. - name: GF_AUTH_BASIC_ENABLED
  37. value: "true"
  38. - name: GF_AUTH_ANONYMOUS_ENABLED
  39. value: "false"
  40. # - name: GF_AUTH_ANONYMOUS_ORG_ROLE
  41. # value: Admin
  42. # does not really work, because of template variables in exported dashboards:
  43. # - name: GF_DASHBOARDS_JSON_ENABLED
  44. # value: "true"
  45. readinessProbe:
  46. httpGet:
  47. path: /login
  48. port: 3000
  49. # initialDelaySeconds: 30
  50. # timeoutSeconds: 1
  51. volumeMounts:
  52. - name: grafana-persistent-storage
  53. mountPath: /var
  54. volumes:
  55. - name: grafana-persistent-storage
  56. emptyDir: { }
  57. ---
  58. apiVersion: v1
  59. kind: Service
  60. metadata:
  61. name: grafana
  62. namespace: kube-system
  63. labels:
  64. monitor: grafana
  65. component: core
  66. spec:
  67. type: NodePort
  68. ports:
  69. - port: 3000 # 访问服务名即可跳转到对于目标容器端口
  70. protocol: TCP
  71. targetPort: 3000 # 容器开放端口
  72. nodePort: 33000 # 绑定集群节点端口
  73. selector:
  74. monitor: grafana
  75. component: core

访问URL:http://节点IP:33000
2. 添加数据源
在这里插入图片描述

3. 添加模板
在这里插入图片描述

访问http://节点IP:33000/dashboard/db/kubernetes-cluster-monitoring-via-prometheus?refresh=10s&orgId=1

发表评论

表情:
评论列表 (有 0 条评论,43人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Grafana 系统监控

            随着业务的复杂性,对软件系统的要求越来越高,意味着我们需要随时掌控系统的运行情况。因此,对系统的实时监控以及可视化展示,就成了基础架构的必须能力。 Grafa