티스토리 뷰

<출처> https://azure.github.io/application-gateway-kubernetes-ingress/setup/install-new/

 

 

 

 

 

그린필드(Greenfield) 배포 -  신규 AKS 생성 시

아래 지시 사항은 기존 구성 요소가 없는 환경에 AGIC가 설치되는 것으로 가정한다.

 

 

 

 

요구되는 CLI 도구

Azure Cloud Shell을 사용하는 것이 좋다. 또는 Azure 포털에서 다음 아이콘을 클릭한다.

 

Azure Cloud Shell에는 이미 필요한 모든 도구가 있다. 다른 환경을 사용하려면 다음 명령 줄 도구가 설치되어 있는지 확인한다.

(필자는 WSL bash 환경에서 작업을 진행하겠다.)

  1. az - Azure CLI: 설치 지침 
  2. kubectl - Kubernetes command-line tool: 설치 지침
  3. helm - Kubernetes package manager: 설치 지침
  4. jq - command-line JSON processor: 설치 지침

 

 

 

Identity 생성

아래 단계에 따라 Azure Active Directory(AAD ) 서비스 사용 주체를 만든다. appId, password 및 objectId 값을 기록해둔다. 이 값은 다음 단계에서 사용된다.

 

1. AD 서비스 주체를 만든다(RBAC에 대해 자세히 알아보기). Azure Cloud Shell에 다음 줄을 붙여 넣는다.

az ad sp create-for-rbac --skip-assignment -o json > auth.json
appId=$(jq -r ".appId" auth.json)
password=$(jq -r ".password" auth.json)
echo $appId
zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ az ad sp create-for-rbac --skip-assignment -o json > auth.json
Retrying service principal creation: 1/36
Retrying service principal creation: 2/36
zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ appId=$(jq -r ".appId" auth.json)
zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ password=$(jq -r ".password" auth.json)
zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ echo $appId
d24e603b-438d-4150-9780-65c3b7402125

 

2. Cloud Shell에서 다음 명령을 실행하여 새로운 Service Princpial 인 objectId bash 변수를 만든다.

objectId=$(az ad sp show --id $appId --query "objectId" -o tsv)
echo $objectId

 

아래의 ARM 템플릿에서 objectId bash 변수가 사용된다. echo $objectId를 사용하여 값을 확인한다.

zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ objectId=$(az ad sp show --id
$appId --query "objectId" -o tsv)
zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ echo $objectId
fce75f22-1638-42a0-8094-664c721801db

 

3. Cloud Shell에 아래의 전체 명령 (여러 줄의 단일 명령)을 붙여 넣어 parameters.json 파일을 만든다. ARM 템플릿 배포에 사용된다.

 

cat <<EOF > parameters.json

{

  "aksServicePrincipalAppId": { "value": "$appId" },

  "aksServicePrincipalClientSecret": { "value": "$password" },

  "aksServicePrincipalObjectId": { "value": "$objectId" },

  "aksEnableRBAC": { "value": false }

}

EOF

 

RBAC 가능 클러스터를 배포하려면 aksEnabledRBAC 필드를 true로 설정한다. cat parameters.json을 사용하여 새로 작성된 파일의 컨텐츠를 확인한다. 이전 단계의 appId, password 및 objectId bash 변수값이 포함된다.

zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ cat <<EOF > parameters.json
> {
>   "aksServicePrincipalAppId": { "value": "$appId" },
>   "aksServicePrincipalClientSecret": { "value": "$password" },
>   "aksServicePrincipalObjectId": { "value": "$objectId" },   
>   "aksEnableRBAC": { "value": false }
> }
> EOF
zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ cat parameters.json
{
  "aksServicePrincipalAppId": { "value": "d24e603b-438d-4150-9780-65c3b7402125" },   
  "aksServicePrincipalClientSecret": { "value": "a2ead596-xxxx-xxx-xxxx-be674e769493" },
  "aksServicePrincipalObjectId": { "value": "fce75f22-1638-42a0-8094-664c721801db" },
  "aksEnableRBAC": { "value": false }
}

 

 

 

 

컴포넌트 배포

