安装
# helm repo add grafana https://grafana.github.io/helm-charts
# helm repo update
# helm search repo grafana
NAME CHART VERSION APP VERSION DESCRIPTION
grafana/grafana 6.1.7 7.3.3 The leading tool for querying and visualizing t...
# helm pull grafana/grafana version=6.1.7
# helm show values grafana-6.1.7.tgz
生成 grafana 配置文件:
# cat > grafana-config.yaml <<EOF
replicas: 1
deploymentStrategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
readinessProbe:
failureThreshold: 3
httpGet:
path: /api/health
port: 3000
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
livenessProbe:
httpGet:
path: /api/health
port: 3000
initialDelaySeconds: 60
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 30
failureThreshold: 10
image:
repository: grafana/grafana
tag: 7.3.3
pullPolicy: IfNotPresent
securityContext:
runAsUser: 472
runAsGroup: 472
fsGroup: 472
# 设置账号密码,即环境变量 GF_SECURITY_ADMIN_USER 和 GF_SECURITY_ADMIN_PASSWORD
adminUser: admin
adminPassword: kong62123
resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
# 设置持久存储 storage 挂载到 /var/lib/grafana
persistence:
type: pvc
enabled: true
storageClassName: alicloud-disk-efficiency
accessModes:
- ReadWriteMany
size: 20Gi
# 实现 chown -R 472:472 /var/lib/grafana 修改卷权限
initChownData:
enabled: true
image:
repository: busybox
tag: "1.31.1"
pullPolicy: IfNotPresent
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
securityContext:
runAsNonRoot: false
runAsUser: 0
ingress:
enabled: true
#ingressClassName: traefik
annotations:
kubernetes.io/ingress.class: traefik
path: /
hosts:
- grafana-loki.ingress.hupu.io
EOF
安装 grafana:
# helm install grafana grafana/grafana -f grafana-config.yaml -n grafana
查看 grafana 密码:
# kubectl get secret -n grafana grafana -o jsonpath="{.data}"
map[admin-password:cm9vdEAxMjM0 admin-user:YWRtaW4= ldap-toml:]
# kubectl get secret --namespace grafana grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
kong62123
注意:这里有一个 bug,就是通过 grafana 查询 loki 报错后,无法继续执行,必须刷新页面才能再次查询
网友评论