가용성 영역에 ACI(Azure Container Instances) 컨테이너 그룹 배포

가용성 영역은 Azure 지역에서 물리적으로 별도 영역입니다. 가용성 영역을 사용하여 전체 데이터 센터의 예기치 않은 실패 또는 손실로부터 컨테이너화된 애플리케이션을 보호할 수 있습니다. 영역, 영역 중복항상 사용 가능한 서비스 등 세 가지 유형의 Azure 서비스가 가용성 영역을 지원합니다. 가용성 영역을 지원하는 Azure 서비스의 고가용성 서비스 섹션에서 이러한 유형의 서비스와 이러한 서비스가 복원력을 높이는 방법에 대해 자세히 알아볼 수 있습니다.

ACI(Azure Container Instances)는 영역 컨테이너 그룹 배포를 지원합니다. 즉, 인스턴스가 자체 선택된 특정 가용성 영역에 고정됩니다. 가용성 영역은 컨테이너 그룹 수준에서 지정됩니다. 컨테이너 그룹 내의 컨테이너에는 고유한 가용성 영역이 있을 수 없습니다. 컨테이너 그룹의 가용성 영역을 변경하려면 컨테이너 그룹을 삭제하고 새 가용성 영역을 사용하여 다른 컨테이너 그룹을 만들어야 합니다.

참고 항목

이 문서의 예제는 Bash 셸용으로 서식이 지정되어 있습니다. 다른 셸을 사용하려는 경우 해당 셸에 따라 줄 연속 문자를 조정합니다.

제한 사항

Important

  • GPU 리소스가 있는 컨테이너 그룹은 현재 가용성 영역을 지원하지 않습니다.

버전 요구 사항

  • Azure CLI를 사용하는 경우 버전 2.30.0 이상이 설치되어 있는지 확인합니다.
  • PowerShell을 사용하는 경우 버전 2.1.1-preview 이상이 설치되어 있는지 확인합니다.
  • Java SDK를 사용하는 경우 버전 2.9.0 이상이 설치되어 있는지 확인합니다.
  • 가용성 영역 지원은 ACI API 버전 09-01-2021 이상에서만 사용할 수 있습니다.

ARM(Azure Resource Manager) 템플릿을 사용하여 컨테이너 그룹 배포

ARM 템플릿 만들기

먼저 다음 JSON을 azuredeploy.json이라는 새 파일에 복사합니다. 이 예제 템플릿은 단일 컨테이너가 있는 컨테이너 그룹을 미국 동부의 가용성 영역 1에 배포합니다.

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "metadata": {
        "_generator": {
            "name": "bicep",
            "version": "0.4.1.14562",
            "templateHash": "12367894147709986470"
        }
    },
    "parameters": {
        "name": {
            "type": "string",
            "defaultValue": "acilinuxpublicipcontainergroup",
            "metadata": {
                "description": "Name for the container group"
            }
        },
        "image": {
            "type": "string",
            "defaultValue": "mcr.microsoft.com/azuredocs/aci-helloworld",
            "metadata": {
                "description": "Container image to deploy. Should be of the form repoName/imagename:tag for images stored in public Docker Hub, or a fully qualified URI for other registries. Images from private registries require additional registry credentials."
            }
        },
        "port": {
            "type": "int",
            "defaultValue": 80,
            "metadata": {
                "description": "Port to open on the container and the public IP address."
            }
        },
        "cpuCores": {
            "type": "int",
            "defaultValue": 1,
            "metadata": {
                "description": "The number of CPU cores to allocate to the container."
            }
        },
        "memoryInGb": {
            "type": "int",
            "defaultValue": 2,
            "metadata": {
                "description": "The amount of memory to allocate to the container in gigabytes."
            }
        },
        "restartPolicy": {
            "type": "string",
            "defaultValue": "Always",
            "allowedValues": [
                "Always",
                "Never",
                "OnFailure"
            ],
            "metadata": {
                "description": "The behavior of Azure runtime if container has stopped."
            }
        },
        "location": {
            "type": "string",
            "defaultValue": "eastus",
            "metadata": {
                "description": "Location for all resources."
            }
        }
    },
    "functions": [],
    "resources": [
        {
            "type": "Microsoft.ContainerInstance/containerGroups",
            "apiVersion": "2021-09-01",
            "zones": [
                "1"
            ],
            "name": "[parameters('name')]",
            "location": "[parameters('location')]",
            "properties": {
                "containers": [
                    {
                        "name": "[parameters('name')]",
                        "properties": {
                            "image": "[parameters('image')]",
                            "ports": [
                                {
                                    "port": "[parameters('port')]",
                                    "protocol": "TCP"
                                }
                            ],
                            "resources": {
                                "requests": {
                                    "cpu": "[parameters('cpuCores')]",
                                    "memoryInGB": "[parameters('memoryInGb')]"
                                }
                            }
                        }
                    }
                ],
                "osType": "Linux",
                "restartPolicy": "[parameters('restartPolicy')]",
                "ipAddress": {
                    "type": "Public",
                    "ports": [
                        {
                            "port": "[parameters('port')]",
                            "protocol": "TCP"
                        }
                    ]
                }
            }
        }
    ],
    "outputs": {
        "containerIPv4Address": {
            "type": "string",
            "value": "[reference(resourceId('Microsoft.ContainerInstance/containerGroups', parameters('name'))).ipAddress.ip]"
        }
    }
}

ARM 템플릿 배포

az group create 명령을 사용하여 리소스 그룹을 만듭니다.

az group create --name myResourceGroup --location eastus

az deployment group create 명령을 사용하여 템플릿을 배포합니다.

az deployment group create \
  --resource-group myResourceGroup \
  --template-file azuredeploy.json

컨테이너 그룹 세부 정보 가져오기

가용성 영역에 성공적으로 배포된 컨테이너 그룹을 확인하려면 az container show 명령을 사용하여 컨테이너 그룹 세부 정보를 확인합니다.

az container show --name acilinuxcontainergroup --resource-group myResourceGroup

다음 단계

가용성 영역에 대한 Azure 아키텍처 센터의 가이드에서 영역 컨테이너 그룹을 사용하여 내결함성 애플리케이션을 빌드하는 방법을 알아봅니다.