다음 몇 단계는 Azure 구독에 다음 구성 요소 목록을 추가한다.

  • Azure Kubernetes 서비스
  • 애플리케이션 게이트웨이 v2
  • 서브넷이 2 개인 가상 네트워크
  • 퍼블릭 IP 주소
  • AAD 포드 ID에서 사용될 관리되는 ID
  • ARM 템플릿을 template.json 파일로 다운로드 한다.

쉘에 다음을 붙여 넣는다.

wget https://raw.githubusercontent.com/Azure/application-gateway-kubernetes-ingress/master/deploy/azuredeploy.json -O template.json
zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ wget https://raw.githubusercontent.com/Azure/application-gateway-kubernetes-ingress/master/deploy/azuredeploy.json -O template.json
Will not apply HSTS. The HSTS database must be a regular and non-world-writable file.
ERROR: could not open HSTS store at '/home/zerobig/.wget-hsts'. HSTS will be disabled.--2020-03-22 15:35:34--  https://raw.githubusercontent.com/Azure/application-gateway-kubernetes-ingress/master/deploy/azuredeploy.json
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.196.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.196.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 27230 (27K) [text/plain]
Saving to: ‘template.json’
 
template.json         100%[=======================>]  26.59K  --.-KB/s    in 0.1s   
 
2020-03-22 15:35:35 (180 KB/s) - ‘template.json’ saved [27230/27230]

 

<주의>

westus2에서 지원되는 kubernetesVersion이 지금 내려받은 template.json 내 버전과 상이하므로

template.json 파일 내 kubernesVersion 버전의 수정이 필요하다. 기존 "1.15.5"를 다음과 같이 수정한다.

 

 

  • Azure Cloud Shell 및 az 도구를 통해 ARM 템플릿을 배포한다. 리소스 그룹 및 지역/위치의 이름을 수정한 후 다음 각 행을 쉘에 붙여 넣는다. 
resourceGroupName="zh0322"
location="westus2"
deploymentName="ingress-appgw"
az group create -n $resourceGroupName -l $location
az group deployment create -g $resourceGroupName -n $deploymentName --template-file template.json --parameters parameters.json

 

참고 : 마지막 명령을 완료하는 데 몇 분이 걸릴 수 있다.

zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ resourceGroupName="zh0322"
zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ location="westus2"
zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ deploymentName="ingress-appgw"zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ az group create -n $resourceGroupName -l $location
{
  "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322", 
  "location": "westus2",
  "managedBy": null,
  "name": "zh0322",
  "properties": {
    "provisioningState": "Succeeded"
  },
  "tags": null,
  "type": "Microsoft.Resources/resourceGroups"
}
zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ az group deployment create -g
$resourceGroupName -n $deploymentName --template-file template.json --parameters parameters.json
{
  "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.Resources/deployments/ingress-appgw",
  "location": null,
  "name": "ingress-appgw",
  "properties": {
    "correlationId": "9e901f92-90c5-4de8-b685-346418063fe2",
    "debugSetting": null,
    "dependencies": [
      {
        "dependsOn": [
          {
            "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.Network/virtualNetworks/virtualnetwork5c35",
            "resourceGroup": "zh0322",
            "resourceName": "virtualnetwork5c35",
            "resourceType": "Microsoft.Network/virtualNetworks"
          },
          {
            "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.Network/publicIPAddresses/appgwpublicip5c35",
            "resourceGroup": "zh0322",
            "resourceName": "appgwpublicip5c35",
            "resourceType": "Microsoft.Network/publicIPAddresses"
          }
        ],
        "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.Network/applicationGateways/applicationgateway5c35",
        "resourceGroup": "zh0322",
        "resourceName": "applicationgateway5c35",
        "resourceType": "Microsoft.Network/applicationGateways"
      },
      {
        "dependsOn": [
          {
            "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.Network/virtualNetworks/virtualnetwork5c35",
            "resourceGroup": "zh0322",
            "resourceName": "virtualnetwork5c35",
            "resourceType": "Microsoft.Network/virtualNetworks"
          },
          {
            "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.ManagedIdentity/userAssignedIdentities/appgwContrIdentity5c35",
            "resourceGroup": "zh0322",
            "resourceName": "appgwContrIdentity5c35",
            "resourceType": "Microsoft.ManagedIdentity/userAssignedIdentities"       
          }
        ],
        "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.Resources/deployments/RoleAssignmentDeploymentForKubenetesSp",
        "resourceGroup": "zh0322",
        "resourceName": "RoleAssignmentDeploymentForKubenetesSp",
        "resourceType": "Microsoft.Resources/deployments"
      },
      {
        "dependsOn": [
          {
            "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.Network/applicationGateways/applicationgateway5c35",      
            "resourceGroup": "zh0322",
            "resourceName": "applicationgateway5c35",
            "resourceType": "Microsoft.Network/applicationGateways"
          },
          {
            "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.ManagedIdentity/userAssignedIdentities/appgwContrIdentity5c35",
            "resourceGroup": "zh0322",
            "resourceName": "appgwContrIdentity5c35",
            "resourceType": "Microsoft.ManagedIdentity/userAssignedIdentities"       
          },
          {
            "apiVersion": "2015-08-31-PREVIEW",
            "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.ManagedIdentity/userAssignedIdentities/appgwContrIdentity5c35",
            "resourceGroup": "zh0322",
            "resourceName": "appgwContrIdentity5c35",
            "resourceType": "Microsoft.ManagedIdentity/userAssignedIdentities"       
          }
        ],
        "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.Resources/deployments/RoleAssignmentDeploymentForUserAssignedIdentity",
        "resourceGroup": "zh0322",
        "resourceName": "RoleAssignmentDeploymentForUserAssignedIdentity",
        "resourceType": "Microsoft.Resources/deployments"
      },
      {
        "dependsOn": [
          {
            "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.Network/virtualNetworks/virtualnetwork5c35",
            "resourceGroup": "zh0322",
            "resourceName": "virtualnetwork5c35",
            "resourceType": "Microsoft.Network/virtualNetworks"
          },
          {
            "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.Resources/deployments/RoleAssignmentDeploymentForKubenetesSp",
            "resourceGroup": "zh0322",
            "resourceName": "RoleAssignmentDeploymentForKubenetesSp",
            "resourceType": "Microsoft.Resources/deployments"
          }
        ],
        "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.ContainerService/managedClusters/aks5c35",
        "resourceGroup": "zh0322",
        "resourceName": "aks5c35",
        "resourceType": "Microsoft.ContainerService/managedClusters"
      }
    ],
    "duration": "PT6M48.4241816S",
    "mode": "Incremental",
    "onErrorDeployment": null,
    "outputResources": [
      {
        "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.Authorization/roleAssignments/fc026b87-ac37-5ecd-bebc-03c02d834c8a",
        "resourceGroup": "zh0322"
      },
      {
        "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.ContainerService/managedClusters/aks5c35",
        "resourceGroup": "zh0322"
      },
      {
        "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.ManagedIdentity/userAssignedIdentities/appgwContrIdentity5c35",        "resourceGroup": "zh0322"
      },
      {
        "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.ManagedIdentity/userAssignedIdentities/appgwContrIdentity5c35/providers/Microsoft.Authorization/roleAssignments/5e4f9cac-bb37-5b12-9d7d-23c386891347",
        "resourceGroup": "zh0322"
      },
      {
        "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.Network/applicationGateways/applicationgateway5c35",
        "resourceGroup": "zh0322"
      },
      {
        "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.Network/applicationgateways/applicationgateway5c35/providers/Microsoft.Authorization/roleAssignments/25ee8231-62c8-5511-80fd-28f8ffd5f2e0",
        "resourceGroup": "zh0322"
      },
      {
        "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.Network/publicIPAddresses/appgwpublicip5c35",
        "resourceGroup": "zh0322"
      },
      {
        "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.Network/virtualNetworks/virtualnetwork5c35",
        "resourceGroup": "zh0322"
      },
      {
        "id": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.Network/virtualNetworks/virtualnetwork5c35/subnets/kubesubnet/providers/Microsoft.Authorization/roleAssignments/16a41df9-2f41-55cd-b48c-18f0cd522680",
        "resourceGroup": "zh0322"
      }
    ],
    "outputs": {
      "aksApiServerAddress": {
        "type": "String",
        "value": "aks-f40ed7e9.hcp.westus2.azmk8s.io"
      },
      "aksClusterName": {
        "type": "String",
        "value": "aks5c35"
      },
      "applicationGatewayName": {
        "type": "String",
        "value": "applicationgateway5c35"
      },
      "identityClientId": {
        "type": "String",
        "value": "e7ec52bb-8e27-48c2-926c-62078c21e859"
      },
      "identityResourceId": {
        "type": "String",
        "value": "/subscriptions/f8764f39-xxxx-xxxx-xxxx-77b286ed971b/resourceGroups/zh0322/providers/Microsoft.ManagedIdentity/userAssignedIdentities/appgwContrIdentity5c35"
      },
      "resourceGroupName": {
        "type": "String",
        "value": "zh0322"
      },
      "subscriptionId": {
        "type": "String",
        "value": "f8764f39-xxxx-xxxx-xxxx-77b286ed971b"
      }
    },
    "parameters": {
      "aksAgentCount": {
        "type": "Int",
        "value": 3
      },
      "aksAgentOsDiskSizeGB": {
        "type": "Int",
        "value": 40
      },
      "aksAgentVMSize": {
        "type": "String",
        "value": "Standard_D3_v2"
      },
      "aksDnsPrefix": {
        "type": "String",
        "value": "aks"
      },
      "aksDnsServiceIP": {
        "type": "String",
        "value": "10.2.0.10"
      },
      "aksDockerBridgeCIDR": {
        "type": "String",
        "value": "172.17.0.1/16"
      },
      "aksEnableRBAC": {
        "type": "Bool",
        "value": false
      },
      "aksServiceCIDR": {
        "type": "String",
        "value": "10.2.0.0/16"
      },
      "aksServicePrincipalAppId": {
        "type": "String",
        "value": "d24e603b-438d-4150-9780-65c3b7402125"
      },
      "aksServicePrincipalClientSecret": {
        "type": "SecureString"
      },
      "aksServicePrincipalObjectId": {
        "type": "String",
        "value": "fce75f22-1638-42a0-8094-664c721801db"
      },
      "aksSubnetAddressPrefix": {
        "type": "String",
        "value": "10.0.0.0/16"
      },
      "applicationGatewaySku": {
        "type": "String",
        "value": "WAF_v2"
      },
      "applicationGatewaySubnetAddressPrefix": {
        "type": "String",
        "value": "10.1.0.0/16"
      },
      "kubernetesVersion": {
        "type": "String",
        "value": "1.15.10"
      },
      "virtualNetworkAddressPrefix": {
        "type": "String",
        "value": "10.0.0.0/8"
      }
    },
    "parametersLink": null,
    "providers": [
      {
        "id": null,
        "namespace": "Microsoft.ManagedIdentity",
        "registrationPolicy": null,
        "registrationState": null,
        "resourceTypes": [
          {
            "aliases": null,
            "apiVersions": null,
            "capabilities": null,
            "locations": [
              "westus2"
            ],
            "properties": null,
            "resourceType": "userAssignedIdentities"
          }
        ]
      },
      {
        "id": null,
        "namespace": "Microsoft.Network",
        "registrationPolicy": null,
        "registrationState": null,
        "resourceTypes": [
          {
            "aliases": null,
            "apiVersions": null,
            "capabilities": null,
            "locations": [
              "westus2"
            ],
            "properties": null,
            "resourceType": "virtualNetworks"
          },
          {
            "aliases": null,
            "apiVersions": null,
            "capabilities": null,
            "locations": [
              "westus2"
            ],
            "properties": null,
            "resourceType": "publicIPAddresses"
          },
          {
            "aliases": null,
            "apiVersions": null,
            "capabilities": null,
            "locations": [
              "westus2"
            ],
            "properties": null,
            "resourceType": "applicationGateways"
          }
        ]
      },
      {
        "id": null,
        "namespace": "Microsoft.Resources",
        "registrationPolicy": null,
        "registrationState": null,
        "resourceTypes": [
          {
            "aliases": null,
            "apiVersions": null,
            "capabilities": null,
            "locations": [
              null
            ],
            "properties": null,
            "resourceType": "deployments"
          }
        ]
      },
      {
        "id": null,
        "namespace": "Microsoft.ContainerService",
        "registrationPolicy": null,
        "registrationState": null,
        "resourceTypes": [
          {
            "aliases": null,
            "apiVersions": null,
            "capabilities": null,
            "locations": [
              "westus2"
            ],
            "properties": null,
            "resourceType": "managedClusters"
          }
        ]
      }
    ],
    "provisioningState": "Succeeded",
    "template": null,
    "templateHash": "5554300784726754287",
    "templateLink": null,
    "timestamp": "2020-03-22T07:14:47.197876+00:00"
  },
  "resourceGroup": "zh0322",
  "type": "Microsoft.Resources/deployments"
}

 

