热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

prometheus09-k8s部署grafana

1.部署grafana?apiVersion:?appsv1?kind:?StatefulSet?metadata:??name:?grafana??namespace:?kube-systemspec:??serviceName:?grafana??repl

1.部署grafana 

apiVersion: apps/v1 
kind: StatefulSet 
metadata:
  name: grafana
  namespace: kube-system
spec:
  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: v1
kind: Service
metadata:
  name: grafana
  namespace: kube-system
spec:
  type: NodePort
  ports:
  - port : 80
    targetPort: 3000
    nodePort: 30007
  selector:
    app: grafana

2.storageclass提前创建好的

[root@kubemaster01 grafana]# kubectl  get sc
NAME                  PROVISIONER      AGE
managed-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)          AGE
grafana                NodePort    169.169.180.248           80:30007/TCP     6m33s

4.访问 添加数据源 出图

prometheus09-k8s部署grafana

prometheus09-k8s部署grafana

prometheus09-k8s部署grafana

prometheus09-k8s部署grafana

prometheus09-k8s部署grafana


推荐阅读
author-avatar
az旺成电料
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有