一、 Deployment配置文件

[root@master grafana]# vi grafana-deploy.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: grafana
  namespace: kube-ops
  labels:
    app: grafana
spec:
  revisionHistoryLimit: 10
  template:
    metadata:
      labels:
        app: grafana
    spec:
      containers:
      - name: grafana
        image: grafana/grafana:5.3.4
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 3000
          name: grafana
        env:
        - name: GF_SECURITY_ADMIN_USER
          value: admin
        - name: GF_SECURITY_ADMIN_PASSWORD
          value: admin321
        readinessProbe:
          failureThreshold: 10
          httpGet:
            path: /api/health
            port: 3000
            scheme: HTTP
          initialDelaySeconds: 60
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 30
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /api/health
            port: 3000
            scheme: HTTP
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        resources:
          limits:
            cpu: 100m
            memory: 256Mi
          requests:
            cpu: 100m
            memory: 256Mi
        volumeMounts:
        - mountPath: /var/lib/grafana
          subPath: grafana
          name: www
      securityContext:
        fsGroup: 472
        runAsUser: 472
      volumes:
      - name: storage
        emptyDir: {}
      - name: www
        persistentVolumeClaim: 
          claimName: prometheus-nfs-v3

二、 Service配置文件

[root@master grafana]# vi grafana-svc.yaml
apiVersion: v1
kind: Service
metadata:
  name: grafana
  namespace: kube-ops
  labels:
    app: grafana
spec:
  type: NodePort
  ports:
    - port: 3000
  selector:
    app: grafana

三、 PersistentVolume

[root@master grafana]# vim grafana-volume.yaml 
apiVersion: v1
kind: PersistentVolume
metadata:
  name: prometheus-nfs-v3
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  - ReadOnlyMany
  - ReadWriteMany
  persistentVolumeReclaimPolicy: Recycle
  nfs:
    server: 192.168.0.24
    path: /data/nfs/server-20-nfs-v3

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: prometheus-nfs-v3
  namespace: kube-ops
spec:
  accessModes:
  - ReadWriteOnce
  - ReadOnlyMany
  - ReadWriteMany
  resources:
    requests:
      storage: 10Gi

四、登陆

http://192.168.10.31:31339/login admin/admin123

五、添加DB

六、模板

可以去官方寻找可用的仪表盘ID:

重用的有:

  • 9276
  • 162
  • 193
  • 7362
最后修改日期: 2020年3月31日

作者

留言

撰写回覆或留言

发布留言必须填写的电子邮件地址不会公开。