K8s下部署grafana

1. 系统要求

最小化的软硬件要求

最小化硬件要求

  • 磁盘空间: 1 GB
  • 内存: 750 MiB (approx 750 MB)
  • CPU: 250m (approx 2.5 cores)

2. k8s部署grafana步骤

1) 创建名字空间

kubectl create namespace my-grafana

 2) 创建yaml

vim  grafana.yaml

 yaml包含如下三个资源对象

Object Description
Persistent Volume Claim (PVC) 存储声明
Service 提供pod的网络访问
Deployment 负责创建pod,并确保可以滚动更新和管理副本集
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: grafana-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: grafana
  name: grafana
spec:
  selector:
    matchLabels:
      app: grafana
  template:
    metadata:
      labels:
        app: grafana
    spec:
      securityContext:
        fsGroup: 472
        supplementalGroups:
          - 0
      containers:
        - name: grafana
          image: grafana/grafana:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 3000
              name: http-grafana
              protocol: TCP
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /robots.txt
              port: 3000
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 2
          livenessProbe:
            failureThreshold: 3
            initialDelaySeconds: 30
            periodSeconds: 10
            successThreshold: 1
            tcpSocket:
              port: 3000
            timeoutSeconds: 1
          resources:
            requests:
              cpu: 250m
              memory: 750Mi
          volumeMounts:
            - mountPath: /var/lib/grafana
              name: grafana-pv
      volumes:
        - name: grafana-pv
          persistentVolumeClaim:
            claimName: grafana-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: grafana
spec:
  ports:
    - port: 3000
      protocol: TCP
      targetPort: http-grafana
  selector:
    app: grafana
  sessionAffinity: None
  type: LoadBalancer

 3) 执行yaml

这里并没有创建pv,所以要确保有可用的pv使用(至少要有1Gi的pv可用),才可以执行如下的命令

kubectl apply -f grafana.yaml --namespace=my-grafana

 4) 查看结果

kubectl get pv,pvc,deployment -n my-grafana

 

 5) 访问grafana

kubectl get svc -n my-grafana

grafana的service采用的是NodePort方式暴露服务,因此可以通过映射的随机端口31483进行访问:

 

 这里k8s部署grafana就算成功了

相关推荐

  1. k8s部署grafana

    2024-04-11 09:56:08       11 阅读
  2. kubekey部署k8s

    2024-04-11 09:56:08       41 阅读

最近更新

  1. 什么是voc数据,和coco数据的区别是什么?

    2024-04-11 09:56:08       0 阅读
  2. Spring Boot 创建定时任务

    2024-04-11 09:56:08       0 阅读
  3. Redis

    2024-04-11 09:56:08       0 阅读
  4. C语言2D游戏

    2024-04-11 09:56:08       0 阅读
  5. Docker 容器出现 IP 冲突

    2024-04-11 09:56:08       1 阅读
  6. 构建安全稳定的应用:SpringSecurity实用指南

    2024-04-11 09:56:08       1 阅读
  7. 事务的范围比锁的范围大

    2024-04-11 09:56:08       1 阅读

热门阅读

  1. Css3梳理篇——animation(动画)

    2024-04-11 09:56:08       16 阅读
  2. Mac环境简化RSA密钥生成命令

    2024-04-11 09:56:08       12 阅读
  3. 项目成本管理写作思路

    2024-04-11 09:56:08       16 阅读
  4. Python的re模块

    2024-04-11 09:56:08       16 阅读
  5. 软件测试常见面试题目合集【测试面试】

    2024-04-11 09:56:08       13 阅读
  6. myweb项目资料集

    2024-04-11 09:56:08       16 阅读
  7. 深入理解与实践:npm常用命令全面解析

    2024-04-11 09:56:08       12 阅读
  8. Git 的基本概念和使用方式

    2024-04-11 09:56:08       14 阅读
  9. QT_数据库

    2024-04-11 09:56:08       13 阅读
  10. oracle恢复异常处理

    2024-04-11 09:56:08       13 阅读
  11. 模板方法模式

    2024-04-11 09:56:08       14 阅读