AKS(Azure Kubernetes Service)용 HTTP 애플리케이션 라우팅 추가 기능(사용 중지됨)

주의

AKS(Azure Kubernetes Service)에 대한 HTTP 애플리케이션 라우팅 추가 기능(미리 보기)은 2025년 3월 3일에 사용 중지됩니다. 해당 날짜까지 애플리케이션 라우팅 추가 기능으로 마이그레이션하는 것이 좋습니다.

HTTP 애플리케이션 라우팅 추가 기능을 사용하면 다음을 통해 AKS(Azure Kubernetes Service) 클러스터에 배포된 애플리케이션에 쉽게 액세스할 수 있습니다.

  • AKS 클러스터에서 수신 컨트롤러를 구성합니다.
  • 애플리케이션 엔드포인트에 대해 공개적으로 액세스할 수 있는 DNS 이름 만들기
  • 구독에서 DNS 영역을 만듭니다. DNS 비용에 대한 자세한 내용은 DNS 가격 책정을 참조하세요.

시작하기 전에

  • HTTP 애플리케이션 라우팅 추가 기능은 AKS 버전 1.22.6 이상에서 작동하지 않습니다.
  • 명령을 로컬로 실행하는 경우 az aks install-cli 명령을 사용하여 kubectl을 설치합니다.

HTTP 애플리케이션 라우팅 추가 기능 개요

추가 기능은 Kubernetes 수신 컨트롤러외부 DNS 컨트롤러라는 두 구성 요소를 배포합니다.

  • 수신 컨트롤러: 수신 컨트롤러는 Kubernetes LoadBalancer 서비스를 사용하여 인터넷에 노출됩니다. 수신 컨트롤러는 Kubernetes 수신 리소스를 감시 및 구현하고 애플리케이션 엔드포인트에 대한 경로를 만듭니다.
  • 외부 DNS 컨트롤러: 외부 DNS 컨트롤러는 Kubernetes 수신 리소스를 감시하고 클러스터별 DNS 영역에 DNS A 레코드를 만듭니다.

HTTP 애플리케이션 라우팅 사용

  1. 새 AKS 클러스터를 만들고 --enable-addons 매개 변수와 함께 az aks create 명령을 사용하여 HTTP 애플리케이션 라우팅 추가 기능을 사용하도록 설정합니다.

    az aks create --resource-group myResourceGroup --name myAKSCluster --enable-addons http_application_routing
    

    --addons 매개 변수와 함께 az aks enable-addons 명령을 사용하여 기존 AKS 클러스터에서 HTTP 라우팅을 활성화할 수도 있습니다.

    az aks enable-addons --resource-group myResourceGroup --name myAKSCluster --addons http_application_routing
    
  2. az aks show 명령을 사용하여 DNS 영역 이름을 검색합니다. 클러스터에 애플리케이션을 배포하려면 DNS 영역 이름이 필요합니다.

    az aks show --resource-group myResourceGroup --name myAKSCluster --query addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName -o table
    

    출력은 다음 예제 출력과 같아야 합니다.

    9f9c1fe7-21a1-416d-99cd-3543bb92e4c3.eastus.aksapp.io
    

AKS 클러스터에 연결

  • az aks get-credentials 명령을 사용하여 Kubernetes 클러스터에 연결하도록 kubectl을 구성합니다. 다음 예제에서는 myResourceGroup에서 AKS 클러스터 이름 myAKSCluster에 대한 자격 증명을 가져옵니다.

    az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
    

HTTP 애플리케이션 라우팅 사용

Important

HTTP 애플리케이션 라우팅 추가 기능은 다음 주석을 있는 수신 리소스에서만 트리거할 수 있습니다.

annotations:
 kubernetes.io/ingress.class: addon-http-application-routing
  1. samples-http-application-routing.yaml이라는 파일을 만들고 다음 YAML을 복사합니다. 줄 43에서, 이전 단계에서 수집한 DNS 영역 이름으로 <CLUSTER_SPECIFIC_DNS_ZONE>을 업데이트합니다.

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: aks-helloworld
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: aks-helloworld
      template:
        metadata:
          labels:
            app: aks-helloworld
        spec:
          containers:
          - name: aks-helloworld
            image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
            ports:
            - containerPort: 80
            env:
            - name: TITLE
              value: "Welcome to Azure Kubernetes Service (AKS)"
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: aks-helloworld
    spec:
      type: ClusterIP
      ports:
     - port: 80
      selector:
        app: aks-helloworld
    ---
    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: aks-helloworld
      annotations:
        kubernetes.io/ingress.class: addon-http-application-routing
    spec:
      rules:
     - host: aks-helloworld.<CLUSTER_SPECIFIC_DNS_ZONE>
        http:
          paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: aks-helloworld
                port:
                  number: 80
    
  2. kubectl apply 명령을 사용하여 리소스를 만듭니다.

    kubectl apply -f samples-http-application-routing.yaml
    

    다음 예제에서는 생성된 리소스를 보여줍니다.

    deployment.apps/aks-helloworld created
    service/aks-helloworld created
    ingress.networking.k8s.io/aks-helloworld created
    
  3. aks-helloworld.<CLUSTER_SPECIFIC_DNS_ZONE>(예: aks-helloworld.9f9c1fe7-21a1-416d-99cd-3543bb92e4c3.eastus.aksapp.io)로 웹 브라우저를 열고 데모 애플리케이션이 표시되는지 확인합니다. 애플리케이션을 표시하는 데 몇 분 정도 걸릴 수 있습니다.

