본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Azure Monitor 스케일러

원문 보기 위키 갱신

Azure Monitor의 메트릭 값을 기준으로 워크로드를 자동 조정하는 스케일러예요. Azure 리소스에서 수집한 메트릭을 바라보며 파드 수를 늘리거나 줄이는 원리를 살펴볼게요.

출처: 문서

본문

트리거 명세 (Trigger Specification)

이 명세는 Azure Monitor 메트릭을 기준으로 스케일링하는 azure-monitor 트리거를 설명해요.

triggers:
- type: azure-monitor
  metadata:
    resourceURI: Microsoft.ContainerService/managedClusters/azureMonitorCluster
    tenantId: xxx-xxx-xxx-xxx-xxx
    subscriptionId: yyy-yyy-yyy-yyy-yyy
    resourceGroupName: azureMonitor
    metricName: kube_pod_status_ready
    metricFilter: namespace eq 'default'
    metricAggregationInterval: "0:1:0"
    metricInterval: FULL # Optional. Aggregate the full query window into one data point.
    targetValue: "0.5"
    activationTargetValue: "3.5"
    activeDirectoryClientId: <client id value> # Optional, can use TriggerAuthentication as well
    activeDirectoryClientIdFromEnv: CLIENT_ID_ENV_NAME # Optional, can use TriggerAuthentication as well
    activeDirectoryClientPasswordFromEnv: CLIENT_PASSWORD_ENV_NAME # Optional, can use TriggerAuthentication as well
    # Optional (Default: AzurePublicCloud)
    cloud: Private
    # Required when cloud = Private
    azureResourceManagerEndpoint: https://management.azure.airgap.com/
    # Required when cloud = Private.
    activeDirectoryEndpoint: https://login.airgap.example/