# Values 설명

-verbosityLevel : AGIC 로깅 인프라의 상세 수준을 설정한다. 가능한 값은 로깅 레벨을 참조한다. 

-appgw.subscriptionId : Application Gateway가 있는 Azure 구독 ID이다.

-appgw.resourceGroup : Application Gateway가 생성된 Azure Resource Group의 이름이다.

-appgw.name : Application Gateway의 이름이다.

-appgw.shared :이 부울 플래그는 기본적으로 false로 설정되어야 한다. 공유 Application Gateway가 필요한 경우 true로 설정한다.

-kubernetes.watchNamespace : AGIC가 감시할 네임스페이스를 지정한다. 단일 문자열 값이거나 쉼표로 구분된 네임스페이스 목록 일 수 있다.

-armAuth.type : aadPodIdentity 또는 servicePrincipal 일 수 있다.

-armAuth.identityResourceID : Azure Managed Identity의 리소스 ID이다.

-armAuth.identityClientId : Identity의 클라이언트 ID이다. Identity-armAuth.secretJSON에 대한 자세한 내용은 아래를 참조한다. 

armip.type이 servicePrincipal로 설정된 경우 서비스 주체 secret 유형이 선택된 경우에만 필요하다.

-rbac.enabled : AKS 클러스터가 있는 경우 이를 true로 설정한다. 즉 RBAC가 활성화 된 것이다.

