AKS 시리즈.네트워크 코어 애플리케이션: Application Gateway 및 Application Gateway Ingress Controller

저번 애플 게이트웨이를 통해 AKS의 앱을 외부에 공개했다.이번에는 애플과 AKS를 더욱 긴밀하게 연대하는 방법으로 애플 게이트웨이(AGIC)를 활용할 예정이다.
GitHub: Application Gateway Kubernetes Ingress

AGIC 개요


AGIC는 Kubernetes의 입구 자원으로 AKS에 개발되었다.AGIC는 항상 클러스터 상태를 모니터링하며 필요에 따라 Application Gateway 설정을 동적으로 업데이트합니다.
다음 그림은 AGIC가 Kubernetes API를 통해 상태를 모니터링한 결과 ARM 템플릿을 통해 Application Gateway를 변경한 경우를 나타냅니다.

AGIC는 다음과 같은 기능을 제공합니다.
  • URL 라우팅
  • 쿠키 기반 모방
  • SSL 끝
  • 터미널 간 SSL 통신
  • 공공, 내부 및 혼합 웹 사이트 지원
  • 애플리케이션 방화벽과 통합
  • 또한 이러한 기능은 실제로 Application Gateway에서 제공합니다.AGIC는 AKS 측의 자원 제작과 변경에 대해 Application Gateway가 자동으로 사용할 수 있도록 구성했다.

    사전 준비


    제목 노드 없음 추가


    현재 모든 노드는 type = sql 또는 type = app를 테마로 하고 있기 때문에 다음에 추가할 Pod를 설정하는 데 사용할 노드를 노드 탱크 1에 추가합니다.
    1. nodepool scale 명령 실행
    az aks nodepool scale -n nodepool1 --node-count 3 -g netcoresample --cluster-name myaks
    
    2. 노드를 확인합니다.
    >kubectl get nodes
    NAME                                STATUS   ROLES   AGE     VERSION
    aks-nodepool1-23705949-vmss000000   Ready    agent   23h     v1.13.11
    aks-nodepool1-23705949-vmss000001   Ready    agent   23h     v1.13.11
    aks-nodepool1-23705949-vmss000002   Ready    agent   5m42s   v1.13.11
    aks-nodepool2-23705949-vmss000000   Ready    agent   23h     v1.13.11
    
    이렇게 하면 주제가 없는 노드를 만들 수 있다.

    Helm의 설치 및 웨어하우스 추가


    AGIC가 헬름을 이용해 설치하는 절차를 안내했기 때문에 여기에 헬름을 설치한다.헬름에 대해서는 다른 시리즈에서 소개할 예정이다.
    1. GitHub: Helm에서 사용한 OS의 최신 버전인 helm을 가져옵니다.해동은 경로를 통해 어디든지 통과한다.여기 설치v2.15.2.
    2. AKS로 Tiller용 서비스 계정을 만듭니다.
    kubectl create serviceaccount --namespace kube-system tiller-sa
    
    3. 그룹 관리자의 권한을 창설된 계정에 부여한다.
    kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller-sa
    
    4. Helm을 초기화합니다.
    helm init --tiller-namespace kube-system --service-account tiller-sa
    
    5. AGIC용 창고를 늘린다.
    helm repo add application-gateway-kubernetes-ingress https://appgwingress.blob.core.windows.net/ingress-azure-helm-package/
    helm repo update
    
    6. Tiller가 구성되었는지 확인합니다.
    >kubectl -n kube-system get pods
    ...
    tiller-deploy-7fb69fc45-mlft8           1/1     Running   0          26m
    ...
    >helm version
    Client: &version.Version{SemVer:"v2.15.2", GitCommit:"8dce272473e5f2a7bf58ce79bb5c3691db54c96b", GitTreeState:"clean"}
    Server: &version.Version{SemVer:"v2.15.2", GitCommit:"8dce272473e5f2a7bf58ce79bb5c3691db54c96b", GitTreeState:"clean"}
    

    AAD Pod Identity 설정


    AAD Pod Identity는 AKS 동작을 사용하는 컨트롤러로, Azure Active Directory Identities를 Pod에 바인딩할 수 있습니다.이 시나리오는 AGIC PORD가 ARM 템플릿을 조작할 수 있는 권한이 필요하기 때문에 이쪽 기능을 사용합니다.
    1. AAA Pod Identity에 대한 디버깅을 수행합니다.
    kubectl apply -f https://raw.githubusercontent.com/Azure/aad-pod-identity/master/deploy/infra/deployment-rbac.yaml
    
    2. AAD Identity의 제작.대상 자원 그룹을 만들고 그룹 노드가 있는 자원 그룹을 지정합니다.표시된 결과에 PrincipalId를 기록합니다.
    az identity create -g MC_netcoresample_myaks_japaneast -n agic_identity
    
    3. Application Gateway의 자원 ID를 얻습니다.
    az network application-gateway list --query "[].id"
    
    4. Application Gateway의 Contributor 역할을 제작된 Identity에게 부여한다.
    az role assignment create \
        --role Contributor \
        --assignee <principalId> \
        --scope <App-Gateway-ID>
    
    5. Application Gateway로 구성된 리소스 그룹의 ID를 가져옵니다.
    az group list --query "[].id"
    
    6. Identity에 리소스 그룹의 Reader를 부여합니다.
    az role assignment create \
        --role Reader \
        --assignee <principalId> \
        --scope <App-Gateway-Resource-Group-ID>
    

    AGIC 설치


    미리 준비되어 있기 때문에 AGIC를 설치합니다.
    1. https://raw.githubusercontent.com/Azure/application-gateway-kubernetes-ingress/master/docs/examples/sample-helm-config.yaml에서 Helm 구성 파일을 다운로드합니다.yaml로 저장합니다.
    2. 파일을 열고 appgw,armauth,rbac를 적당한 값으로 변경합니다.armAuth의 값은 Identity를 만들 때 출력된 값입니다.제거된 경우az identity show -g MC_netcoresample_myaks_japaneast -n agic_identity는 얻을 수 있다.
    appgw:
        subscriptionId: 93b67b2c-9ac0-4bd8-a565-4603f7073a97
        resourceGroup: netcoresample
        name: netcoresampleag
    ...
    armAuth:
        type: aadPodIdentity
        identityResourceID: <Identity id>
        identityClientID:  <Identity clientId>
    ...
    rbac:
        enabled: true
    
    3. 설치 실행
    helm install -f helm-config.yaml application-gateway-kubernetes-ingress/ingress-azure
    
    4. 백덕을 확인한다.
    >kubectl get pods
    NAME                                          READY   STATUS    RESTARTS   AGE
    core3webapp-67b678b946-cthmp                  1/1     Running   6          23h
    core3webapp-67b678b946-rd6nc                  1/1     Running   6          23h
    invited-kiwi-ingress-azure-66d6855bf7-f6lgh   1/1     Running   1          70s
    mic-65cbc47665-2wgfb                          1/1     Running   0          64m
    mic-65cbc47665-xqfgq                          1/1     Running   0          64m
    mssql-deployment-6597f9f5b6-z8g9j             1/1     Running   1          23h
    nmi-nkkkn                                     1/1     Running   1          35m
    
    5. Application Gateway가 자동으로 업데이트되었는지 확인하고 백엔드 풀 설정을 삭제합니다.

    어플리케이션 공개


    마지막으로 앱을 공개합니다.응용 프로그램의 공개는 입구 자원을 만드는 것을 통해 이루어진다.
    1. myapp.yaml의 마지막에 다음 코드를 추가합니다.
  • 쿠키 에뮬레이션 사용
  • 포트 80 후면 풀에 추가
  • myapp.yaml
    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      name: core3webapp
      annotations:
        kubernetes.io/ingress.class: azure/application-gateway
      appgw.ingress.kubernetes.io/cookie-based-affinity: "true"
    spec:
      rules:
      - http:
          paths:
          - backend:
              serviceName: core3webapp
              servicePort: 80
    
    2. 프로그램을 실행합니다.
    kubectl apply -f myapp.yaml
    
    3. Application Gateway의 백엔드 수영장을 확인한다.

    4. 새로 만든 백엔드 풀의 세부 사항을 확인합니다.

    5. Pord의 IP 주소와 일치하는지 확인합니다.
    >kubectl get pods -o wide
    NAME                                          READY   STATUS    RESTARTS   AGE   IP           NODE                                NOMINATED NODE   READINESS GATES
    core3webapp-67b678b946-cthmp                  1/1     Running   6          23h   10.0.0.16    aks-nodepool1-23705949-vmss000000   <none>           <none>
    core3webapp-67b678b946-rd6nc                  1/1     Running   6          23h   10.0.0.55    aks-nodepool1-23705949-vmss000001   <none>           <none>
    invited-kiwi-ingress-azure-66d6855bf7-f6lgh   1/1     Running   1          11m   10.0.0.106   aks-nodepool1-23705949-vmss000002   <none>           <none>
    mic-65cbc47665-2wgfb                          1/1     Running   0          74m   10.0.0.127   aks-nodepool1-23705949-vmss000002   <none>           <none>
    mic-65cbc47665-xqfgq                          1/1     Running   0          75m   10.0.0.108   aks-nodepool1-23705949-vmss000002   <none>           <none>
    mssql-deployment-6597f9f5b6-z8g9j             1/1     Running   1          23h   10.0.0.75    aks-nodepool2-23705949-vmss000000   <none>           <none>
    nmi-nkkkn                                     1/1     Running   1          46m   10.0.0.98    aks-nodepool1-23705949-vmss000002   <none>           <none>
    
    6. HTTP 설정에서 쿠키 베이스의 모방 설정을 확인합니다.

    7. 브라우저로부터의 연결을 확인합니다.로그인 확인이 가능한지 확인합니다.

    총결산


    이번에는 AGIC의 Application Gateway를 사용한 구성을 시도했다.AGIC를 사용하면 AKS 측 설정이 자동으로 애플리케이션 게이트웨이에 반영되기 때문에 관리할 수 있는 장점이 있고, 한편으로는 AKS 측에서 추가적인 팟을 설계할 예정이어서 사전 계획이 필요하다.
    지금은 테이블에서 팟 구성을 제어하고 싶지만, 아직 문제점과 앱과 무관한 팟이 추가된 만큼 다음에는 이 일대를 정리할 예정이다.
    다음 글로 이동
    디렉토리로 돌아가기

    인용하다


    GitHub: Application Gateway Kubernetes Ingress
    GitHub: AAD Pod Identity
    Azure Kubernetes Service(AKS)에서 Helm을 사용하는 응용 프로그램 설치
    GitHub: Helm

    좋은 웹페이지 즐겨찾기