빠른 시작: Azure Event Grid를 사용하여 AKS(Azure Kubernetes Service) 이벤트 구독

Azure Event Grid는 게시-구독 모델을 사용하여 균일한 이벤트 소비를 제공하는 완전히 관리되는 이벤트 라우팅 서비스입니다.

이 빠른 시작에서는 AKS 클러스터를 만들고 AKS 이벤트를 구독합니다.

필수 구성 요소

참고 항목

여기 서비스 중단에서 볼 수 있듯이 EventGrid 알림과 관련된 문제가 있는 경우 AKS 작업은 영향을 받지 않으며 Event Grid 중단과 무관합니다.

AKS 클러스터 만들기

az aks create 명령을 사용하여 AKS 클러스터를 만듭니다. 다음 예에서는 MyResourceGroup 리소스 그룹에 하나의 노드가 있는 MyResourceGroup 리소스 그룹과 MyAKS라는 클러스터를 만듭니다.

az group create --name MyResourceGroup --location eastus
az aks create -g MyResourceGroup -n MyAKS --location eastus  --node-count 1 --generate-ssh-keys

AKS 이벤트 구독

az eventhubs namespace createaz eventhubs eventhub create를 사용하여 네임스페이스와 이벤트 허브를 만듭니다. 다음 예에서는 MyResourceGroup 리소스 그룹의 MyNamespace에 네임스페이스 MyNamespace와 이벤트 허브 MyEventGridHub를 만듭니다.

az eventhubs namespace create --location eastus --name MyNamespace -g MyResourceGroup
az eventhubs eventhub create --name MyEventGridHub --namespace-name MyNamespace -g MyResourceGroup

참고 항목

네임스페이스의 이름은 고유해야 합니다.

az eventgrid event-subscription create를 사용하여 AKS 이벤트를 구독합니다.

SOURCE_RESOURCE_ID=$(az aks show -g MyResourceGroup -n MyAKS --query id --output tsv)
ENDPOINT=$(az eventhubs eventhub show -g MyResourceGroup -n MyEventGridHub --namespace-name MyNamespace --query id --output tsv)
az eventgrid event-subscription create --name MyEventGridSubscription \
--source-resource-id $SOURCE_RESOURCE_ID \
--endpoint-type eventhub \
--endpoint $ENDPOINT

az eventgrid event-subscription list을 사용하여 AKS 이벤트 구독을 확인합니다.

az eventgrid event-subscription list --source-resource-id $SOURCE_RESOURCE_ID

다음 예시 출력은 MyAKS 클러스터의 이벤트를 구독하고 해당 이벤트가 MyEventGridHub 이벤트 허브로 전달됨을 보여 줍니다.

[
  {
    "deadLetterDestination": null,
    "deadLetterWithResourceIdentity": null,
    "deliveryWithResourceIdentity": null,
    "destination": {
      "deliveryAttributeMappings": null,
      "endpointType": "EventHub",
      "resourceId": "/subscriptions/SUBSCRIPTION_ID/resourceGroups/MyResourceGroup/providers/Microsoft.EventHub/namespaces/MyNamespace/eventhubs/MyEventGridHub"
    },
    "eventDeliverySchema": "EventGridSchema",
    "expirationTimeUtc": null,
    "filter": {
      "advancedFilters": null,
      "enableAdvancedFilteringOnArrays": null,
      "includedEventTypes": [
        "Microsoft.ContainerService.NewKubernetesVersionAvailable","Microsoft.ContainerService.ClusterSupportEnded","Microsoft.ContainerService.ClusterSupportEnding","Microsoft.ContainerService.NodePoolRollingFailed","Microsoft.ContainerService.NodePoolRollingStarted","Microsoft.ContainerService.NodePoolRollingSucceeded"
      ],
      "isSubjectCaseSensitive": null,
      "subjectBeginsWith": "",
      "subjectEndsWith": ""
    },
    "id": "/subscriptions/SUBSCRIPTION_ID/resourceGroups/MyResourceGroup/providers/Microsoft.ContainerService/managedClusters/MyAKS/providers/Microsoft.EventGrid/eventSubscriptions/MyEventGridSubscription",
    "labels": null,
    "name": "MyEventGridSubscription",
    "provisioningState": "Succeeded",
    "resourceGroup": "MyResourceGroup",
    "retryPolicy": {
      "eventTimeToLiveInMinutes": 1440,
      "maxDeliveryAttempts": 30
    },
    "systemData": null,
    "topic": "/subscriptions/SUBSCRIPTION_ID/resourceGroups/MyResourceGroup/providers/microsoft.containerservice/managedclusters/MyAKS",
    "type": "Microsoft.EventGrid/eventSubscriptions"
  }
]

AKS 이벤트가 발생하면 이벤트 허브에 해당 이벤트가 표시됩니다. 예를 들어 클러스터에 사용 가능한 Kubernetes 버전 목록이 변경되면 Microsoft.ContainerService.NewKubernetesVersionAvailable 이벤트가 표시됩니다. 현재 지원 내 업그레이드 및 클러스터에 사용할 수 있는 새로운 이벤트도 있습니다. AKS가 내보내는 이벤트에 대한 자세한 내용은 AKS(Azure Kubernetes Service)를 Event Grid 원본으로 사용을 참조하세요.

클러스터 및 구독 삭제

az group delete 명령을 사용하여 리소스 그룹, AKS 클러스터, 네임스페이스, 이벤트 허브 및 모든 관련 리소스를 제거합니다.

az group delete --name MyResourceGroup --yes --no-wait

참고 항목

클러스터를 삭제해도 AKS 클러스터에서 사용하는 Microsoft Entra 서비스 주체는 제거되지 않습니다. 서비스 주체를 제거하는 방법에 대한 단계는 AKS 서비스 주체 고려 사항 및 삭제를 참조하세요.

관리 ID를 사용하는 경우 ID는 플랫폼에 의해 관리되며 제거할 필요가 없습니다.

다음 단계

이 빠른 시작에서는 Kubernetes 클러스터를 배포한 다음, Azure Event Hubs에서 AKS 이벤트를 구독했습니다.

AKS에 대해 자세히 알아보고 배포 예제에 대한 전체 코드를 연습해 보려면 Kubernetes 클러스터 자습서를 계속 진행합니다.