GKE 추론 게이트웨이

이 문서에서는 Google Cloud Managed Service for Prometheus를 사용하여 GKE Inference Gateway에서 측정항목을 수집할 수 있도록 Google Kubernetes Engine 배포를 구성하는 방법을 설명합니다. 이 문서에서는 다음을 수행하는 방법을 보여줍니다.

  • 측정항목을 보고하도록 GKE 추론 게이트웨이를 설정합니다.
  • Cloud Monitoring에서 사전 정의된 대시보드에 액세스하여 측정항목을 확인합니다.

이 안내는 관리형 컬렉션을 Managed Service for Prometheus와 함께 사용하는 경우에만 적용됩니다. 자체 배포 컬렉션을 사용하는 경우 GKE Inference Gateway 문서에서 설치 정보를 참조하세요.

이 안내는 예시로서 제공되며 대부분의 Kubernetes 환경에서 작동합니다. 제한적인 보안 또는 조직 정책으로 인해 애플리케이션 또는 내보내기 도구를 설치하는 데 문제가 있으면 지원을 위한 오픈소스 문서를 참조하는 것이 좋습니다.

GKE Inference Gateway에 대한 자세한 내용은 GKE Inference Gateway를 참고하세요.

기본 요건

Managed Service for Prometheus 및 관리형 컬렉션을 사용하여 GKE Inference Gateway 내보내기 도구에서 측정항목을 수집하려면 배포가 다음 요구사항을 충족해야 합니다.

  • 클러스터가 Google Kubernetes Engine 버전 1.28.15-gke.2475000 이상을 실행 중이어야 합니다.
  • 관리형 컬렉션이 사용 설정된 상태에서 Managed Service for Prometheus를 실행 중이어야 합니다. 자세한 내용은 관리형 컬렉션 시작하기를 참조하세요.

GKE Inference Gateway 내보내기는 Prometheus 형식 측정항목을 자동으로 노출하므로 별도로 설치할 필요가 없습니다.

GKE Inference Gateway 내보내기 도구가 예상 엔드포인트에서 측정항목을 내보내는지 확인하려면 다음을 수행합니다.

  1. 보안 비밀, ServiceAccount, ClusterRole, ClusterBinding을 추가합니다. GKE 추론 게이트웨이 내보내기 도구 관측 가능성 엔드포인트는 인증 토큰으로 보호됩니다. 사용자 인증 정보를 가져오려면 클라이언트에 연결된 ClusterRole이 있는 서비스 계정에 매핑되는 보안 비밀이 nonResourceURLs: "/metrics", verbs: get 규칙에 필요합니다. 자세한 내용은 서비스 계정의 보안 비밀 만들기를 참고하세요.

  2. 다음 명령어를 사용하여 포트 전달을 설정합니다.

    kubectl -n NAMESPACE_NAME port-forward POD_NAME 9090
    
  3. 다른 창에서 다음 단계를 따르세요.

    1. 다음 명령어를 실행하여 토큰을 가져옵니다.

      TOKEN=$(kubectl -n default get secret inference-gateway-sa-metrics-reader-secret  -o jsonpath='{.secrets[0].name}' -o jsonpath='{.data.token}' | base64 --decode)
      
    2. curl 유틸리티를 사용하여 엔드포인트 localhost:9090/metrics에 액세스합니다.

      curl -H "Authorization: Bearer $TOKEN" localhost:9090/metrics
      

서비스 계정의 보안 비밀 만들기

GKE 추론 게이트웨이 내보내기 도구 엔드포인트를 보호하려면 Managed Service for Prometheus 연산자에 gmp-system 네임스페이스에서 승인된 측정항목 수집을 위한 비밀이 필요합니다.

클러스터에서 Autopilot 모드를 사용하는 경우 gmp-systemgke-gmp-system으로 바꿉니다.

다음 Secret, ServiceAccount, ClusterRole, ClusterRoleBinding 구성을 사용할 수 있습니다.

# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: inference-gateway-metrics-reader
rules:
- nonResourceURLs:
  - /metrics
  verbs:
  - get
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: inference-gateway-sa-metrics-reader
  namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: inference-gateway-sa-metrics-reader-role-binding
  namespace: default
subjects:
- kind: ServiceAccount
  name: inference-gateway-sa-metrics-reader
  namespace: default
roleRef:
  kind: ClusterRole
  name: inference-gateway-metrics-reader
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: v1
kind: Secret
metadata:
  name: inference-gateway-sa-metrics-reader-secret
  namespace: default
  annotations:
    kubernetes.io/service-account.name: inference-gateway-sa-metrics-reader
