Google Cloud Platform Storage
GCS(Google Cloud Storage) 버킷 안의 객체 수를 기준으로 워크로드를 스케일링하는 scaler예요. 워커가 실행되면서 버킷의 객체를 삭제하거나 이동시켜 정리할 것이라고 가정해요.
출처: 문서
본문
트리거 명세 (Trigger Specification)
이 명세는 주어진 GCS(Google Cloud Storage) 버킷의 객체 수에 따라 Kubernetes 워크로드를 스케일링하는 gcp-storage scaler를 설명해요. 이 scaler는 워커가 실행될 때 버킷 안의 객체를 삭제하거나 이동시켜 정리할 것이라고 가정해요.
triggers:
- type: gcp-storage
metadata:
bucketName: test-bucket
targetObjectCount: '100'
activationTargetObjectCount: '10' # Optional
maxBucketItemsToScan: '1000'
credentialsFromEnv: GOOGLE_APPLICATION_CREDENTIALS_JSON # Optional
credentialsFromEnvFile: GOOGLE_APPLICATION_CREDENTIALS_JSON # Optional
blobPrefix: # Optional. Prefix for the Blob. Use this to specify sub path for the blobs if required. Default : ""
blobDelimiter: # Optional. Delimiter for identifying the blob Prefix. Default: ""
파라미터 목록은 다음과 같아요.
- bucketName - GCS의 버킷 이름이에요.
- targetObjectCount - 스케일링 동작을 트리거하는 평균 타깃 값이에요. (기본값: 100, 선택 사항)
- activationTargetObjectCount - scaler를 활성화하기 위한 타깃 값이에요. activation에 대한 자세한 내용은 여기에서 확인할 수 있어요. (기본값: 0, 선택 사항)
- maxBucketItemsToScan - 버킷의 객체 수를 언제까지 셀지예요. (기본값: 1000, 선택 사항)
- blobPrefix - Blob의 접두사예요. 필요하면 Blob의 하위 경로를 지정할 때 사용해요. (기본값: "", 선택 사항)
- blobDelimiter - blob 접두사를 식별하는 데 쓰는 구분자예요. (기본값: "", 선택 사항)
객체 수를 세는 것은 객체 메타데이터를 반복하는 작업을 수반하므로, 이 값을 targetObjectCount * maxReplicaCount 값으로 설정하는 것을 권장해요.
메트릭 이름은 트리거 인덱스와 bucketName을 기반으로 자동 생성돼요. 예: s0-gcp-storage-bucketName.
metadata에서 credentialsFromEnv 또는 credentialsFromEnvFile 중 하나를 제공할 수 있어요.
- credentialsFromEnv - 자격 증명 정보를 담고 있는 환경 변수의 이름으로 설정해요.
- credentialsFromEnvFile - 자격 증명 정보를 담고 있는 json 파일의 이름으로 설정해요.
인증 파라미터 (Authentication Parameters)
TriggerAuthentication CRD를 사용해 서비스 계정 자격 증명을 JSON으로 제공해 인증을 구성할 수 있어요.
Credential 기반 인증:
- GoogleApplicationCredentials - JSON 형식의 서비스 계정 자격 증명이에요.
Identity 기반 인증:
TriggerAuthentication CRD를 사용해 Google Cloud에서 실행 중인 머신과 연결된 서비스 계정으로 인증을 구성할 수도 있어요. 아래 예시처럼 TriggerAuthentication을 생성하고 ScaledObject에서 참조하기만 하면 돼요. 클러스터 안에서 전역적으로 사용하려면 ClusterTriggerAuthentication도 사용할 수 있어요.
예시 (Examples)
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: gcp-storage-scaledobject
namespace: keda-gcp-storage-test
spec:
scaleTargetRef:
name: keda-gcp-storage-go
triggers:
- type: gcp-storage
metadata:
bucketName: "Transactions"
targetObjectCount: "5"
credentialsFromEnv: GOOGLE_APPLICATION_CREDENTIALS_JSON
Kubernetes secret과 함께 TriggerAuthentication 사용
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-gcp-credentials
spec:
secretTargetRef:
- parameter: GoogleApplicationCredentials
name: gcp-storage-secret # Required. Refers to the name of the secret
key: GOOGLE_APPLICATION_CREDENTIALS_JSON # Required.
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: gcp-storage-scaledobject
spec:
scaleTargetRef:
name: keda-gcp-storage-go
triggers:
- type: gcp-storage
authenticationRef:
name: keda-trigger-auth-gcp-credentials
metadata:
bucketName: "Transactions"
targetObjectCount: "5"
blobPrefix: blobsubpath # Default : ""
blobDelimiter: "/" # Default: ""
GCP Identity와 함께 TriggerAuthentication 사용
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-gcp-credentials
spec:
podIdentity:
provider: gcp
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: gcp-storage-scaledobject
spec:
scaleTargetRef:
name: keda-gcp-storage-go
triggers:
- type: gcp-storage
authenticationRef:
name: keda-trigger-auth-gcp-credentials
metadata:
bucketName: "Transactions"
targetObjectCount: "5"
더 알아보기 (Learn more)
GCS 버킷에 쌓인 객체 수를 기준으로 워크로드를 스케일링하는 방법을 살펴봤어요. 인증은 자격 증명 JSON 또는 GCP identity 중 원하는 방식을 골라 구성할 수 있어요.