HTTP 애플리케이션 라우팅 제거

  1. [az aks disable-addons][az-aks-disable-addons] command with the addons' 매개 변수를 사용하여 HTTP 애플리케이션 라우팅 추가 기능을 제거합니다.

    az aks disable-addons --addons http_application_routing --name myAKSCluster --resource-group myResourceGroup --no-wait
    
  2. HTTP 애플리케이션 라우팅 추가 기능을 비활성화하면 일부 Kubernetes 리소스는 클러스터에서 남아 있을 수 있습니다. 이러한 리소스는 configmapssecrets를 포함하며 kube 시스템 네임스페이스에서 만들어집니다. 정리 클러스터를 유지하려면 이러한 리소스를 제거하는 것이 좋습니다. 다음 kubectl get 명령을 사용하여 addon-http-application-routing 리소스를 찾습니다.

    kubectl get deployments --namespace kube-system
    kubectl get services --namespace kube-system
    kubectl get configmaps --namespace kube-system
    kubectl get secrets --namespace kube-system
    

    다음 예제 출력은 삭제되어야 하는 configmaps를 보여줍니다.

    NAMESPACE     NAME                                                       DATA   AGE
    kube-system   addon-http-application-routing-nginx-configuration         0      9m7s
    kube-system   addon-http-application-routing-tcp-services                0      9m7s
    kube-system   addon-http-application-routing-udp-services                0      9m7s
    
  3. kubectl delete 명령을 사용하여 나머지 리소스를 삭제합니다. 리소스 종류, 리소스 이름 및 네임스페이스를 지정해야 합니다. 다음 예제에서는 이전 configmaps 중 하나를 삭제합니다.

    kubectl delete configmaps addon-http-application-routing-nginx-configuration --namespace kube-system
    
  4. 클러스터에 남아 있던 모든 addon-http-application-routing 리소스에 대해 이전 kubectl delete 단계를 반복합니다.

