Azure Application Gateway + AGIC를 사용하여 Kube 서비스 노출

발행: (2026년 3월 1일 오후 04:01 GMT+9)
9 분 소요
원문: Dev.to

Source: Dev.to

Azure Application Gateway Ingress Controller (AGIC) 로 Kubernetes 서비스 노출하기

이 글에서는 Azure Kubernetes Service(AKS) 클러스터에 Azure Application Gateway Ingress Controller (AGIC) 를 설치하고, 이를 통해 Kubernetes 서비스(예: my-service) 를 외부에 노출하는 과정을 단계별로 설명합니다.

사전 요구 사항

  • Azure 구독
  • Azure CLI (az) 최신 버전
  • kubectl 설치 및 구성
  • AKS 클러스터가 이미 생성되어 있어야 함
  • Azure Application Gateway가 존재하거나 새로 만들 수 있어야 함

1. Azure Application Gateway 생성 (이미 존재한다면 건너뛰기)

az network public-ip create \
  --resource-group $RG \
  --name agic-pip \
  --sku Standard \
  --allocation-method Static

az network vnet create \
  --resource-group $RG \
  --name agic-vnet \
  --address-prefix 10.0.0.0/16 \
  --subnet-name agic-subnet \
  --subnet-prefix 10.0.1.0/24

az network application-gateway create \
  --resource-group $RG \
  --name myAppGateway \
  --sku Standard_v2 \
  --capacity 2 \
  --frontend-ip-name agic-feip \
  --frontend-port-name agic-feport \
  --http-settings-name agic-http-settings \
  --routing-rule-name agic-rule \
  --vnet-name agic-vnet \
  --subnet agic-subnet \
  --public-ip-address agic-pip

2. AKS 클러스터에 AGIC 설치

Helm 차트를 사용해 AGIC 를 배포합니다.

helm repo add application-gateway-kubernetes-ingress https://appgwingress.blob.core.windows.net/ingress-azure-helm-package/
helm repo update

helm install agic \
  application-gateway-kubernetes-ingress/ingress-azure \
  --namespace kube-system \
  --set appgw.name=myAppGateway \
  --set appgw.resourceGroup=$RG \
  --set appgw.subscriptionId=$(az account show --query id -o tsv) \
  --set armAuth.type=servicePrincipal \
  --set armAuth.secretJSON=$(az ad sp create-for-rbac --skip-assignment --name agic-sp --query "{clientId:appId, clientSecret:password, tenantId:tenant}" -o tsv) \
  --set rbac.enabled=true \
  --set verbosityLevel=3

Tip: armAuth.secretJSON 에는 Service Principal JSON 문자열을 넣어야 합니다. 위 명령은 이를 바로 생성해 전달합니다.

3. Ingress 리소스 정의

다음은 my-service 를 HTTP 80 포트로 노출하는 간단한 Ingress 매니페스트 예시입니다.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-service-ingress
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
spec:
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: my-service
            port:
              number: 80

위 파일을 my-ingress.yaml 로 저장한 뒤 적용합니다.

kubectl apply -f my-ingress.yaml

4. 배포 확인

  1. Ingress가 정상적으로 생성됐는지 확인

    kubectl get ingress my-service-ingress
  2. Application Gateway에 라우팅 규칙이 추가됐는지 확인

    Azure Portal → Application Gateway → 리스너/규칙 섹션에서 my-service-ingress 라는 이름이 보이면 성공입니다.

  3. 브라우저에서 서비스에 접근

    curl http://<ApplicationGatewayPublicIP>

    정상적인 응답이 반환되면 AKS 서비스가 외부에 노출된 것입니다.

5. 트러블슈팅 팁

문제원인해결 방법
Ingress가 Pending 상태AGIC가 Application Gateway와 통신하지 못함Service Principal 권한을 확인하고, Contributor 역할이 할당됐는지 검증
502 Bad Gateway백엔드 풀에 올바른 AKS 노드가 등록되지 않음AKS 클러스터와 Application Gateway가 같은 Virtual Network에 있는지 확인
라우팅이 작동하지 않음Ingress annotation이 누락됨kubernetes.io/ingress.class: azure/application-gateway 어노테이션을 반드시 추가

6. 정리

  • Azure Application Gateway와 AGIC를 사용하면 기존 L7 로드밸런서 없이도 Kubernetes 서비스에 대한 고가용성 엔드포인트를 손쉽게 제공할 수 있습니다.
  • Helm 차트를 이용한 설치가 가장 간편하며, 필요에 따라 Helm values 파일을 커스터마이징해 다양한 시나리오에 적용할 수 있습니다.
  • 보안 측면에서는 WAF 설정, SSL 종료 등을 Application Gateway 레벨에서 관리하는 것이 권장됩니다.

이제 AKS 클러스터에 배포된 애플리케이션을 Azure Application Gateway를 통해 외부에 안전하게 노출할 수 있습니다. Happy coding!

🔷 사전 요구 사항

Azure CLI와 kubectl이 설치되어 있는지 확인하세요:

az version
kubectl version --client

Azure에 로그인

az login

변수 설정

