千家信息网

prometheus09-k8s部署grafana

发表于:2024-12-12 作者:千家信息网编辑
千家信息网最后更新 2024年12月12日,1.部署grafanaapiVersion: apps/v1 kind: StatefulSet metadata: name: grafana namespace: kube-systemspe
千家信息网最后更新 2024年12月12日prometheus09-k8s部署grafana

1.部署grafana

apiVersion: apps/v1 kind: StatefulSet metadata:  name: grafana  namespace: kube-systemspec:  serviceName: "grafana"  replicas: 1  selector:    matchLabels:      app: grafana  template:    metadata:      labels:        app: grafana    spec:      containers:      - name: grafana        image: grafana/grafana        ports:          - containerPort: 3000            protocol: TCP        resources:          limits:            cpu: 100m                        memory: 256Mi                    requests:            cpu: 100m                        memory: 256Mi        volumeMounts:          - name: grafana-data            mountPath: /var/lib/grafana            subPath: grafana      securityContext:        fsGroup: 472        runAsUser: 472  volumeClaimTemplates:  - metadata:      name: grafana-data    spec:      storageClassName: managed-nfs-storage       accessModes:        - ReadWriteOnce      resources:        requests:          storage: "1Gi"---apiVersion: v1kind: Servicemetadata:  name: grafana  namespace: kube-systemspec:  type: NodePort  ports:  - port : 80    targetPort: 3000    nodePort: 30007  selector:    app: grafana

2.storageclass提前创建好的

[root@kubemaster01 grafana]# kubectl  get scNAME                  PROVISIONER      AGEmanaged-nfs-storage   fuseim.pri/ifs   4h25m[root@kubemaster01 grafana]#

3.访问

[root@kubemaster01 grafana]# kubectl  get svc   -n  kube-system NAME                   TYPE        CLUSTER-IP        EXTERNAL-IP   PORT(S)          AGEgrafana                NodePort    169.169.180.248           80:30007/TCP     6m33s

4.访问 添加数据源 出图

0