CloudEvent 지원 (CloudEvent Support)
KEDA가 발생시키는 이벤트를 CloudEvent 형식으로 구독할 수 있어요. CloudEventSource 리소스로 사용자가 지정한 CloudEvent 싱크(sink)로 이벤트를 전달하는 방법을 배워볼게요.
출처: 문서
본문
CloudEventSource로 이벤트 구독하기 (Subscribing to events with CloudEventSource)
CloudEventSource 리소스는 사용자가 정의한 CloudEvent 싱크로 발행되는 이벤트를 구독하는 데 KEDA에서 사용할 수 있어요.
📝
CloudEventSource리소스가 생성되면 KEDA는 계속해서 Kubernetes 이벤트를 발행하면서도, 이 문서에 나열된 지원 이벤트 유형에 대해서는 추가로 CloudEvent도 발행해요.
다음은 CloudEventSource CRD의 스키마예요.
apiVersion: eventing.keda.sh/v1alpha1
kind: CloudEventSource
metadata:
name: {cloud-event-name}
spec:
clusterName: {cluster-name} #Optional. Will be used in the source/subject to specify where the event comes from. The default value is 'kubernetes-default' and it can also be set during the installation of KEDA with --k8sClusterName. This one will overwrite others if set.
authenticationRef:
name: {trigger-authentication-name} #Optional. Used to reference a `TriggerAuthentication` for authentication.
kind: TriggerAuthentication # Optional. Used to choose the authentication scopes. https://keda.sh/docs/latest/concepts/authentication/#authentication-scopes-namespace-vs-cluster
destination:
http:
uri: http://foo.bar
azureEventGridTopic:
endpoint: https://my-topic.eastus-1.eventgrid.azure.net/api/events
eventSubscription: #Optional. Submit included/excluded event types will filter events when emitting events.
includedEventTypes: #Optional. Only events in this section will be emitted.
- keda.scaledobject.failed.v1
excludedEventTypes: #Optional. Events in this section will not be emitted.
- keda.scaledobject.ready.v1
일반적으로 KEDA가 발행하는 이벤트는 기본적으로 이런 구조로 내려와요.
{
"specversion" : "1.0",
"type" : "com.cloudeventsource.keda",
"source" : "/{cluster-name}/{keda-namespace}/keda",
"subject" : "/{cluster-name}/{namespace}/{object-type}/{object-name}",
"id" : "<guid>",
"time" : "2018-04-05T17:31:00Z",
"datacontenttype" : "application/json",
"data" : {
"reason":"<event-reason>",
"message":"<event-message>"
}
}
이벤트 싱크 (Event Sinks)
KEDA 이벤트를 전달할 수 있는 목적지는 여러 종류가 있어요. 지원되는 목적지 개요는 다음과 같아요.
- HTTP 엔드포인트.
- Azure Event Grid 엔드포인트.
HTTP 엔드포인트 (HTTP endpoint)
destination:
http:
uri: http://foo.bar #An http endpoint that can receive cloudevent
Azure Event Grid
destination:
azureEventGrid:
endpoint: foo.bar #endpoint from AzureEventGrid Topic
인증 정보는 authenticationRef로 제공해야 해요. TriggerAuthentication을 제공해 Azure Event Grid 인증을 위한 액세스 키 또는 관리 ID(managed identity)를 넘길 수 있어요. 지원되는 인증 유형 개요는 다음과 같아요.
연결 문자열 인증 (Connection String Authentication)
accessKey- Azure Event Grid 연결 인증용 액세스 키 문자열.
Pod identity 기반 인증 (Pod identity based authentication)
Azure AD Workload Identity provider를 사용할 수 있어요.
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: nameOfTriggerAuth
namespace: default
spec:
podIdentity:
provider: azure-workload
이벤트 필터 (Event Filter)
어떤 이벤트 유형에 관심이 있는지, 또는 어떤 이벤트를 무시하고 싶은지 정의하는 필터를 포함할 수 있어요. 이는 주어진 싱크에 대해 각각 includedEventTypes 또는 excludedEventTypes로 처리해요.
eventSubscription: #Optional. Submit included/excluded event types will filter events when emitting events.
includedEventTypes: #Optional. Only events in this section will be emitted.
- keda.scaledobject.failed.v1
excludedEventTypes: #Optional. Events in this section will not be emitted.
- keda.scaledobject.ready.v1
지원 이벤트 목록 (Supported Event List)
| 이벤트 유형 (Event Type) | 시나리오 설명 (Scenario Description) |
|---|---|
| keda.scaledobject.ready.v1 | ScaledObject가 처음으로 준비 상태가 되었거나, 객체의 이전 준비 조건 상태가 Unknown 또는 False일 때 |
| keda.scaledobject.failed.v1 | ScaledObject의 검증(validation)이 실패할 때 |
| keda.scaledobject.removed.v1 | ScaledObject가 삭제될 때 |
| keda.scaledobject.paused.v1 | ScaledObject가 일시 중지될 때 |
| keda.scaledobject.unpaused.v1 | ScaledObject가 일시 중지 해제될 때 |
| keda.scaledjob.ready.v1 | ScaledJob이 처음으로 준비 상태가 되었거나, 객체의 이전 준비 조건 상태가 Unknown 또는 False일 때 |
| keda.scaledjob.failed.v1 | ScaledJob의 검증(validation)이 실패할 때 |
| keda.scaledjob.removed.v1 | ScaledJob이 삭제될 때 |
| keda.scaledjob.paused.v1 | ScaledJob이 일시 중지될 때 |
| keda.scaledjob.unpaused.v1 | ScaledJob이 일시 중지 해제될 때 |
| keda.scaledjob.rolloutcleanup.started.v1 | KEDA가 이전 버전의 ScaledJob이 소유한 Job 정리를 시작할 때 |
| keda.scaledjob.rolloutcleanup.completed.v1 | KEDA가 이전 버전의 ScaledJob이 소유한 Job 정리를 완료할 때 |
| keda.scaledjob.rolloutcleanup.failed.v1 | KEDA가 이전 버전의 ScaledJob이 소유한 Job 삭제를 실패할 때 |
| keda.authentication.triggerauthentication.created.v1 | TriggerAuthentication이 처음 생성될 때 |
| keda.authentication.triggerauthentication.updated.v1 | TriggerAuthentication이 업데이트될 때 |
| keda.authentication.triggerauthentication.removed.v1 | TriggerAuthentication이 삭제될 때 |
| keda.authentication.clustertriggerauthentication.created.v1 | ClusterTriggerAuthentication이 처음 생성될 때 |
| keda.authentication.clustertriggerauthentication.updated.v1 | ClusterTriggerAuthentication이 업데이트될 때 |
| keda.authentication.clustertriggerauthentication.removed.v1 | ClusterTriggerAuthentication이 삭제될 때 |
더 알아보기 (Learn more)
이벤트 기반 알림이나 감사(audit) 파이프라인을 만들 때 CloudEventSource를 활용하면 KEDA 운영 상태를 외부 시스템으로 흘려보낼 수 있어요. 싱크와 필터를 조합해서 필요한 이벤트만 골라 받아보세요.