파라미터 목록:

  • resourceURI - <resourceProviderNamespace>/<resourceType>/<resourceName> 형식의 Azure 리소스 축약 URI예요.
  • tenantId - Azure 리소스가 속한 테넌트의 ID예요. 인증에 사용돼요.
  • subscriptionId - Azure 리소스가 속한 Azure 구독의 ID예요. 전체 리소스 URI를 결정하는 데 사용돼요.
  • resourceGroupName - Azure 리소스의 리소스 그룹 이름이에요.
  • metricName - 조회할 메트릭의 이름이에요. Azure 메트릭은 공식 문서에서 목록으로 확인할 수 있어요. Azure Monitor 사용자 지정 메트릭을 조회할 때는 사용자 지정 메트릭 이름을 지정해요.
  • metricNamespace - 메트릭 네임스페이스의 이름이에요. metricName이 사용자 지정 메트릭일 때 필수예요.
  • targetValue - 스케일링 동작을 트리거하는 목표 값이에요. (이 값은 float일 수 있어요)
  • activationTargetValue - 스케일러를 활성화하는 목표 값이에요. 활성화(activation)에 대해 더 알고 싶다면 여기를 참고해요. (기본값: 0, 선택 사항, 이 값은 float일 수 있어요)
  • metricAggregationType - Azure Monitor 메트릭의 집계 방식이에요. Average, Total, Maximum 등이 있으며 전체 목록은 공식 문서에서 확인할 수 있어요.
  • metricFilter - 공식 문서에 나열된 차원(dimensions)을 사용해 더 정밀하게 필터링하는 필터의 이름이에요. (선택 사항)
  • metricAggregationInterval - "hh:mm:ss" 형식으로 메트릭을 조회하는 시간 창이에요. (기본값: "0:5:0", 선택 사항)
  • metricInterval - 쿼리 창 내에서 메트릭 값을 집계할 때 사용하는 시간 입자(time grain)예요. Azure Monitor가 지원하는 ISO 8601 기간(예: PT5M)을 사용하거나, 완전한 metricAggregationInterval에 대해 하나의 데이터 포인트를 반환하도록 FULL을 사용해요. 생략하면 Azure Monitor의 기본 시간 입자인 PT1M을 사용해 기존 KEDA 동작을 유지해요. FULL을 쓰면 Total과 Count가 전체 쿼리 창을 다루므로, 그 전체 창 값에 맞게 targetValue와 activationTargetValue를 설정해야 해요. (선택 사항)
  • activeDirectoryClientId - 최소 Monitoring Reader 권한이 필요한 Active Directory 애플리케이션의 ID예요. (선택 사항)
  • activeDirectoryClientPasswordFromEnv - Active Directory 클라이언트 비밀번호를 담고 있는 환경 변수의 이름이에요. (선택 사항)
  • cloud - Azure 리소스가 속한 클라우드 환경의 이름이에요. (값: AzurePublicCloud, AzureUSGovernmentCloud, AzureGermanCloud, AzureChinaCloud, Private, 기본값: AzurePublicCloud, 선택 사항)
  • azureResourceManagerEndpoint - 클라우드 환경의 Azure Resource Manager 엔드포인트예요. (cloud가 Private일 때 필수. 예: AzureChinaCloud의 경우 https://management.chinacloudapi.cn/)
  • activeDirectoryEndpoint - 클라우드 환경의 Active Directory 엔드포인트예요. (cloud가 Private일 때 필수. 예: AzureChinaCloud의 경우 https://login.chinacloudapi.cn/)

일부 파라미터는 metadata에 직접 설정하는 대신 환경 변수로 제공할 수 있어요. 환경 변수에서 값을 가져오는 데 사용할 수 있는 파라미터 목록은 다음과 같아요:

  • activeDirectoryClientIdFromEnv - 최소 Monitoring Reader 권한이 필요한 Active Directory 애플리케이션의 ID로, activeDirectoryClientId와 비슷하지만 스케일 대상의 환경 변수에서 읽어요. (선택 사항)

인증 파라미터 (Authentication Parameters)

TriggerAuthentication CRD를 사용해 Azure Active Directory 자격 증명 세트를 제공하거나 pod identity를 사용해 인증을 구성할 수 있어요.

자격 증명 기반 인증(Credential based authentication):

  • activeDirectoryClientId - 최소 Monitoring Reader 권한이 필요한 Active Directory 애플리케이션의 ID예요.
  • activeDirectoryClientPassword - Active Directory 애플리케이션의 비밀번호예요.

사용자는 Azure 리소스에서 데이터를 읽을 수 있는 접근 권한이 필요해요.

Pod identity 기반 인증(Pod identity based authentication): Azure AD Workload Identity 제공자를 사용할 수 있어요.

예시 (Example)

apiVersion: v1
kind: Secret
metadata:
  name: azure-monitor-secrets
data:
  activeDirectoryClientId: <clientId>
  activeDirectoryClientPassword: <clientPassword>
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
  name: azure-monitor-trigger-auth
spec:
  secretTargetRef:
    - parameter: activeDirectoryClientId
      name: azure-monitor-secrets
      key: activeDirectoryClientId
    - parameter: activeDirectoryClientPassword
      name: azure-monitor-secrets
      key: activeDirectoryClientPassword
  # or Pod Identity, kind: Secret is not required in case of pod Identity
  podIdentity:
      provider: azure-workload
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: azure-monitor-scaler
spec:
  scaleTargetRef:
    name: azure-monitor-example
  minReplicaCount: 1
  maxReplicaCount: 10
  triggers:
  - type: azure-monitor
    metadata:
      resourceURI: Microsoft.ContainerService/managedClusters/azureMonitorCluster
      tenantId: xxx-xxx-xxx-xxx-xxx
      subscriptionId: yyy-yyy-yyy-yyy-yyy
      resourceGroupName: azureMonitor
      metricName: pod_custom_metric
      metricNamespace: pod_custom_metrics_namespace # required when monitoring custom metrics
      metricFilter: namespace eq 'default'
      metricAggregationInterval: "0:1:0"
      metricAggregationType: Average
      targetValue: "1"
    authenticationRef:
      name: azure-monitor-trigger-auth

더 알아보기 (Learn more)

사용자 지정 메트릭을 쓸 때는 metricNamespace를 꼭 함께 지정해야 해요. metricInterval을 FULL로 두면 창 전체를 하나의 데이터 포인트로 보므로, 목표 값도 그 전체 창 기준으로 맞춰야 한다는 점을 기억해 두세요. 인증은 시크릿과 pod identity 중 환경에 맞게 고르면 돼요.