RG=rg-aks-agic-demo
LOCATION=eastus2
AKS_NAME=aks-agic-demo
APPGW_NAME=appgw-agic-demo
VNET_NAME=vnet-agic-demo
AKS_SUBNET=aks-subnet
APPGW_SUBNET=appgw-subnet

🟢 1단계 — 리소스 그룹 만들기

az group create \
  --name $RG \
  --location $LOCATION

🟢 단계 2 — 2개의 서브넷이 있는 VNet 만들기

⚠️ Application Gateway는 전용 서브넷에 있어야 합니다.

VNet 및 AKS 서브넷을 생성합니다:

az network vnet create \
  --resource-group $RG \
  --name $VNET_NAME \
  --address-prefix 10.0.0.0/8 \
  --subnet-name $AKS_SUBNET \
  --subnet-prefix 10.240.0.0/16

Application Gateway 서브넷을 생성합니다:

az network vnet subnet create \
  --resource-group $RG \
  --vnet-name $VNET_NAME \
  --name $APPGW_SUBNET \
  --address-prefix 10.241.0.0/16

🟢 3단계 — 애플리케이션 게이트웨이를 위한 공용 IP 생성

az network public-ip create \
  --resource-group $RG \
  --name appgw-pip \
  --sku Standard \
  --allocation-method Static

🟢 Step 4 — 애플리케이션 게이트웨이 만들기 (WAF v2)

az network application-gateway create \
  --name $APPGW_NAME \
  --resource-group $RG \
  --location $LOCATION \
  --sku Standard_v2 \
  --capacity 2 \
  --vnet-name $VNET_NAME \
  --subnet $APPGW_SUBNET \
  --public-ip-address appgw-pip \
  --priority 100

🟢 단계 5 — AKS용 서브넷 ID 가져오기

AKS_SUBNET_ID=$(az network vnet subnet show \
  --resource-group $RG \
  --vnet-name $VNET_NAME \
  --name $AKS_SUBNET \
  --query id -o tsv)

🟢 단계 6 — AGIC가 활성화된 AKS 만들기

먼저, Application Gateway 리소스 ID를 가져옵니다:

APPGW_ID=$(az network application-gateway show \
  --name $APPGW_NAME \
  --resource-group $RG \
  --query id -o tsv)

이제 AKS 클러스터를 생성하고 기존 Application Gateway를 연결합니다:

az aks create \
  --resource-group $RG \
  --name $AKS_NAME \
  --network-plugin azure \
  --vnet-subnet-id $AKS_SUBNET_ID \
  --enable-addons ingress-appgw \
  --appgw-id $APPGW_ID \
  --node-count 2 \
  --generate-ssh-keys

이렇게 하면 AKS 내부에 AGIC 애드온이 자동으로 배포됩니다.

🟢 Step 7 — AKS 자격 증명 가져오기

az aks get-credentials \
  --resource-group $RG \
  --name $AKS_NAME

AGIC 파드가 실행 중인지 확인합니다:

kubectl get pods -n kube-system

ingress-appgw-... 라는 이름의 파드가 표시될 것입니다.

🟢 Step 8 — 데모 애플리케이션 배포

kubectl create deployment nginx --image=nginx
kubectl expose deployment nginx --port 80

서비스 확인:

kubectl get svc

🟢 Step 9 — Ingress 리소스 생성

ingress.yaml 파일을 다음 내용으로 생성합니다:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx-ingress
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
spec:
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: nginx
            port:
              number: 80

매니페스트를 적용합니다:

kubectl apply -f ingress.yaml

🟢 단계 10 — 공용 IP 가져오기

az network public-ip show \
  --resource-group $RG \
  --name appgw-pip \
  --query ipAddress \
  --output tsv

AGIC가 구성을 동기화할 때까지 2~3분 정도 기다리세요.

브라우저에서 IP 주소를 엽니다:

http://<public-ip>

기본 NGINX 환영 페이지가 표시됩니다:

Welcome to nginx!

🔷 What Just Happened (Enterprise Flow)

Internet

Application Gateway

AGIC watches Ingress

Routes to AKS Service

Pod

트래픽은 AKS 노드에 직접 도달하지 않으며, 먼저 Application Gateway가 필터링합니다.

🔷 AGIC 동기화 확인

AGIC 로그를 확인하세요:

kubectl logs -n kube-system \
  deploy/ingress-appgw-deployment

구성 업데이트에 대한 메시지가 표시됩니다.

Note: 다음과 같은 오류가 발생하면
E0301 06:36:34.657523 1 client.go:191] Code="ErrorApplicationGatewayForbidden"
문제 해결 가이드를 확인하세요.

🧹 정리

az group delete --name $RG --yes --no-wait

🎯 이제 다음을 갖추었습니다

  • ✅ 클러스터 외부의 Layer 7 라우팅
  • ✅ AKS 프라이빗 노드
  • ✅ 엔터프라이즈 인그레스 패턴
0 조회
Back to Blog

관련 글

더 보기 »

일이 정신 건강 위험이 될 때

markdown !Ravi Mishrahttps://media2.dev.to/dynamic/image/width=50,height=50,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fu...