ALB 컨트롤러 - 백 엔드 상태 및 메트릭

Kubernetes 서비스 및 Pod의 백 엔드 상태를 이해하는 것은 문제를 식별하고 문제 해결 시 도움을 주는 데 매우 중요합니다. 백 엔드 상태를 쉽게 파악할 수 있도록 ALB 컨트롤러는 모든 ALB 컨트롤러 배포에서 백 엔드 상태와 메트릭 엔드포인트 정보를 노출합니다.

ALB 컨트롤러의 백 엔드 상태는 다음의 세 가지 환경을 노출합니다.

  1. 컨테이너용 Application Gateway 리소스에서 요약된 백 엔드 상태
  2. Kubernetes 서비스에서 요약된 백 엔드 상태
  3. 지정된 Kubernetes 서비스에 대한 자세한 백 엔드 상태

ALB 컨트롤러의 메트릭 엔드포인트는 백 엔드 상태의 메트릭과 요약 정보를 모두 노출합니다. 이 엔드포인트를 사용하면 Prometheus에 노출될 수 있습니다.

다음 URL을 통해 이러한 엔드포인트에 액세스할 수 있습니다.

  • 백 엔드 상태 - http://<alb-controller-pod-ip>:8000/backendHealth
    • 출력은 JSON 형식입니다.
  • 메트릭 - http://<alb-controller-pod-ip>:8001/metrics
    • 출력은 텍스트 형식입니다.

이 Pod와 포트에 연결된 모든 클라이언트 또는 Pod에서 이러한 엔드포인트에 액세스할 수 있습니다. 액세스를 제한하려면 Kubernetes 네트워크 정책을 사용하여 특정 클라이언트에 대한 액세스를 제한하는 하는 것이 좋습니다.

백 엔드 상태

백 엔드 상태 검색

ALB 컨트롤러는 기본 역할을 하는 ALB 컨트롤러 Pod의 백 엔드 상태를 노출합니다.

기본 Pod를 찾으려면 다음 명령을 실행합니다.

CONTROLLER_NAMESPACE='azure-alb-system'
kubectl get lease -n $CONTROLLER_NAMESPACE alb-controller-leader-election -o jsonpath='{.spec.holderIdentity}' | awk -F'_' '{print $1}'

kubectl 유틸리티를 통한 간접 액세스의 경우, Pod로의 트래픽을 프록시하는 수신기를 만들 수 있습니다.

kubectl port-forward <pod-name> -n $CONTROLLER_NAMESPACE 8000 8001

kubectl 명령이 수신 대기 중이면 다른 터미널(또는 클라우드 셸 세션)을 열고 127.0.0.1로 curl을 실행하여 Pod로 리디렉션합니다.

curl http://127.0.0.1:8000

예제 응답:

Available paths:
Path: /backendHealth
Description: Prints the backend health of the ALB.
Query Parameters:
        detailed: if true, prints the detailed view of the backend health
        alb-id: Resource ID of the Application Gateway for Containers to filter backend health for.
        service-name: Service to filter backend health for. Expected format: \<namespace\>/\<service\>/\<service-port-number\>

Path: /
Description: Prints the help

컨테이너용 Application Gateway에서 요약된 백 엔드 상태

이 환경은 컨테이너용 Application Gateway 및 해당 상태에 대한 참조를 사용하여 모든 Kubernetes 서비스를 요약합니다.

이 환경에는 alb-controller Pod에 대한 요청 쿼리에서 컨테이너용 Application Gateway 리소스 ID를 지정하면 액세스할 수 있습니다.

다음 명령을 사용하여 지정된 컨테이너용 Application Gateway 리소스의 백 엔드 상태를 프로브할 수 있습니다.

curl http://\<alb-controller-pod-ip-address\>:8000/backendHealth?alb-id=/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/yyyyyyyy/providers/Microsoft.ServiceNetworking/trafficControllers/zzzzzzzzzz

예제 출력:

