首页 > 其他分享 >基于GPU 显卡在k8s 集群上实现hpa 功能

基于GPU 显卡在k8s 集群上实现hpa 功能

时间:2022-11-30 15:46:47浏览次数:39  
标签:exporter name ack prometheus GPU gpu 显卡 hpa

前言

Kubernetes 支持HPA模块进行容器伸缩,默认支持CPU和内存等指标。原生的HPA基于Heapster,不支持GPU指标的伸缩,但是支持通过CustomMetrics的方式进行HPA指标的扩展。我们可以通过部署一个基于Prometheus Adapter 作为CustomMetricServer,它能将Prometheus指标注册的APIServer接口,提供HPA调用。 通过配置,HPA将CustomMetric作为扩缩容指标, 可以进行GPU指标的弹性伸缩。

阿里云容器Kubernetes监控-GPU监控

  • k8s集群准备好gpu 服务器
# kubectl get node 
NAME                    STATUS   ROLES    AGE    VERSION
master-11               Ready    master   466d   v1.18.20
master-12               Ready    master   466d   v1.18.20
master-13               Ready    master   466d   v1.18.20
slave-gpu-103           Ready    <none>   159d   v1.18.20
slave-gpu-105           Ready    <none>   160d   v1.18.20
slave-gpu-109           Ready    <none>   160d   v1.18.20
slave-rtx3080-gpu-111   Ready    <none>   6d3h   v1.18.20
  • 给每个GPU 服务器打上标签、并添加污点
kubectl label node slave-gpu-103 aliyun.accelerator/nvidia_name=yes
kubectl taint node slave-gpu-103 gpu_type=moviebook:NoSchedule
  • 部署Prometheus 的GPU 采集器,网络采用hostNetwork
# cat gpu-exporter.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
  namespace: monitoring
  name: ack-prometheus-gpu-exporter
spec:
  selector:
    matchLabels:
      k8s-app: ack-prometheus-gpu-exporter
  template:
    metadata:
      labels:
        k8s-app: ack-prometheus-gpu-exporter
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: aliyun.accelerator/nvidia_name
                operator: Exists
      hostNetwork: true
      hostPID: true
      containers:
      - name: node-gpu-exporter
        image: registry.cn-hangzhou.aliyuncs.com/acs/gpu-prometheus-exporter:0.1-5cc5f27
        imagePullPolicy: Always
        ports:
        - name: http-metrics
          containerPort: 9445
        env:
          - name: MY_NODE_NAME
            valueFrom:
              fieldRef:
                apiVersion: v1
                fieldPath: spec.nodeName
        resources:
          requests:
            memory: 50Mi
            cpu: 200m
          limits:
            memory: 100Mi
            cpu: 300m
        volumeMounts:
        - mountPath: /var/run/docker.sock
          name: docker-sock
      volumes:
      - hostPath:
          path: /var/run/docker.sock
          type: File
        name: docker-sock
      tolerations:
      - effect: NoSchedule
        key: server_type
        operator: Exists
---
apiVersion: v1
kind: Service
metadata:
  name: node-gpu-exporter
  namespace: monitoring
  labels:
    k8s-app: ack-prometheus-gpu-exporter
spec:
  type: ClusterIP
  ports:
  - name: http-metrics
    port: 9445
    protocol: TCP
  selector:
    k8s-app: ack-prometheus-gpu-exporter

---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: ack-prometheus-gpu-exporter
  labels:
    release: ack-prometheus-operator
    app: ack-prometheus-gpu-exporter
  namespace: monitoring
spec:
  selector:
    matchLabels:
      k8s-app: ack-prometheus-gpu-exporter
  namespaceSelector:
    matchNames:
    - monitoring
  endpoints:
  - port: http-metrics
    interval: 30s

#创建GPU 采集器
kubectl apply  -f  gpu-exporter.yaml 
  • prometheus 增加监控GPU 服务器实例列表
# kubectl edit cm -n prometheus  prometheus-conf 

      - job_name: 'GPU服务监控'
        static_configs:
          #- targets: ['node-gpu-exporter.monitoring:9445']
          - targets:
            - 10.147.100.103:9445
            - 10.147.100.105:9445
            - 10.147.100.111:9445
            - 10.147.100.109:9445
#重启prometheus 使配置文件生效

#查看prometheus gpu信息相关指标 nvidia_gpu_duty_cycle

  • PROMETHEUS ADAPTER的证书

标签:exporter,name,ack,prometheus,GPU,gpu,显卡,hpa
From: https://www.cnblogs.com/lixinliang/p/16938630.html

相关文章

  • 《XY6739CW 4G 核心板》采用PowerVR GE8100 GPU !——安卓9.0
        《XY6739CW4G核心板》为研发人员基于联发科MT6739P平台自主研发的一款4G全网通核心板,具有丰富的接口便于二次开发使用,硬件软件集成度高,易于开发,扩展方便,且性价......
  • 矩池云|GPU 分布式使用教程之 TensorFlow
    GPU分布式使用教程之TensorFlowTensorFlow提供了6种策略实现分布式计算,各个策略详情请参考官方文档。本文档使用MirroredStrategy实现单机多卡分布式,MultiWorkerMirr......
  • 真实感渲染:WebGPU介绍和使用光栅化管线绘制一个三角形
    大家好~本课程为“真实感渲染”的线上课程,从0开始,介绍相关的图形学算法和数学基础,给出详细的数学推导、伪代码和实现代码,最终带领大家开发出基于物理的渲染器线上课程资料......
  • k8s 基于hpa弹性伸缩实验
    HPA基本原理 kubectlscale 命令可以来实现Pod的扩缩容功能,但是这个毕竟是完全手动操作的,要应对线上的各种复杂情况,我们需要能够做到自动化去感知业务,来自动进行扩缩......
  • 核心显卡是新一代的智能图形核心
    核心显卡是新一代的智能图形核心,它整合在智能处理器当中,依托处理器强大的运算能力和智能能效调节设计,在更低功耗下实现同样出色的图形处理性能和流畅的应用体验。​......
  • 自己的笔记本电脑为什么不能驱动独立显卡?
    这个问题有几个原因,简单来讲就是macOS驱动独立显卡要求固件能正确提供VBIOS(条件一),以及独立显卡提供直通通道(条件二),被macOS免驱支持的芯片型号(条件三)。详细来说具体如下......
  • nvidia显卡的售后真的是不敢要人恭维——拆机箱时误拧显卡自身挡板螺丝被拒保
    事情比较简单,单位在nvidia的经销商那里购买的nvidiatitanrtx显卡,保修期内坏掉,拆下来的过程中误拧了挡板的螺丝,结果被拒保,这里就是单纯的记录这件事情。 这件事确实我这方......
  • win10安装tensorflow-gpu-1.15
    因课程要求,需要安装tensorflow1.15。我是使用conda来管理不同环境的。总的步骤为:查看tensorflow1.15对应python,cuda,cudnn版本安装python,cuda,cudnn安装tensorf......
  • 带GPU的Pytorch安装【看看避坑啊!】
    之前写过一篇如何安装Pytorch的博客,但主要是CPU版本的,注意的事项还比较少。现在专门再记录一遍安装GPU版本的。CPU版本参考:Pytorch的安装前言一定要记住,先看自己电脑......
  • ubuntu显卡及驱动
    2022-11-25一、概述计算机的一个重要组成部分是处理器,包括CPU和GPU,CPU包括算数运算和逻辑运算。通常一个电脑都包含CPU,而不一定配备GPU。GPU更擅长图像处理及矩阵运算,包......