{"meta":{"title":"Azure Kubernetes Service에 배포하기","intro":"CD(연속 배포) 워크플로의 일부로 프로젝트를 Azure Kubernetes Service (AKS)에 배포하는 방법을 알아보세요.","product":"GitHub Actions","breadcrumbs":[{"href":"/ko/actions","title":"GitHub Actions"},{"href":"/ko/actions/how-tos","title":"사용법"},{"href":"/ko/actions/how-tos/deploy","title":"배포"},{"href":"/ko/actions/how-tos/deploy/deploy-to-third-party-platforms","title":"타사 플랫폼에 배포"},{"href":"/ko/actions/how-tos/deploy/deploy-to-third-party-platforms/azure-kubernetes-service","title":"Azure Kubernetes Service"}],"documentType":"article"},"body":"# Azure Kubernetes Service에 배포하기\n\nCD(연속 배포) 워크플로의 일부로 프로젝트를 Azure Kubernetes Service (AKS)에 배포하는 방법을 알아보세요.\n\n## 필수 조건\n\nGitHub Actions 워크플로를 만들기 전에 먼저 다음 설정 단계를 완료해야 합니다.\n\n1. 대상 AKS 클러스터 및 ACR(Azure Container Registry)을 만듭니다. 자세한 내용은 [Quickstart: Azure 포털을 사용하여 AKS 클러스터 배포 - Azure Kubernetes Service](https://docs.microsoft.com/azure/aks/kubernetes-walkthrough-portal) 및 [Quickstart - 포털에서 레지스트리 만들기 - Azure Container Registry](https://docs.microsoft.com/azure/container-registry/container-registry-get-started-portal) Azure 설명서를 참조하세요.\n\n1. `AZURE_CREDENTIALS`라는 비밀을 만들어 Azure 자격 증명을 저장합니다. 이 정보를 찾고 비밀을 구성하는 방법에 대한 자세한 내용은 [`Azure/login` 작업 설명서](https://github.com/Azure/login#configure-a-service-principal-with-a-secret) 참조하세요.\n\n## 워크플로 만들기\n\n필수 구성 요소를 완료한 후에는 워크플로 만들기를 진행할 수 있습니다.\n\n다음 예제 워크플로에서는 코드를 리포지토리에 푸시할 때 Azure Kubernetes Service 프로젝트를 빌드하고 배포하는 방법을 보여 줍니다.\n\n워크플로 `env` 키에서 다음 값을 바꿉니다.\n* `AZURE_CONTAINER_REGISTRY`를 컨테이너 레지스트리의 이름으로 바꿉니다.\n* `PROJECT_NAME`을 프로젝트의 이름으로 바꿉니다.\n* `RESOURCE_GROUP`을 AKS 클러스터가 포함된 리소스 그룹으로 바꿉니다.\n* `CLUSTER_NAME`을 AKS 클러스터 이름으로 바꿉니다.\n\n이 워크플로는 `helm``azure/k8s-bake` 렌더링 엔진을 사용합니다. \n`helm` 렌더링 엔진을 사용하는 경우 `CHART_PATH` 값을 helm 파일의 경로로 변경합니다. \n`CHART_OVERRIDE_PATH`을 재정의 파일 경로 배열로 변경합니다. 다른 렌더링 엔진을 사용하는 경우 `azure/k8s-bake` 작업에 전송된 입력 매개 변수를 업데이트합니다.\n\n```yaml copy\n# 이 워크플로는 GitHub에서 인증되지 않은 작업을 사용합니다.\n# 작업은 타사에서 제공하며\n# 별도의 서비스 약관, 개인정보처리방침, 지원 설명서에서 규정됩니다.\n# 참조하세요.\n\n# 커밋 SHA에 작업을 고정하는 것이 좋습니다.\n# 최신 버전을 얻으려면 SHA를 업데이트해야 합니다.\n# 태그 또는 분기를 참조할 수도 있지만 경고 없이 작업이 변경될 수 있습니다.\n\nname: Build and deploy to Azure Kubernetes Service\n\nenv:\n  AZURE_CONTAINER_REGISTRY: MY_REGISTRY_NAME # set this to the name of your container registry\n  PROJECT_NAME: MY_PROJECT_NAME              # set this to your project's name\n  RESOURCE_GROUP: MY_RESOURCE_GROUP          # set this to the resource group containing your AKS cluster\n  CLUSTER_NAME: MY_CLUSTER_NAME              # set this to the name of your AKS cluster\n  REGISTRY_URL: MY_REGISTRY_URL              # set this to the URL of your registry\n  # If you bake using helm:\n  CHART_PATH: MY_HELM_FILE                   # set this to the path to your helm file\n  CHART_OVERRIDE_PATH: MY_OVERRIDE_FILES     # set this to an array of override file paths\n\non: [push]\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v6\n\n    - name: Azure Login\n      uses: azure/login@14a755a4e2fd6dff25794233def4f2cf3f866955\n      with:\n        creds: ${{ secrets.AZURE_CREDENTIALS }}\n\n    - name: Build image on ACR\n      uses: azure/CLI@61bb69d64d613b52663984bf12d6bac8fd7b3cc8\n      with:\n        azcliversion: 2.29.1\n        inlineScript: |\n          az configure --defaults acr=${{ env.AZURE_CONTAINER_REGISTRY }}\n          az acr build -t -t ${{ env.REGISTRY_URL }}/${{ env.PROJECT_NAME }}:${{ github.sha }}\n\n    - name: Gets K8s context\n      uses: azure/aks-set-context@94ccc775c1997a3fcfbfbce3c459fec87e0ab188\n      with:\n          creds: ${{ secrets.AZURE_CREDENTIALS }}\n          resource-group: ${{ env.RESOURCE_GROUP }}\n          cluster-name: ${{ env.CLUSTER_NAME }}\n      id: login\n\n    - name: Configure deployment\n      uses: azure/k8s-bake@61041e8c2f75c1f01186c8f05fb8b24e1fc507d8\n      with:\n        renderEngine: 'helm'\n        helmChart: ${{ env.CHART_PATH }}\n        overrideFiles: ${{ env.CHART_OVERRIDE_PATH }}\n        overrides: |\n          replicas:2\n        helm-version: 'latest'\n      id: bake\n\n    - name: Deploys application\n      uses: Azure/k8s-deploy@dd4bbd13a5abd2fc9ca8bdcb8aee152bb718fa78\n      with:\n        manifests: ${{ steps.bake.outputs.manifestsBundle }}\n        images: |\n          ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.PROJECT_NAME }}:${{ github.sha }}\n        imagepullsecrets: |\n          ${{ env.PROJECT_NAME }}\n```\n\n## 추가 참고 자료\n\n* 원래의 워크플로 템플릿은 [`azure-kubernetes-service.yml`](https://github.com/actions/starter-workflows/blob/main/deployments/azure-kubernetes-service.yml)을 GitHub Actions `starter-workflows` 리포지토리에서 참조하세요.\n* 이 워크플로에서 사용되는 작업은 공식 Azure [`Azure/login`](https://github.com/Azure/login),[`Azure/aks-set-context`](https://github.com/Azure/aks-set-context)입니다. [`Azure/CLI`](https://github.com/Azure/CLI), [`Azure/k8s-bake`](https://github.com/Azure/k8s-bake) 및 [`Azure/k8s-deploy`](https://github.com/Azure/k8s-deploy)actions.\n* Azure 배포하는 GitHub 작업 워크플로에 대한 자세한 예제는 [actions-workflow-samples](https://github.com/Azure/actions-workflow-samples) 리포지토리를 참조하세요."}