{
  "services": [
    {
      "serviceName": "default/service-hello-world/80",
      "serviceHealth": [
        {
          "albId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/yyyyyyyy/providers/Microsoft.ServiceNetworking/trafficControllers/zzzzzzzzzz",
          "totalEndpoints": 1,
          "totalHealthyEndpoints": 1,
          "totalUnhealthyEndpoints": 0
        }
      ]
    },
    {
      "serviceName": "default/service-contoso/443",
      "serviceHealth": [
        {
          "albId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/yyyyyyyy/providers/Microsoft.ServiceNetworking/trafficControllers/zzzzzzzzzz",
          "totalEndpoints": 1,
          "totalHealthyEndpoints": 1,
          "totalUnhealthyEndpoints": 0
        }
      ]
    }
  ]
}

Kubernetes 서비스에서 요약된 백 엔드 상태

이 환경은 지정된 서비스의 상태 요약 상태를 검색합니다.

이 환경에는 alb-controller Pod에 <namespace>/<service>/<service-port-number> 쿼리 문자열 형식으로 네임스페이스의 이름, 서비스, 서비스의 포트 번호를 입력하면 액세스할 수 있습니다.

다음 명령을 사용하여 지정된 Kubernetes 서비스의 백 엔드 상태를 프로브할 수 있습니다.

curl http://\<alb-controller-pod-ip-address\>:8000/backendHealth?service-name=default/service-hello-world/80

예제 출력:

{
  "services": [
    {
      "serviceName": "default/service-hello-world/80",
      "serviceHealth": [
        {
          "albId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/yyyyyyyy/providers/Microsoft.ServiceNetworking/trafficControllers/zzzzzzzzzz",
          "totalEndpoints": 1,
          "totalHealthyEndpoints": 1,
          "totalUnhealthyEndpoints": 0
        }
      ]
    }
  ]
}

지정된 Kubernetes 서비스에 대한 자세한 백 엔드 상태

이 환경은 해당하는 상태와 IP 주소를 비롯해 서비스를 구성하는 모든 엔드포인트를 보여 줍니다. 엔드포인트 상태는 정상 또는 비정상으로 보고됩니다.

이 환경에는 alb-controller Pod에 대한 쿼리 문자열에서 detailed=true를 지정하면 액세스할 수 있습니다.

예를 들어 다음 명령을 실행하여 개별 엔드포인트 상태를 확인할 수 있습니다.

curl http://\<alb-controller-pod-ip-address\>:8000/backendHealth?service-name=default/service-hello-world/80\&detailed=true

예제 출력:

{
  "services": [
    {
      "serviceName": "default/service-hello-world/80",
      "serviceHealth": [
        {
          "albId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/yyyyyyyy/providers/Microsoft.ServiceNetworking/trafficControllers/zzzzzzzzzz",
          "totalEndpoints": 1,
          "totalHealthyEndpoints": 1,
          "totalUnhealthyEndpoints": 0,
          "endpoints": [
            {
              "address": "10.1.1.22",
              "health": {
                "status": "HEALTHY"
              }
            }
          ]
        }
      ]
    }
  ]
}

메트릭

ALB 컨트롤러는 현재 Prometheus에 노출될 텍스트 기반 형식에 따라 메트릭을 표시합니다. 이러한 로그에 대한 액세스는 기본 alb 컨트롤러 Pod http://\<alb-controller-pod-ip\>:8001/metrics의 포트 8001에서 사용할 수 있습니다.

현재 공개된 메트릭은 다음과 같습니다.

메트릭 이름 설명
alb_connection_status 컨테이너용 Application Gateway 리소스에 대한 연결 상태
alb_reconnection_count 컨테이너용 Application Gateway 리소스에 대한 재연결 시도 횟수
total_config_updates 서비스 라우팅 구성 작업 횟수
total_endpoint_updates 백 엔드 풀 구성 작업 횟수
total_deployments 컨테이너용 Application Gateway 리소스 배포 횟수
total_endpoints 서비스의 엔드포인트 수
total_healthy_endpoints 서비스의 정상 엔드포인트 수
total_unhealthy_endpoints 서비스의 비정상 엔드포인트 수