Azure Contaainer Apps는 일반 탐색을 구성합니다.

Azure Contaainer Apps에서는 정상성 탐색을 사용할 수 있습니다.
그러나 현재 GUI(Azure portal)는 적절한 설정을 할 수 없습니다.
ARM Template에서 디자인할 필요가 있지만, 공식 문서에서 미묘한 생략이 있었던 것 같아 실제로 하고 결과를 남겼다.

환경·준비

  • Azure Container Apps
  • Windows 10
  • Windows PowerShell
  • Azure CLI (v2.30.0)
  • 사용된 샘플


    이번에는 웹 서버만 서면 OK여서 사용했다Nginx.

    정상성 탐지 정보


    정상성 탐지 자체는 Kubernetes의 개념이다.다음 문서를 참조하십시오.

    해봤어요.


    일반 동작 모드(1)


    ARM Template 만들기


    ARM Templatecontainers의 부하probes에서 탐지의 구성을 배열로 지정합니다.
    프로토타입은 단일 컨테이너 이미지 컨테이너 앱이 생성한 ARM Template를 참고해 아래template.jsonparameters.json를 제작했다.
    template.json
    {
        "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "subscriptionId": {
                "type": "string"
            },
            "name": {
                "type": "string"
            },
            "location": {
                "type": "string"
            },
            "environmentId": {
                "type": "string"
            },
            "containers": {
                "type": "array"
            },
            "secrets": {
                "type": "array"
            },
            "registries": {
                "type": "array"
            },
            "ingress": {
                "type": "object"
            }
        },
        "resources": [
            {
                "name": "[parameters('name')]",
                "kind": "containerapps",
                "location": "[parameters('location')]",
                "dependsOn": [],
                "properties": {
                    "configuration": {
                        "secrets": "[parameters('secrets')]",
                        "registries": "[parameters('registries')]",
                        "ingress": "[parameters('ingress')]"
                    },
                    "template": {
                        "containers": "[parameters('containers')]"
                    },
                    "managedEnvironmentId": "[parameters('environmentId')]"
                },
                "apiVersion": "2022-01-01-preview",
                "type": "Microsoft.App/containerapps"
            }
        ]
    }
    
    parameters.json
    {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "subscriptionId": {
                "value": "..." // Subscription ID
            },
            "name": {
                "value": "prove-test-80"
            },
            "location": {
                "value": "northeurope"
            },
            "environmentId": {
                "value": "..." // Container Apps Environment ID
            },
            "containers": {
                "value": [
                    {
                        "name": "prove-test-con",
                        "image": "nginx",
                        "command": [],
                        "resources": {
                            "cpu": ".25",
                            "memory": ".5Gi"
                        },
                        "probes": [
                            {
                                "type": "readiness",
                                "tcpSocket": {
                                    "port": 80
                                },
                                "initialDelaySeconds": 1,
                                "periodSeconds": 5
                            }
                        ]
                    }
                ]
            },
            "registries": {
                "value": []
            },
            "secrets": {
                "value": []
            },
            "ingress": {
                "value": {
                    "external": true,
                    "targetPort": "80",
                    "transport": "auto",
                    "allowInsecure": true
                }
            }
        }
    }
    
    !
    잡담initialDelaySeconds에 관해서는 Kubbernetes의 공식 중 최소치가 0였지만 0을 설정하는 중 오류가 발생했습니다.
    InitialDelaySeconds must be in the range of ['1', '60'].
    위에서 설명한 대로 1 는 최소값으로 설정됩니다.의도한 By Design인지 아닌지는 확인되지 않았다.

    프로그램 설계


    컨테이너 앱스 환경이 제작되면 이후 ARM Template를 디자인하면 OK.
    az deployment group create --resource-group <リソースグループ名> --template-file template.json --parameters '@parameters.json'
    

    동작 확인


    정상 액세스 여부를 확인할 수 있습니다.

    NG 모드


    ARM Template 만들기


    이번에는 Startup Probe를 설정해 보겠습니다.고의적인 실패를 위해 인증 포트를 81로 설정합니다.template.json가 같기 때문에 생략합니다.
    parameters.json
    {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "subscriptionId": {
                "value": "..." // Subscription ID
            },
            "name": {
                "value": "prove-test-81"
            },
            "location": {
                "value": "northeurope"
            },
            "environmentId": {
                "value": "..." // Container Apps Environment ID
            },
            "containers": {
                "value": [
                    {
                        "name": "prove-test-con",
                        "image": "nginx",
                        "command": [],
                        "resources": {
                            "cpu": ".25",
                            "memory": ".5Gi"
                        },
                        "probes": [
                            {
                                "type": "readiness",
                                "tcpSocket": {
                                    "port": 80
                                },
                                "initialDelaySeconds": 1,
                                "periodSeconds": 5
                            },
                            {
                                "type": "startup",
                                "httpGet": {
                                    "path": "/",
                                    "port": 81,
                                    "httpHeaders": [
                                        {
                                            "name": "Custom-Header",
                                            "value": "startup probe"
                                        }
                                    ]
                                },
                                "initialDelaySeconds": 1,
                                "periodSeconds": 5
                            }
                        ]
                    }
                ]
            },
            "registries": {
                "value": []
            },
            "secrets": {
                "value": []
            },
            "ingress": {
                "value": {
                    "external": true,
                    "targetPort": "80",
                    "transport": "auto",
                    "allowInsecure": true
                }
            }
        }
    }
    

    프로그램 설계


    동상

    동작 확인


    얼마든지 접근할 수 없음을 확인할 수 있습니다.Startup Probe가 실패했기 때문에 수신 액세스를 효과적으로 할당할 수 없습니다.
    또 로그 애널리틱스 쪽에서 뭔가 나오는 줄 알고 확인해 봤는데 제대로 된 일지가 보이지 않았다.서운하다

    정상 동작 모드(2)


    ARM Template 만들기


    Startup Probe의 인증 포트를 80로 설정합니다.template.json가 같기 때문에 생략합니다.
    parameters.json
    {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "subscriptionId": {
                "value": "..." // Subscription ID
            },
            "name": {
                "value": "prove-test-80-2"
            },
            "location": {
                "value": "northeurope"
            },
            "environmentId": {
                "value": "..." // Container Apps Environment ID
            },
            "containers": {
                "value": [
                    {
                        "name": "prove-test-con",
                        "image": "nginx",
                        "command": [],
                        "resources": {
                            "cpu": ".25",
                            "memory": ".5Gi"
                        },
                        "probes": [
                            {
                                "type": "readiness",
                                "tcpSocket": {
                                    "port": 80
                                },
                                "initialDelaySeconds": 1,
                                "periodSeconds": 5
                            },
                            {
                                "type": "startup",
                                "httpGet": {
                                    "path": "/",
                                    "port": 80,
                                    "httpHeaders": [
                                        {
                                            "name": "Custom-Header",
                                            "value": "startup probe"
                                        }
                                    ]
                                },
                                "initialDelaySeconds": 1,
                                "periodSeconds": 5
                            }
                        ]
                    }
                ]
            },
            "registries": {
                "value": []
            },
            "secrets": {
                "value": []
            },
            "ingress": {
                "value": {
                    "external": true,
                    "targetPort": "80",
                    "transport": "auto",
                    "allowInsecure": true
                }
            }
        }
    }
    

    프로그램 설계


    동상

    동작 확인


    이번에는 정상 방문이 가능하다는 것을 확인했다.

    총결산


    무사히 동작을 확인했습니다.🤗
    일반적인 Kubbernetes와 마찬가지로'시동을 기다리는 데 시간이 걸리는 컨테이너'를 실현할 수 있습니다!

    좋은 웹페이지 즐겨찾기