kubernetes部署grafana

Grafana是一款流行的开源可视化平台,它支持与多种监控系统的集成,如Prometheus、Zabbix等。它的优点包括:

界面美观,交互性好,支持各种图表展示和数据可视化效果;

易于安装和配置,可以快速地搭建起一个可视化监控系统;

提供了丰富的数据源和插件支持,可以与多种监控系统集成。

Grafana的缺点包括:

缺乏对数据采集和存储的支持,需要依赖其他监控系统;

对于大规模的监控需求,可能会存在性能问题;

使用kubernetes来部署grafana服务。亲测可用

1.部署pv

apiVersion: v1
kind: PersistentVolume
metadata:
  name: "grafana-data-pv"
  labels:
    name: grafana-data-pv
    release: stable
spec:
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Recycle
  nfs:
    path: /nfs/grafana/data
    server: 192.168.0.1

2.部署pvc

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: grafana-data-pvc
  namespace: ns-monitor
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
  selector:
    matchLabels:
      name: grafana-data-pv
      release: stable

3.部署deployement

kind: Deployment
apiVersion: apps/v1
metadata:
  labels:
    app: grafana
  name: grafana
  namespace: ns-monitor
spec:
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: grafana
  template:
    metadata:
      labels:
        app: grafana
    spec:
      securityContext:
        runAsUser: 0
      containers:
        - name: grafana
          image: grafana/grafana:9.5.2
          imagePullPolicy: IfNotPresent
          env:
            - name: GF_AUTH_BASIC_ENABLED
              value: "true"
            - name: GF_AUTH_ANONYMOUS_ENABLED
              value: "false"
          readinessProbe:
            httpGet:
              path: /login
              port: 3000
          volumeMounts:
            - mountPath: /var/lib/grafana
              name: grafana-data-volume
          ports:
            - containerPort: 3000
              protocol: TCP
      volumes:
        - name: grafana-data-volume
          persistentVolumeClaim:
            claimName: grafana-data-pvc

4.部署service

kind: Service
apiVersion: v1
metadata:
  labels:
    app: grafana
  name: grafana-service
  namespace: ns-monitor
spec:
  ports:
    - port: 3000
      targetPort: 3000
  selector:
    app: grafana
  type: NodePort

5.验证

部署完以后,开始进行验证
在浏览器输出svc的ip地址和端口号:http://10.101.182.198:3000,就可以访问grafana的页面了。

你可能感兴趣的:(云原生,kubernetes,grafana,容器,云原生)