문제 해결

  1. kubectl logs 명령을 사용하여 외부 DNS 애플리케이션에 대한 애플리케이션 로그를 봅니다.

    kubectl logs -f deploy/addon-http-application-routing-external-dns -n kube-system
    

    로그는 다음 예제 출력과 같이 ATXT DNS 레코드가 성공적으로 생성되었는지 확인해야 합니다.

    time="2018-04-26T20:36:19Z" level=info msg="Updating A record named 'aks-helloworld' to '52.242.28.189' for Azure DNS zone '471756a6-e744-4aa0-aa01-89c4d162a7a7.canadaeast.aksapp.io'."
    time="2018-04-26T20:36:21Z" level=info msg="Updating TXT record named 'aks-helloworld' to '"heritage=external-dns,external-dns/owner=default"' for Azure DNS zone '471756a6-e744-4aa0-aa01-89c4d162a7a7.canadaeast.aksapp.io'."
    
  2. kubectl logs 명령을 사용하여 NGINX 수신 컨트롤러에 대한 애플리케이션 로그를 봅니다.

    kubectl logs -f deploy/addon-http-application-routing-nginx-ingress-controller -n kube-system
    

    로그는 다음 예제 출력과 같이 수신 리소스의 CREATE를 확인하고 컨트롤러를 다시 로드해야 합니다.

    -------------------------------------------------------------------------------
    NGINX Ingress controller
      Release:    0.13.0
      Build:      git-4bc943a
      Repository: https://github.com/kubernetes/ingress-nginx
    -------------------------------------------------------------------------------
    
    I0426 20:30:12.212936       9 flags.go:162] Watching for ingress class: addon-http-application-routing
    W0426 20:30:12.213041       9 flags.go:165] only Ingress with class "addon-http-application-routing" will be processed by this ingress controller
    W0426 20:30:12.213505       9 client_config.go:533] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
    I0426 20:30:12.213752       9 main.go:181] Creating API client for https://10.0.0.1:443
    I0426 20:30:12.287928       9 main.go:225] Running in Kubernetes Cluster version v1.8 (v1.8.11) - git (clean) commit 1df6a8381669a6c753f79cb31ca2e3d57ee7c8a3 - platform linux/amd64
    I0426 20:30:12.290988       9 main.go:84] validated kube-system/addon-http-application-routing-default-http-backend as the default backend
    I0426 20:30:12.294314       9 main.go:105] service kube-system/addon-http-application-routing-nginx-ingress validated as source of Ingress status
    I0426 20:30:12.426443       9 stat_collector.go:77] starting new nginx stats collector for Ingress controller running in namespace  (class addon-http-application-routing)
    I0426 20:30:12.426509       9 stat_collector.go:78] collector extracting information from port 18080
    I0426 20:30:12.448779       9 nginx.go:281] starting Ingress controller
    I0426 20:30:12.463585       9 event.go:218] Event(v1.ObjectReference{Kind:"ConfigMap", Namespace:"kube-system", Name:"addon-http-application-routing-nginx-configuration", UID:"2588536c-4990-11e8-a5e1-0a58ac1f0ef2", APIVersion:"v1", ResourceVersion:"559", FieldPath:""}): type: 'Normal' reason: 'CREATE' ConfigMap kube-system/addon-http-application-routing-nginx-configuration
    I0426 20:30:12.466945       9 event.go:218] Event(v1.ObjectReference{Kind:"ConfigMap", Namespace:"kube-system", Name:"addon-http-application-routing-tcp-services", UID:"258ca065-4990-11e8-a5e1-0a58ac1f0ef2", APIVersion:"v1", ResourceVersion:"561", FieldPath:""}): type: 'Normal' reason: 'CREATE' ConfigMap kube-system/addon-http-application-routing-tcp-services
    I0426 20:30:12.467053       9 event.go:218] Event(v1.ObjectReference{Kind:"ConfigMap", Namespace:"kube-system", Name:"addon-http-application-routing-udp-services", UID:"259023bc-4990-11e8-a5e1-0a58ac1f0ef2", APIVersion:"v1", ResourceVersion:"562", FieldPath:""}): type: 'Normal' reason: 'CREATE' ConfigMap kube-system/addon-http-application-routing-udp-services
    I0426 20:30:13.649195       9 nginx.go:302] starting NGINX process...
    I0426 20:30:13.649347       9 leaderelection.go:175] attempting to acquire leader lease  kube-system/ingress-controller-leader-addon-http-application-routing...
    I0426 20:30:13.649776       9 controller.go:170] backend reload required
    I0426 20:30:13.649800       9 stat_collector.go:34] changing prometheus collector from  to default
    I0426 20:30:13.662191       9 leaderelection.go:184] successfully acquired lease kube-system/ingress-controller-leader-addon-http-application-routing
    I0426 20:30:13.662292       9 status.go:196] new leader elected: addon-http-application-routing-nginx-ingress-controller-5cxntd6
    I0426 20:30:13.763362       9 controller.go:179] ingress backend successfully reloaded...
    I0426 21:51:55.249327       9 event.go:218] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"aks-helloworld", UID:"092c9599-499c-11e8-a5e1-0a58ac1f0ef2", APIVersion:"extensions", ResourceVersion:"7346", FieldPath:""}): type: 'Normal' reason: 'CREATE' Ingress default/aks-helloworld
    W0426 21:51:57.908771       9 controller.go:775] service default/aks-helloworld does not have any active endpoints
    I0426 21:51:57.908951       9 controller.go:170] backend reload required
    I0426 21:51:58.042932       9 controller.go:179] ingress backend successfully reloaded...
    167.220.24.46 - [167.220.24.46] - - [26/Apr/2018:21:53:20 +0000] "GET / HTTP/1.1" 200 234 "" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" 197 0.001 [default-aks-helloworld-80] 10.244.0.13:8080 234 0.004 200
    

리소스 정리

  • kubectl delete 명령을 사용하여 이 문서에서 만든 연결된 Kubernetes 개체를 제거합니다.

    kubectl delete -f samples-http-application-routing.yaml
    

    다음 예제 출력은 Kubernetes 개체가 제거되었음을 보여줍니다.

    deployment "aks-helloworld" deleted
    service "aks-helloworld" deleted
    ingress "aks-helloworld" deleted
    

다음 단계

AKS에 HTTPS 보안 수신 컨트롤러를 설치하는 방법에 대한 자세한 내용은 AKS(Azure Kubernetes Service)의 HTTPS 수신을 참조하세요.