본문 바로가기
클라우드/Azure

[ApplicationGateway] 공유 Application Gateway Ingress Controller 사용하기

by worldcenter 2025. 1. 23.

Azure Kubernetes에서 Application Gateway Ingress Controller(이하 AGIC)를 사용하도록 설정하는 방법은 다양합니다.

1. Azure CLI, Terraform, Portal을 통한 배포

2. Helm을 통한 배포

 

1번의 방법으로 AGIC를 생성할 경우 AKS와 연동된 1개의 AGIC에서는 다른 VM 인스턴스나 다른 AKS를 추가로 연결해서 사용할 수 없습니다. 하지만 2번의 방법의 경우 AGIC를 다른 리소스와 공유하여 사용 가능합니다.

 

본문에서는 Helm을 사용하여 기존 Application Gateway를 AGIC로 연동하고 2개의 AKS 클러스터가 해당 Application Gateway를 공유해서 사용하는 방법을 테스트 합니다.

해당 테스트는 다음의 링크를 참고합니다.

 

 

사전 요구 사항

  • Kubenet을 사용하는 AKS 클러스터(Azure CNI도 가능)
  • AKS 클러스터와 동일한 가상 네트워크에 Application Gateway Standardv2 생성
  • AKS 클러스터에 구성된 Managed Identity(Workload ID)

 

 

Azure Application Gateway Ingress Controller 설치

1. Helm 리포지토리를 추가합니다.

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

 

2. AKS가 Application Gateway에 접근하여 정책 설정이 가능하도록 Azure Kubernetes Workload ID(Managed ID)에 권한을 부여합니다. Application Gateway가 위치한 리소스 그룹에 Reader, Network Contributor 권한을 부여합니다.

 

3. AGIC를 구성하는 helm-config.yaml을 다운로드 합니다.

wget https://raw.githubusercontent.com/Azure/application-gateway-kubernetes-ingress/master/docs/examples/sample-helm-config.yaml -O helm-config.yaml
# This file contains the essential configs for the ingress controller helm chart

# Verbosity level of the App Gateway Ingress Controller
verbosityLevel: 3

################################################################################
# Specify which application gateway the ingress controller must manage
#
appgw:
    subscriptionId: <subscriptionId>
    resourceGroup: <resourceGroupName>
    name: <applicationGatewayName>

    # Setting appgw.shared to "true" creates an AzureIngressProhibitedTarget CRD.
    # This prohibits AGIC from applying config for any host/path.
    # Use "kubectl get AzureIngressProhibitedTargets" to view and change this.
    shared: false

################################################################################
# Specify which kubernetes namespace the ingress controller must watch
# Default value is "default"
# Leaving this variable out or setting it to blank or empty string would
# result in Ingress Controller observing all accessible namespaces.
#
# kubernetes:
#   watchNamespace: <namespace>

################################################################################
# Specify the authentication with Azure Resource Manager
#
# Two authentication methods are available:
# - Option 1: Azure-AD-workload-identity 
armAuth:
    type: workloadIdentity
    identityClientID:  <identityClientId>

## Alternatively you can use Service Principal credentials
# armAuth:
#    type: servicePrincipal
#    secretJSON: <<Generate this value with: "az ad sp create-for-rbac --role Contributor --sdk-auth | base64 -w0" >>

################################################################################
# Specify if the cluster is Kubernetes RBAC enabled or not
rbac:
    enabled: false # true/false

 

4. 이전 단계의 helm-config.yaml 구성을 사용하여 Helm Chart application-gateway-kubernetes-ingress를 설치합니다.

helm install -f <helm-config.yaml> application-gateway-kubernetes-ingress/ingress-azure -n kube-system --generate-name

 

5. kube-system 네임스페이스에 Pod를 확인해보면 Ingress가 정상적으로 배포되지 않았음을 확인할 수 있습니다.

 

6. Pod 로그를 확인해보면 다음과 같이 에러가 발생함을 확인 할 수 있습니다. 해당 에러는 방금 설치한 ingress의 serviceaccount가 적합한 clusterrole을 가지고 있지 않기 때문입니다.

 

7. 아래 serviceaccount에게 Ingressclusterrole을 부여해주어야 합니다.