1. 查看 grafana deployment
$ kubectl get deployment -n kube-vm
$ kubectl get deployment victoria-metrics-k8s-stack-0-1682237547-grafana -n kube-vm -o yaml
...
containers:
- env:
- name: METHOD
value: WATCH
- name: LABEL # configmap 和 secret 必须包含此标签
value: grafana_dashboard
- name: FOLDER # 放置文件的目录
value: /tmp/dashboards
- name: RESOURCE # both 代表监控 configmap 和 secret
value: both
# https://github.com/kiwigrid/k8s-sidecar
# 监控带 grafana_dashboard 标签的 configmap 和 secret
image: quay.io/kiwigrid/k8s-sidecar:1.19.2
...
- env:
- name: METHOD
value: WATCH
- name: LABEL
value: grafana_datasource
- name: FOLDER
value: /etc/grafana/provisioning/datasources
- name: RESOURCE
value: both
- name: REQ_USERNAME
valueFrom:
secretKeyRef:
key: admin-user
name: victoria-metrics-k8s-stack-0-1682237547-grafana
- name: REQ_PASSWORD
valueFrom:
secretKeyRef:
key: admin-password
name: victoria-metrics-k8s-stack-0-1682237547-grafana
- name: REQ_URL
value: http://localhost:3000/api/admin/provisioning/datasources/reload
- name: REQ_METHOD
value: POST
# 监控带 grafana_datasource 标签的 configmap 和 secret
image: quay.io/kiwigrid/k8s-sidecar:1.19.2
...
- env:
- name: GF_SECURITY_ADMIN_USER
valueFrom:
secretKeyRef:
key: admin-user
name: victoria-metrics-k8s-stack-0-1682237547-grafana
- name: GF_SECURITY_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
key: admin-password
name: victoria-metrics-k8s-stack-0-1682237547-grafana
- name: GF_PATHS_DATA
value: /var/lib/grafana/
- name: GF_PATHS_LOGS
value: /var/log/grafana
- name: GF_PATHS_PLUGINS
value: /var/lib/grafana/plugins
- name: GF_PATHS_PROVISIONING
value: /etc/grafana/provisioning
image: grafana/grafana:9.3.0 # grafana 主容器
...
volumeMounts:
- mountPath: /etc/grafana/grafana.ini
name: config
subPath: grafana.ini
- mountPath: /var/lib/grafana
name: storage
- mountPath: /etc/grafana/provisioning/dashboards/dashboardproviders.yaml
name: config
subPath: dashboardproviders.yaml
- mountPath: /tmp/dashboards
name: sc-dashboard-volume
- mountPath: /etc/grafana/provisioning/dashboards/sc-dashboardproviders.yaml
name: sc-dashboard-provider
subPath: provider.yaml
- mountPath: /etc/grafana/provisioning/datasources
name: sc-datasources-volume
dnsPolicy: ClusterFirst
enableServiceLinks: true
initContainers: # 初始化容器
- args:
- -c
- mkdir -p /var/lib/grafana/dashboards/default && /bin/sh -x /etc/grafana/download_dashboards.sh
command:
- /bin/sh
image: curlimages/curl:7.85.0
imagePullPolicy: IfNotPresent
name: download-dashboards
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /etc/grafana/download_dashboards.sh
name: config
subPath: download_dashboards.sh
- mountPath: /var/lib/grafana
name: storage
...
volumes:
- configMap:
defaultMode: 420
name: victoria-metrics-k8s-stack-0-1682237547-grafana
name: config
- configMap:
defaultMode: 420
name: victoria-metrics-k8s-stack-0-1682237547-grafana-dashboards-default
name: dashboards-default
- emptyDir: {}
name: storage
- emptyDir: {}
name: sc-dashboard-volume
- configMap:
defaultMode: 420
name: victoria-metrics-k8s-stack-0-1682237547-grafana-config-dashboards
name: sc-dashboard-provider
- emptyDir: {}
name: sc-datasources-volume
...
// 该目录保存所有的 dashboard
$ kubectl exec vm-stack-grafana-5774558dcb-vrlmv -c grafana -n kube-vm --ls /tmp/dashboards
alertmanager-overview.json
backupmanager.json
grafana-overview.json
k8s-system-coredns.json
k8s-views-global.json
k8s-views-namespaces.json
k8s-views-pods.json
operator.json
victoriametrics-cluster.json
vmagent.json
vmalert.json
作者:jackzang 创建时间:2023-04-25 17:43
最后编辑:jackzang 更新时间:2023-04-25 17:44
最后编辑:jackzang 更新时间:2023-04-25 17:44