ID에 대한 참고 사항 : identityResourceID 및 identityClientID는 ID 작성 단계에서 작성된 값이며 다음 명령을 사용하여 다시 얻을 수 있다.

az identity show -g <resource-group> -n <identity-name>

 

-위 명령의 <resource-group>은 App Gateway의 리소스 그룹이다.

-<identity-name>은 생성된 아이디의 이름이다. az identity list를 사용하여 지정된 구독에 대한 모든 ID를 나열 할 수 있다.

 

1. AGIC 패키지를 설치한다.

helm install -f helm-config.yaml application-gateway-kubernetes-ingress/ingress-azure
zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ helm install -f helm-config.yaml application-gateway-kubernetes-ingress/ingress-azure
NAME:   odd-indri
LAST DEPLOYED: Sun Mar 22 16:31:29 2020
NAMESPACE: default
STATUS: DEPLOYED
 
RESOURCES:
==> v1/AzureIdentity
NAME                          AGE
odd-indri-azid-ingress-azure  0s
 
==> v1/AzureIdentityBinding
NAME                                 AGE
odd-indri-azidbinding-ingress-azure  0s
 
==> v1/ConfigMap
NAME                        DATA  AGE
odd-indri-cm-ingress-azure  8     0s
 
==> v1/ServiceAccount
NAME                        SECRETS  AGE
odd-indri-sa-ingress-azure  1        0s
 
==> v1beta2/Deployment
NAME                     READY  UP-TO-DATE  AVAILABLE  AGE
odd-indri-ingress-azure  0/1    0           0          0s
 
 
NOTES:
Thank you for installing ingress-azure:1.0.0.
 
Your release is named odd-indri.
The controller is deployed in deployment odd-indri-ingress-azure.
 
Configuration Details:
----------------------
 * AzureRM Authentication Method:
    - Use AAD-Pod-Identity
 * Application Gateway:
    - Subscription ID : f8764f39-xxxx-xxxx-xxxx-77b286ed971b
    - Resource Group  : zh0322
    - Application Gateway Name : applicationgateway5c35
 * Kubernetes Ingress Controller:
    - Watching All Namespaces
    - Verbosity level: 3
 
Please make sure the associated aadpodidentity and aadpodidbinding is configured.
For more information on AAD-Pod-Identity, please visit https://github.com/Azure/aad-pod-identity

 

 

샘플 앱 설치

App Gateway, AKS 및 AGIC가 설치되었으므로 Azure Cloud Shell을 통해 샘플 앱을 설치할 수 있다.

cat <<EOF | kubectl apply -f -

