62 lines
2.4 KiB
YAML
62 lines
2.4 KiB
YAML
apiVersion: v1
|
||
kind: Secret
|
||
metadata:
|
||
name: keda-prom-secret
|
||
namespace: bj2-dcloud
|
||
stringData:
|
||
customAuthHeader: "Authorization"
|
||
customAuthValue: "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lc3BhY2UiOiJjcHJvbS11ejJuZ3J6YmpyN243Iiwic2VjcmV0TmFtZSI6IjJjMTI4NGJhZTUxYjRiZjNhMmU2MjM1NTc4NDRjNmQ2IiwiZXhwIjo0OTIzODc3ODIyLCJpc3MiOiJjcHJvbSJ9.idZaTKtQR4WOyr29T_TKZ9cGz2nW9N5Mw-5SBu321p8"
|
||
|
||
---
|
||
apiVersion: keda.sh/v1alpha1
|
||
kind: TriggerAuthentication
|
||
metadata:
|
||
name: keda-prom-creds
|
||
namespace: bj2-dcloud
|
||
spec:
|
||
secretTargetRef:
|
||
- parameter: customAuthHeader
|
||
name: keda-prom-secret
|
||
key: customAuthHeader
|
||
- parameter: customAuthValue
|
||
name: keda-prom-secret
|
||
key: customAuthValue
|
||
|
||
---
|
||
apiVersion: keda.sh/v1alpha1
|
||
kind: ScaledObject
|
||
metadata:
|
||
name: gpu-metrics-scaledobject
|
||
namespace: bj2-dcloud
|
||
spec:
|
||
scaleTargetRef:
|
||
apiVersion: apps/v1
|
||
kind: Deployment
|
||
name: dstereox
|
||
minReplicaCount: 1
|
||
maxReplicaCount: 2
|
||
# idleReplicaCount: 0 # 当指标为0时,保持0副本
|
||
pollingInterval: 30 # 每30秒检查一次指标
|
||
cooldownPeriod: 300 # 扩容后等待5分钟再进行下一次扩容
|
||
# initialCooldownPeriod: 0 # 启动后立即检查指标
|
||
|
||
# fallback: # Optional. Section to specify fallback options
|
||
# failureThreshold: 3 # Mandatory if fallback section is included
|
||
# replicas: 6 # Mandatory if fallback section is included
|
||
# behavior: {kind-of-behavior} # Optional. Default: "static"
|
||
triggers:
|
||
# ---------------------------------------------------------
|
||
# 触发器 1: 基于 GPU 利用率 (DCGM)
|
||
# ---------------------------------------------------------
|
||
- type: prometheus
|
||
metadata:
|
||
serverAddress: https://cprom.bj.baidubce.com/select/prometheus
|
||
metricName: dcgm_gpu_utilization
|
||
# query: avg(avg_over_time(DCGM_FI_DEV_GPU_UTIL{namespace="bj2-dcloud",pod=~"dstereox-.*"}[3m]))
|
||
query: max(avg_over_time(DCGM_FI_DEV_GPU_UTIL{pod_name=~"dstereox.*"}[3m]))
|
||
customHeaders: InstanceId=cprom-uz2ngrzbjr7n7
|
||
threshold: "50" # 80%利用率时扩容;计算目标副本数
|
||
activationThreshold: "30" # 30%利用率时开始扩容;判断是否激活 scaler
|
||
authModes: "custom"
|
||
authenticationRef:
|
||
name: keda-prom-creds |