type: kubernetes.io/service-account-token
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: inference-gateway-sa-metrics-reader-secret-read
rules:
- resources:
  - secrets
  apiGroups: [""]
  verbs: ["get", "list", "watch"]
  resourceNames: ["inference-gateway-sa-metrics-reader-secret"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: gmp-system:collector:inference-gateway-sa-metrics-reader-secret-read
  namespace: default
roleRef:
  name: inference-gateway-sa-metrics-reader-secret-read
  kind: ClusterRole
  apiGroup: rbac.authorization.k8s.io
subjects:
- name: collector
  namespace: gmp-system
  kind: ServiceAccount

자세한 내용은 내보내기 도구의 측정항목 및 관측 가능성 가이드를 참고하세요.

로컬 파일에서 구성 변경사항을 적용하려면 다음 명령어를 실행합니다.

kubectl apply -n NAMESPACE_NAME -f FILE_NAME

Terraform을 사용하여 구성을 관리할 수도 있습니다.

ClusterPodMonitoring 리소스 정의

대상 검색을 위해 Managed Service for Prometheus 연산자에는 동일한 네임스페이스의 GKE Inference Gateway 내보내기 도구에 해당하는 ClusterPodMonitoring 리소스가 필요합니다.

다음 ClusterPodMonitoring 구성을 사용할 수 있습니다.

# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: monitoring.googleapis.com/v1
kind: ClusterPodMonitoring
metadata:
  name: inference-optimized-gateway-monitoring
  labels:
    app.kubernetes.io/name: inference-optimized-gateway
    app.kubernetes.io/part-of: google-cloud-managed-prometheus
spec:
  endpoints:
  - port: metrics
    scheme: http
    interval: 5s
    path: /metrics
    authorization:
      type: Bearer
      credentials:
        secret:
          name: inference-gateway-sa-metrics-reader-secret
          key: token
          namespace: default
  selector:
    matchLabels:
      app: inference-gateway-ext-proc

GKE 추론 게이트웨이는 다른 네임스페이스의 보안 비밀에 액세스해야 하므로 PodMonitoring 리소스 대신 ClusterPodMonitoring 리소스를 사용합니다.

ClusterPodMonitoring 구성의 matchLabels 선택기에서 inference-gateway-ext-procapp 값을 GKE 추론 게이트웨이 배포의 라벨로 바꿀 수 있습니다. portmatchLabels 필드의 값이 모니터링하려는 GKE Inference Gateway 포드의 값과 일치하는지 확인합니다.

로컬 파일에서 구성 변경사항을 적용하려면 다음 명령어를 실행합니다.

kubectl apply -n NAMESPACE_NAME -f FILE_NAME

Terraform을 사용하여 구성을 관리할 수도 있습니다.

구성 확인

측정항목 탐색기를 사용하여 GKE Inference Gateway 내보내기 도구를 올바르게 구성했는지 확인할 수 있습니다. Cloud Monitoring이 측정항목을 수집하는 데 1~2분 정도 걸릴 수 있습니다.

측정항목이 수집되었는지 확인하려면 다음을 수행하세요.

  1. Google Cloud 콘솔에서  측정항목 탐색기 페이지로 이동합니다.

    측정항목 탐색기로 이동

    검색창을 사용하여 이 페이지를 찾은 경우 부제목이 Monitoring인 결과를 선택합니다.

  2. 쿼리 빌더 창의 툴바에서 이름이  MQL 또는  PromQL인 버튼을 선택합니다.
  3. 언어 전환 버튼에 PromQL이 선택되어 있는지 확인합니다. 언어 전환 버튼은 쿼리 형식을 지정할 수 있는 동일한 툴바에 있습니다.
  4. 다음 쿼리를 입력하고 실행합니다.
    inference_model_request_total{cluster="CLUSTER_NAME", namespace="NAMESPACE_NAME"}

대시보드 보기

Cloud Monitoring 통합에는 GKE Inference Gateway Prometheus 개요 대시보드가 포함됩니다. 대시보드는 통합을 구성할 때 자동으로 설치됩니다. 통합을 설치하지 않고도 대시보드의 정적 미리보기를 볼 수 있습니다.

설치된 대시보드를 보려면 다음을 수행합니다.

  1. Google Cloud 콘솔에서 대시보드 페이지로 이동합니다.

    대시보드로 이동

    검색창을 사용하여 이 페이지를 찾은 경우 부제목이 Monitoring인 결과를 선택합니다.

  2. 대시보드 목록 탭을 선택합니다.
  3. 통합 카테고리를 선택합니다.
  4. 대시보드의 이름을 클릭합니다(예: GKE Inference Gateway Prometheus 개요).

대시보드의 정적 미리보기를 보려면 다음을 수행합니다.

  1. Google Cloud 콘솔에서 통합 페이지로 이동합니다.

    통합으로 이동

    검색창을 사용하여 이 페이지를 찾은 경우 부제목이 Monitoring인 결과를 선택합니다.

  2. Kubernetes Engine 배포 플랫폼 필터를 클릭합니다.
  3. GKE Inference Gateway 통합을 찾고 세부정보 보기를 클릭합니다.
  4. 대시보드 탭을 선택합니다.

문제 해결

측정항목 수집 문제 해결에 대한 자세한 내용은 수집 측 문제 해결에서 내보내기 도구의 수집 관련 문제를 참조하세요.