apiVersion: v1

kind: Pod

metadata:

  name: aspnetapp

  labels:

    app: aspnetapp

spec:

  containers:

  - image: "mcr.microsoft.com/dotnet/core/samples:aspnetapp"

    name: aspnetapp-image

    ports:

    - containerPort: 80

      protocol: TCP

 

---

 

apiVersion: v1

kind: Service

metadata:

  name: aspnetapp

spec:

  selector:

    app: aspnetapp

  ports:

  - protocol: TCP

    port: 80

    targetPort: 80

 

---

 

apiVersion: extensions/v1beta1

kind: Ingress

metadata:

  name: aspnetapp

  annotations:

    kubernetes.io/ingress.class: azure/application-gateway

spec:

  rules:

  - http:

      paths:

      - path: /

        backend:

          serviceName: aspnetapp

          servicePort: 80

EOF

 

zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ cat <<EOF | kubectl apply -f -
> apiVersion: v1
> kind: Pod
> metadata:
>   name: aspnetapp
>   labels:
>     app: aspnetapp
> spec:
>   containers:
>   - image: "mcr.microsoft.com/dotnet/core/samples:aspnetapp"
>     name: aspnetapp-image
>     ports:
>     - containerPort: 80
>       protocol: TCP
>
> ---
>
> apiVersion: v1
> kind: Service
> metadata:
>   name: aspnetapp
> spec:
>   selector:
>     app: aspnetapp
>   ports:
>   - protocol: TCP
>     port: 80
>     targetPort: 80
>
> ---
>
> apiVersion: extensions/v1beta1
> kind: Ingress
> metadata:
>   name: aspnetapp
>   annotations:
>     kubernetes.io/ingress.class: azure/application-gateway
> spec:
>   rules:
>   - http:
>       paths:
>       - path: /
>         backend:
>           serviceName: aspnetapp
>           servicePort: 80
> EOF
pod/aspnetapp created
service/aspnetapp created
ingress.extensions/aspnetapp created

 

kubectl get all 명령을 사용하여 배포 결과를 확인한다.

zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ kubectl get all
NAME                                           READY   STATUS    RESTARTS   AGE
pod/aspnetapp                                  1/1     Running   0          21s
pod/mic-84cc89497c-llt4l                       1/1     Running   0          14m
pod/mic-84cc89497c-x4krl                       1/1     Running   0          14m
pod/nmi-hr25j                                  1/1     Running   0          14m
pod/nmi-tvvdd                                  1/1     Running   0          14m
pod/nmi-xwjqw                                  1/1     Running   0          14m
pod/odd-indri-ingress-azure-7f484b67d7-tkx97   1/1     Running   0          69s
 
NAME                 TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)   AGE
service/aspnetapp    ClusterIP   10.2.26.181   <none>        80/TCP    21s
service/kubernetes   ClusterIP   10.2.0.1      <none>        443/TCP   22m
 
NAME                 DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR                 AGE       
daemonset.apps/nmi   3         3         3       3            3           beta.kubernetes.io/os=linux   14m       
 
NAME                                      READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/mic                       2/2     2            2           14m
deployment.apps/odd-indri-ingress-azure   1/1     1            1           71s
 
NAME                                                 DESIRED   CURRENT   READY   AGE
replicaset.apps/mic-84cc89497c                       2         2         2       14m
replicaset.apps/odd-indri-ingress-azure-7f484b67d7   1         1         1       71s

 

kubectl get ingress 명령을 사용하여 Ingress Contoller의 퍼블릭 주소를 확인한다.

zerobig@ZEROBIG-NT800:/mnt/d/Azure-Study/20200322_agic$ kubectl get ing
NAME        HOSTS   ADDRESS        PORTS   AGE
aspnetapp   *       40.91.80.102   80      3m30s

 

참고로 이 주소는 Application Gateway의 프론트엔드 퍼블릭 주소와 일치함을 확인할 수 있다.

 

해당 주소를 브라우저 창에서 입력하여 결과를 확인한다.

 

 

 

 

다른 예제

튜토리얼 문서에는 HTTP 또는 HTTPS를 통해 AKS 서비스를 App Gateway를 사용하여 인터넷에 노출시키는 방법에 대한 추가 예제가 포함되어 있다.

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함