Skip to main content

KEDA CRD


ScaledObject

apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: <name>
namespace: <namespace> # .spec.scaleTargetRef와 동일한 namespace로 설정
spec:
scaleTargetRef:
apiVersion: <apiVersion> # Default: apps/v1
kind: <kind> # Default: Deployment
name: <name> # Required
# Default: .spec.template.spec.containers[0].name
envSourceContainerName: <containerName>
pollingInterval: 30 # Default: 30
minReplicaCount: 1 # Default: 0
maxReplicaCount: 100 # Default: 100
# Default: 0, 트리거가 없을 때 유지할 파드 개수로 minReplicaCount보다 작아야함
idleReplicaCount: 0
cooldownPeriod: 300 # Default: 300
# fallback: # Optional, trigger확인에 실패했을 때, 유지할 파드 개유
# failureThreshold: 3
# replicas: 6
advanced:
# Default: false, ScaledObject가 삭제되었을 때, 원래 .spec.replicas 수로 복구할지 여부
restoreToOriginalReplicaCount: false
horizontalPodAutoscalerConfig: # Keda에 의해 생성될 HorizontalPodAutoscaler의 설정
name: <name> # Default: keda-hpa-<scaledObjectName>
behavior:
scaleUp:
# Max인 경우 정책 중 가장 높은 수치를 적용
selectPolicy: Max # Max|Min|Disabled
# Default:0, 0 ~ 3600 설정 가능
# 0인 경우 scaleUp 조건을 만족했을 때 즉시 scaleUp
stabilizationWindowSeconds: 0
policies:
# Percent: 현재 Pod 개수 * value / 100
# Pods: value
- type: Percent # Percent|Pods
value: <value>
periodSeconds: <period> # 정책을 적용할 주기
scaleDown:
selectPolicy: Max # Max|Min|Disabled
# Default: 300, 0 ~ 3600 설정 가능
# 300인 경우 300초 동안 scaleDown 조건을 만족했을 때 scaleDown
stabilizationWindowSeconds: 300
policies:
- type: Percent # Percent|Pods
value: <value>
periodSeconds: <period>
triggers:
# trigger 중 max 값으로 scale
- name: <triggerName> # Optional
type: <triggerType> # Required
metricType: AverageValue # AverageValue|Value|Utilization
metadata: # Required, 트리거 설정 정보
<key>: <value>
# authenticationRef:
# # TriggerAuthentication|ClusterTriggerAuthentication
# kind: TriggerAuthentication
# name: <name>
warning

처리가 오래걸리는 작업에 대해, 스케일 다운이 발생하면, 처리가 완료되지 않은 작업이 중단될 수 있습니다. 이 경우 terminationGracePeriodSeconds를 사용하거나, ScaledJob를 활용하는 방향으로 변경해야합니다.

  • pollingInterval: 트리거 확인 간격
  • cooldownPeriod: 모든 트리거가 비활성화 되었을 때, idle 상태가 되기까지 대기하는 시간(1 -> 0)
  • advanced
  • triggers
    • metricType
      • HorizontalPodAutoscaler: desiredReplicas = ceil[currentReplicas * ( currentMetricValue / desiredMetricValue )]
      • AverageValue: currentaMetricValue = <metric>/currentReplicas
      • Value: currentMetricValue = <metric>
      • Utilization: <usage>/<requested>의 평균값으로, CPU, Memory 타입 트리거에서만 사용가능합니다.

replicas * (msg / replicas) / target

ScaledJob

apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
name: <name>
namespace: <namespace>
spec:
jobTargetRef: