一 说明与官方文档
二 安装
configmap.yaml1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32apiVersion: v1
kind: ConfigMap
metadata:
namespace: kube-system
name: grafana-config
data:
GF_RENDERING_CALLBACK_URL: "http://grafana.internal.mafgwo.cn/"
GF_SERVER_ROOT_URL: "http://grafana.internal.mafgwo.cn"
GF_SERVER_DOMAIN: "grafana.internal.mafgwo.cn"
# GF_SERVER_HTTP_PORT: "3000"
GF_DATABASE_URL: "mysql://grafanaadm:grafana123@10.0.32.79:3306/grafana"
GF_DEFAULT_INSTANCE_NAME: "grafana"
GF_SECURITY_ADMIN_USER: "admin"
GF_AUTH_GITLAB_ENABLED: "true"
GF_AUTH_GITLAB_ALLOW_SIGN_UP: "true"
GF_AUTH_GITLAB_CLIENT_ID: "c940e6d357942f9fb983a9ba379b873ac5551f4838a7d54c29b65fd7abd6578e"
GF_AUTH_GITLAB_CLIENT_SECRET: "46f8e3b223af2d48ddba8f5b24ee470e15db9aeae3cb0def72d5708ef6c739f5"
GF_AUTH_GITLAB_SCOPES: "read_user openid api"
GF_AUTH_GITLAB_AUTH_URL: "http://gitlab.mafgwo.cn/oauth/authorize"
GF_AUTH_GITLAB_TOKEN_URL: "http://gitlab.mafgwo.cn/oauth/token"
GF_AUTH_GITLAB_API_URL: "http://gitlab.mafgwo.cn/api/v4"
GF_AUTH_ALLOWED_GROUPS: "grafana"
GF_AUTH_ROLE_ATTRIBUTE_PATH: "Viewer"
# GF_AUTH_OAUTH_AUTO_LOGIN: "true"
GF_SMTP_ENABLED: "true"
GF_SMTP_HOST: "smtp.exmail.qq.com:25"
GF_SMTP_USER: "cxq@qq.com"
GF_SMTP_PASSWORD: "xxxxxxxxx"
GF_SMTP_FROM_ADDRESS: "cxq@qq.com"
GF_SMTP_FROM_NAME: "Grafana"
GF_SMTP_SKIP_VERIFY: "true"
GF_INSTALL_PLUGINS: "foursquare-clouderamanager-datasource"
deploy.yaml1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: grafana
namespace: kube-system
spec:
replicas: 1
template:
metadata:
labels:
k8s-app: grafana
spec:
nodeSelector:
zone: system
containers:
- name: grafana
image: 10.0.35.243/grafana/grafana:8.4.4
livenessProbe:
failureThreshold: 1
httpGet:
path: /healthz
port: 3000
scheme: HTTP
initialDelaySeconds: 3
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 9
readinessProbe:
failureThreshold: 1
httpGet:
path: /healthz
port: 3000
scheme: HTTP
initialDelaySeconds: 3
periodSeconds: 15
successThreshold: 1
timeoutSeconds: 9
ports:
- name: ui
containerPort: 3000
envFrom:
- configMapRef:
name: grafana-config
apiVersion: v1
kind: Service
metadata:
labels:
# For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)
# If you are NOT using this as an addon, you should comment out this line.
kubernetes.io/cluster-service: 'true'
kubernetes.io/name: monitoring-grafana
name: grafana
namespace: kube-system
spec:
ports:
- port: 3000
targetPort: 3000
selector:
k8s-app: grafana
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: grafana
namespace: kube-system
spec:
rules:
- host: grafana.internal.mafgwo.cn
http:
paths:
- path: /
backend:
serviceName: grafana
servicePort: 3000
1 | kubectl apply -f configmap.yaml |
grafana的默认账号密码为admin/admin。