티스토리 뷰

Fruit Smoothies 소프트웨어 개발 및 운영 팀은 새로 개발된 모든 애플리케이션을 컨테이너화하기로 했다. 컨테이너화된 애플리케이션은 팀 상호 간에 혜택을 제공한다. 예를 들면 다음과 같다.

  • 호스팅 환경 관리의 용이성
  • 소프트웨어 딜리버리의 지속성 보장
  • 서버 하드웨어의 효율적 사용
  • 환경 간 애플리케이션의 이식성

 

팀에서는 모든 컨테이너를 중앙의 안전한 위치에 저장하고 결정을 내릴 때 Azure Container Registry를 사용하도록 했다.

이 실습에서는 다음을 수행하게 된다.

  • Azure CLI를 사용하여 컨테이너 레지스트리 만들기
  • Azure Container Registry 작업을 사용하여 컨테이너 이미지 빌드
  • Azure Container Registry에서 컨테이너 이미지 확인
  • Azure Container Registry에 대해 인증하도록 AKS 클러스터 구성

 

 

 

컨테이너 레지스트리 만들기

Azure Container Registry는 오픈 소스 Docker Registry 2.0을 기반으로 하는 관리형 Docker 레지스트리 서비스이다. Container Registry는 프라이빗이며 Azure에서 호스트된다. 이를 사용하여 모든 유형의 컨테이너 배포에 대한 이미지를 빌드, 저장 및 관리한다.

Docker CLI 또는 Azure CLI를 사용하여 Container Registry로 컨테이너 이미지를 밀어 넣고 끌어올 수 있다. Azure Portal 통합을 사용하여 Container Registry의 컨테이너 이미지를 시각적으로 검사할 수 있다. 분산 환경에서는 지역화된 배포를 위해 Container Registry 지역 복제 기능을 사용하여 컨테이너 이미지를 여러 Azure 데이터 센터에 배포할 수 있다.

Azure Container Registry 태스크를 사용하여 Azure에서 컨테이너 이미지를 빌드할 수도 있다. 태스크는 로컬 Docker 도구를 사용할 필요 없이 표준 Dockerfile을 사용하여 Azure Container Registry에 컨테이너 이미지를 만들고 저장한다. Azure Container Registry 태스크를 사용하면 DevOps 프로세스와 도구를 사용하여 컨테이너 이미지 빌드를 완전히 자동화하거나 요청 시 빌드할 수 있다.

Fruit Smoothies 환경용 컨테이너 레지스트리를 배포해 보자.

1. 컨테이너 레지스트리 이름은 Azure 내에서 고유해야 하며, 5~50자 사이의 영숫자를 포함해야 한다. 학습 목적상 Azure Cloud Shell에서 이 명령을 실행하여 고유한 이름을 저장하는 Bash 변수를 만든다.

(이전 주에 이어 새로 실습을 수행하는 경우 리소스 그룹 및 리전에 대한 변수도 함께 선언해 줘야 한다.)


ACR_NAME=acr$RANDOM

RESOURCE_GROUP=aksworkshop
REGION_NAME=koreacentral

kim@Azure:~$
kim@Azure:~$ ACR_NAME=acr$RANDOM
kim@Azure:~$
kim@Azure:~$ RESOURCE_GROUP=aksworkshop
kim@Azure:~$ REGION_NAME=koreacentral
kim@Azure:~$

 

 

2. az acr create 명령을 사용하여 AKS(Azure Kubernetes Service) 클러스터와 동일한 리소스 그룹 및 지역에 레지스트리를 만든다(예: 한국 중부 aksworkshop).

아래 명령을 실행하여 ACR 인스턴스를 만든다.


az acr create \
--resource-group $RESOURCE_GROUP \
--location $REGION_NAME \
--name $ACR_NAME \
--sku Standard

 

명령이 완료되면 다음 JSON 예제와 비슷한 응답이 표시된다.

kim@Azure:~$ az acr create \
> --resource-group $RESOURCE_GROUP \
> --location $REGION_NAME \
> --name $ACR_NAME \
> --sku Standard
{- Starting ..
  "adminUserEnabled": false,
  "anonymousPullEnabled": false,
  "creationDate": "2021-04-18T00:41:15.682623+00:00",
  "dataEndpointEnabled": false,
  "dataEndpointHostNames": [],
  "encryption": {
    "keyVaultProperties": null,
    "status": "disabled"
  },
  "id": "/subscriptions/1199b626-xxxx-xxxx-xxxx-cabaxxxxee88/resourceGroups/aksworkshop/providers/Microsoft.ContainerRegistry/registries/acr11501",
  "identity": null,
  "location": "koreacentral",
  "loginServer": "acr11501.azurecr.io",
  "name": "acr11501",
  "networkRuleBypassOptions": "AzureServices",
  "networkRuleSet": null,
  "policies": {
    "quarantinePolicy": {
      "status": "disabled"
    },
    "retentionPolicy": {
      "days": 7,
      "lastUpdatedTime": "2021-04-18T00:41:18.116903+00:00",
      "status": "disabled"
    },
    "trustPolicy": {
      "status": "disabled",
      "type": "Notary"
    }
  },
  "privateEndpointConnections": [],
  "provisioningState": "Succeeded",
  "publicNetworkAccess": "Enabled",
  "resourceGroup": "aksworkshop",
  "sku": {
    "name": "Standard",
    "tier": "Standard"
  },
  "status": null,
  "systemData": {
    "createdAt": "2021-04-18T00:41:15.682623+00:00",
    "createdBy": "zerobig.kim@gmail.com",
    "createdByType": "User",
    "lastModifiedAt": "2021-04-18T00:41:15.682623+00:00",
    "lastModifiedBy": "zerobig.kim@gmail.com",
    "lastModifiedByType": "User"
  },
  "tags": {},
  "type": "Microsoft.ContainerRegistry/registries",
  "zoneRedundancy": "Disabled"
}

 

 

 

Azure Container Registry 태스크를 사용하여 컨테이너 이미지 빌드

Fruit Smoothies 평가 앱은 프런트 엔드 웹 사이트와 RESTful API 웹 서비스에 각각 1개의 컨테이너 이미지를 사용한다. 개발 팀은 로컬 Docker 도구를 사용하여 웹 사이트 및 API 웹 서비스에 대한 컨테이너 이미지를 빌드한다. 세 번째 컨테이너는 데이터베이스 게시자가 제공하는 문서 데이터베이스를 배포하는 데 사용되며 ACR에는 데이터베이스 컨테이너가 저장되지 않는다.

Azure Container Registry를 사용하여 표준 Dockerfile로 이러한 컨테이너를 빌드하고 빌드 지침을 제공할 수 있다. Azure Container Registry를 사용하면 다단계 빌드를 포함하여 모든 Dockerfile을 현재 환경에서 다시 사용할 수 있다.

ratings-api 이미지 빌드

평가 API는 Node.js 웹 프레임워크인 Express를 사용하여 빌드된 Node.js 애플리케이션이다. 소스 코드 는 GitHub에 있으며, Node.js Alpine 컨테이너 이미지를 기반으로 이미지를 빌드하는 Dockerfile 이 이미 포함되어 있다.

(Dockerfile의 내용은 다음과 같다.)

-----------------------------------------------------------------------------------------

FROM node:13.5-alpine
 
WORKDIR /usr/src/app
 
# apk를 통해 종속성을 설치
RUN apk update && apk add python g++ make && rm -rf /var/cache/apk/*

# 노드 종속성 설치 - 도커가 캐시 가능토록 별도 스텝으로 수행
COPY package*.json ./
RUN npm install
 
# 이미지 내로 프로젝트 파일 복사
COPY . .
 
# 노드 프로세스가 리슨할 포트 3000으로 노출
EXPOSE 3000
 
# 구동 명령 설정 'npm start'
CMD [ "npm", "start"]

---------------------------------------------------------------------------------------------

 

여기에서 리포지토리를 복제한 다음, 포함된 Dockerfile을 사용하여 Docker 이미지를 빌드한다. 기본 제공 ACR 기능을 사용하여 az acr build 명령을 실행하여 컨테이너 이미지를 빌드하고 레지스트리에 푸시한다.

(소스 코드를 자신의 Git으로 포크하여 진행하도록 하겠다.)

 

1. Cloud Shell에 리포지토리를 복제 후 새로 복제된 디렉터리로 변경한다. (각자 포크한 주소로 clone 한다.)


git clone https://github.com/zer0big/mslearn-aks-workshop-ratings-api.git

cd mslearn-aks-workshop-ratings-api



 

kim@Azure:~$ git clone https://github.com/zer0big/mslearn-aks-workshop-ratings-api.git
Cloning into 'mslearn-aks-workshop-ratings-api'...
remote: Enumerating objects: 83, done.
remote: Total 83 (delta 0), reused 0 (delta 0), pack-reused 83
Unpacking objects: 100% (83/83), done.
kim@Azure:~$ cd mslearn-aks-workshop-ratings-api
kim@Azure:~/mslearn-aks-workshop-ratings-api$

 

2. az acr build를 실행한다. 이 명령은 Dockerfile을 사용하여 컨테이너 이미지를 빌드한다. 그런 다음 결과 이미지를 컨테이너 레지스트리로 푸시한다.


az acr build \
--resource-group $RESOURCE_GROUP \
--registry $ACR_NAME \
--image ratings-api:v1 .

 

참고
이전 명령의 끝에 마침표(.)를 포함해야 한다. Dockerfile을 포함하는 원본 디렉터리를 나타낸다. 이 경우에서는 현재 디렉터리이다. --file 매개 변수를 사용하여 파일의 이름을 지정하지 않았기 때문에 명령은 현재 디렉터리에서 Dockerfile이라는 파일을 찾는다.

 

몇 분 후 다음 예제와 비슷한 응답이 표시된다.

kim@Azure:~/mslearn-aks-workshop-ratings-api$ az acr build \
> --resource-group $RESOURCE_GROUP \
> --registry $ACR_NAME \
> --image ratings-api:v1 .
Packing source code into tar to upload...
Excluding '.gitignore' based on default ignore rules
Excluding '.git' based on default ignore rules
Uploading archived source code from '/tmp/build_archive_0153916e0da34cfa81a1978cc863d69a.tar.gz'...
Sending context (14.960 KiB) to registry: acr11501...
Queued a build with ID: de1
Waiting for an agent...
2021/04/18 00:57:15 Downloading source code...
2021/04/18 00:57:16 Finished downloading source code
2021/04/18 00:57:17 Using acb_vol_edc484c5-0419-441b-ba28-3c480d78f6d0 as the home volume
2021/04/18 00:57:17 Setting up Docker configuration...
2021/04/18 00:57:18 Successfully set up Docker configuration
2021/04/18 00:57:18 Logging in to registry: acr11501.azurecr.io
2021/04/18 00:57:19 Successfully logged into acr11501.azurecr.io
2021/04/18 00:57:19 Executing step ID: build. Timeout(sec): 28800, Working directory: '', Network: ''
2021/04/18 00:57:19 Scanning for dependencies...
2021/04/18 00:57:20 Successfully scanned dependencies
2021/04/18 00:57:20 Launching container with name: build
Sending build context to Docker daemon  68.61kB
Step 1/8 : FROM node:13.5-alpine
13.5-alpine: Pulling from library/node
e6b0cf9c0882: Pulling fs layer
ab436df1df6f: Pulling fs layer
470300a8a365: Pulling fs layer
84e7c11579ee: Pulling fs layer
84e7c11579ee: Waiting
e6b0cf9c0882: Verifying Checksum
e6b0cf9c0882: Download complete
e6b0cf9c0882: Pull complete
470300a8a365: Verifying Checksum
84e7c11579ee: Download complete
ab436df1df6f: Verifying Checksum
ab436df1df6f: Download complete
ab436df1df6f: Pull complete
470300a8a365: Pull complete
84e7c11579ee: Pull complete
Digest: sha256:a5a7ff4267a810a019c7c3732b3c463a892a61937d84ee952c34af2fb486058d
Status: Downloaded newer image for node:13.5-alpine
 ---> e1495e4ac50d
Step 2/8 : WORKDIR /usr/src/app
 ---> Running in e2990007b76d
Removing intermediate container e2990007b76d
 ---> e13dbc62dd29
Step 3/8 : RUN apk update && apk add python g++ make && rm -rf /var/cache/apk/*
 ---> Running in 229a61ac9f11
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
v3.11.11-3-g6e25d786ba [http://dl-cdn.alpinelinux.org/alpine/v3.11/main]
v3.11.10-17-gbfbe1432e9 [http://dl-cdn.alpinelinux.org/alpine/v3.11/community]
OK: 11283 distinct packages available
(1/23) Upgrading musl (1.1.24-r0 -> 1.1.24-r3)
(2/23) Upgrading libstdc++ (9.2.0-r3 -> 9.3.0-r0)
(3/23) Installing binutils (2.33.1-r0)
(4/23) Installing gmp (6.1.2-r1)
(5/23) Installing isl (0.18-r0)
(6/23) Installing libgomp (9.3.0-r0)
(7/23) Installing libatomic (9.3.0-r0)
(8/23) Installing mpfr4 (4.0.2-r1)
(9/23) Installing mpc1 (1.1.0-r1)
(10/23) Installing gcc (9.3.0-r0)
(11/23) Installing musl-dev (1.1.24-r3)
(12/23) Installing libc-dev (0.7.2-r0)
(13/23) Installing g++ (9.3.0-r0)
(14/23) Installing make (4.2.1-r2)
(15/23) Installing libbz2 (1.0.8-r1)
(16/23) Installing expat (2.2.9-r1)
(17/23) Installing libffi (3.2.1-r6)
(18/23) Installing gdbm (1.13-r1)
(19/23) Installing ncurses-terminfo-base (6.1_p20200118-r4)
(20/23) Installing ncurses-libs (6.1_p20200118-r4)
(21/23) Installing readline (8.0.1-r0)
(22/23) Installing sqlite-libs (3.30.1-r2)
(23/23) Installing python2 (2.7.18-r0)
Executing busybox-1.31.1-r8.trigger
OK: 212 MiB in 37 packages
Removing intermediate container 229a61ac9f11
 ---> 5a363576d9ed
Step 4/8 : COPY package*.json ./
 ---> 0ec65a001e8b
Step 5/8 : RUN npm install
 ---> Running in 6f058e4f37ac
npm WARN rating-api@1.3.5 No repository field.
npm WARN rating-api@1.3.5 No license field.
 
added 106 packages from 97 contributors and audited 107 packages in 3.808s
found 11 vulnerabilities (4 low, 2 moderate, 5 high)
  run `npm audit fix` to fix them, or `npm audit` for details
Removing intermediate container 6f058e4f37ac
 ---> 9ef3ae7063cf
Step 6/8 : COPY . .
 ---> 5bd45eb4b986
Step 7/8 : EXPOSE 3000
 ---> Running in 025978ca6797
Removing intermediate container 025978ca6797
 ---> 6cd7b2e17e81
Step 8/8 : CMD [ "npm", "start"]
 ---> Running in 7e0adaf11385
Removing intermediate container 7e0adaf11385
 ---> 1be63971475e
Successfully built 1be63971475e
Successfully tagged acr11501.azurecr.io/ratings-api:v1
2021/04/18 00:57:56 Successfully executed container: build
2021/04/18 00:57:56 Executing step ID: push. Timeout(sec): 3600, Working directory: '', Network: ''
2021/04/18 00:57:56 Pushing image: acr11501.azurecr.io/ratings-api:v1, attempt 1
The push refers to repository [acr11501.azurecr.io/ratings-api]
64ee0b2605f8: Preparing
2e66e32085d6: Preparing
5055bc92a74c: Preparing
e9813c6eabf7: Preparing
62a4ebe4658f: Preparing
efd6e0da275f: Preparing
b352b61d0fe4: Preparing
d06ff5e5272b: Preparing
6b27de954cca: Preparing
b352b61d0fe4: Waiting
d06ff5e5272b: Waiting
6b27de954cca: Waiting
efd6e0da275f: Waiting
64ee0b2605f8: Pushed
62a4ebe4658f: Pushed
5055bc92a74c: Pushed
efd6e0da275f: Pushed
2e66e32085d6: Pushed
b352b61d0fe4: Pushed
6b27de954cca: Pushed
d06ff5e5272b: Pushed
e9813c6eabf7: Pushed
v1: digest: sha256:56f7740cd4babac8087e37d4a588e5133c96e88ff7626e1804735d8121a37dbf size: 2204
2021/04/18 00:58:18 Successfully pushed image: acr11501.azurecr.io/ratings-api:v1
2021/04/18 00:58:18 Step ID: build marked as successful (elapsed time in seconds: 37.009990)
2021/04/18 00:58:18 Populating digests for step ID: build...
2021/04/18 00:58:20 Successfully populated digests for step ID: build
2021/04/18 00:58:20 Step ID: push marked as successful (elapsed time in seconds: 22.007416)
2021/04/18 00:58:20 The following dependencies were found:
2021/04/18 00:58:20
- image:
    registry: acr11501.azurecr.io
    repository: ratings-api
    tag: v1
    digest: sha256:56f7740cd4babac8087e37d4a588e5133c96e88ff7626e1804735d8121a37dbf
  runtime-dependency:
    registry: registry.hub.docker.com
    repository: library/node
    tag: 13.5-alpine
    digest: sha256:a5a7ff4267a810a019c7c3732b3c463a892a61937d84ee952c34af2fb486058d
  git: {}
 
Run ID: de1 was successful after 1m6s

 

푸시된 이미지 레지스트리와 이름(예: acr11501.azurecr.io/ratings-api:v1)을 기록해 둔다. Kubernetes 배포를 구성할 때 이 정보를 사용해야 한다.

ratings-web 이미지 빌드

평가 프런트 엔드는 Vue JavaScript 프레임워크 및 WebPack을 사용해 코드를 번들하여 빌드된 Node.js 애플리케이션이다. 소스 코드는 GitHub에 있으며, Node.js Alpine 이미지를 기반으로 이미지를 빌드하는 Dockerfile 이 이미 포함되어 있다.

(Dockerfile의 내용은 다음과 같다.)

 

-----------------------------------------------------------------------------------------

FROM node:13.5-alpine
 
WORKDIR /usr/src/app
 
# apk를 통해 종속성을 설치
RUN apk update && apk add python g++ make && rm -rf /var/cache/apk/*
 
# 노드 종속성 설치 - 도커가 캐시 가능토록 별도 스텝으로 수행
COPY package*.json ./
RUN npm install
 
# 이미지 내로 프로젝트 파일 복사
COPY . .
 
# 노드 프로세스가 리슨할 포트 8080으로 노출
EXPOSE 8080
 
# 구동 명령 설정 'npm start'
CMD [ "npm", "start"]

---------------------------------------------------------------------------------------------

 

수행하는 단계는 이전과 동일하다. 리포지토리를 복제한 다음, az acr build 명령을 사용하여 포함된 Dockerfile을 사용해 Docker 이미지를 빌드한다.

 

1. 먼저 홈 디렉터리로 다시 변경하고 ratings-web 리포지토리를 복제 후 새로 복제된 디렉터리로 변경한다.


cd ~

git clone https://github.com/MicrosoftDocs/mslearn-aks-workshop-ratings-web.git

cd mslearn-aks-workshop-ratings-web



 

kim@Azure:~/mslearn-aks-workshop-ratings-api$ cd ~
kim@Azure:~$ git clone https://github.com/zer0big/mslearn-aks-workshop-ratings-web.git
Cloning into 'mslearn-aks-workshop-ratings-web'...
remote: Enumerating objects: 92, done.
remote: Counting objects: 100% (92/92), done.
remote: Compressing objects: 100% (79/79), done.
remote: Total 92 (delta 36), reused 43 (delta 10), pack-reused 0
Unpacking objects: 100% (92/92), done.
kim@Azure:~$ cd mslearn-aks-workshop-ratings-web

 

2. az acr build를 실행한다. 이 명령은 Dockerfile을 사용하여 컨테이너 이미지를 빌드한다. 그런 다음 결과 이미지를 컨테이너 레지스트리로 푸시한다.

 


az acr build \
--resource-group $RESOURCE_GROUP \
--registry $ACR_NAME \
--image ratings-web:v1 .

 

몇 분 후 다음 예제와 비슷한 응답이 표시된다.

kim@Azure:~/mslearn-aks-workshop-ratings-web$ az acr build \
> --resource-group $RESOURCE_GROUP \
> --registry $ACR_NAME \
> --image ratings-web:v1 .
Packing source code into tar to upload...
Excluding '.gitignore' based on default ignore rules
Excluding '.git' based on default ignore rules
Uploading archived source code from '/tmp/build_archive_3b40ba7230e34a84b3edd008bd008362.tar.gz'...
Sending context (1.211 MiB) to registry: acr11501...
Queued a build with ID: de2
Waiting for an agent...
2021/04/18 01:05:18 Downloading source code...
2021/04/18 01:05:19 Finished downloading source code
2021/04/18 01:05:20 Using acb_vol_6d8e4ace-0972-4b53-8ec4-993fef082c29 as the home volume
2021/04/18 01:05:20 Setting up Docker configuration...
2021/04/18 01:05:21 Successfully set up Docker configuration
2021/04/18 01:05:21 Logging in to registry: acr11501.azurecr.io
2021/04/18 01:05:22 Successfully logged into acr11501.azurecr.io
2021/04/18 01:05:22 Executing step ID: build. Timeout(sec): 28800, Working directory: '', Network: ''
2021/04/18 01:05:22 Scanning for dependencies...
2021/04/18 01:05:22 Successfully scanned dependencies
2021/04/18 01:05:22 Launching container with name: build
Sending build context to Docker daemon  1.627MB
Step 1/8 : FROM node:13.5-alpine
13.5-alpine: Pulling from library/node
e6b0cf9c0882: Pulling fs layer
ab436df1df6f: Pulling fs layer
470300a8a365: Pulling fs layer
84e7c11579ee: Pulling fs layer
84e7c11579ee: Waiting
e6b0cf9c0882: Verifying Checksum
e6b0cf9c0882: Download complete
e6b0cf9c0882: Pull complete
470300a8a365: Verifying Checksum
470300a8a365: Download complete
84e7c11579ee: Verifying Checksum
84e7c11579ee: Download complete
ab436df1df6f: Verifying Checksum
ab436df1df6f: Download complete
ab436df1df6f: Pull complete
470300a8a365: Pull complete
84e7c11579ee: Pull complete
Digest: sha256:a5a7ff4267a810a019c7c3732b3c463a892a61937d84ee952c34af2fb486058d
Status: Downloaded newer image for node:13.5-alpine
 ---> e1495e4ac50d
Step 2/8 : WORKDIR /usr/src/app
 ---> Running in e4a1790e8e02
Removing intermediate container e4a1790e8e02
 ---> a179d747c9ff
Step 3/8 : RUN apk update && apk add python g++ make && rm -rf /var/cache/apk/*
 ---> Running in 9e709b013f6d
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
v3.11.11-3-g6e25d786ba [http://dl-cdn.alpinelinux.org/alpine/v3.11/main]
v3.11.10-17-gbfbe1432e9 [http://dl-cdn.alpinelinux.org/alpine/v3.11/community]
OK: 11283 distinct packages available
(1/23) Upgrading musl (1.1.24-r0 -> 1.1.24-r3)
(2/23) Upgrading libstdc++ (9.2.0-r3 -> 9.3.0-r0)
(3/23) Installing binutils (2.33.1-r0)
(4/23) Installing gmp (6.1.2-r1)
(5/23) Installing isl (0.18-r0)
(6/23) Installing libgomp (9.3.0-r0)
(7/23) Installing libatomic (9.3.0-r0)
(8/23) Installing mpfr4 (4.0.2-r1)
(9/23) Installing mpc1 (1.1.0-r1)
(10/23) Installing gcc (9.3.0-r0)
(11/23) Installing musl-dev (1.1.24-r3)
(12/23) Installing libc-dev (0.7.2-r0)
(13/23) Installing g++ (9.3.0-r0)
(14/23) Installing make (4.2.1-r2)
(15/23) Installing libbz2 (1.0.8-r1)
(16/23) Installing expat (2.2.9-r1)
(17/23) Installing libffi (3.2.1-r6)
(18/23) Installing gdbm (1.13-r1)
(19/23) Installing ncurses-terminfo-base (6.1_p20200118-r4)
(20/23) Installing ncurses-libs (6.1_p20200118-r4)
(21/23) Installing readline (8.0.1-r0)
(22/23) Installing sqlite-libs (3.30.1-r2)
(23/23) Installing python2 (2.7.18-r0)
Executing busybox-1.31.1-r8.trigger
OK: 212 MiB in 37 packages
Removing intermediate container 9e709b013f6d
 ---> d463375a9ebe
Step 4/8 : COPY package*.json ./
 ---> e87248044440
Step 5/8 : RUN npm install
 ---> Running in aafd9a4a0143
 
<중략>
 
added 1152 packages from 681 contributors and audited 1222 packages in 183.695s
found 513 vulnerabilities (495 low, 7 moderate, 11 high)
  run `npm audit fix` to fix them, or `npm audit` for details
Removing intermediate container aafd9a4a0143
 ---> 115982084260
Step 6/8 : COPY . .
 ---> 65be874ab05e
Step 7/8 : EXPOSE 8080
 ---> Running in f74f691cbf63
Removing intermediate container f74f691cbf63
 ---> c3ad0d707697
Step 8/8 : CMD [ "npm", "start"]
 ---> Running in 5157b29f8b17
Removing intermediate container 5157b29f8b17
 ---> 3b041c4fe8b0
Successfully built 3b041c4fe8b0
Successfully tagged acr11501.azurecr.io/ratings-web:v1
2021/04/18 01:09:03 Successfully executed container: build
2021/04/18 01:09:03 Executing step ID: push. Timeout(sec): 3600, Working directory: '', Network: ''
2021/04/18 01:09:03 Pushing image: acr11501.azurecr.io/ratings-web:v1, attempt 1
The push refers to repository [acr11501.azurecr.io/ratings-web]
38c696cd649b: Preparing
6ca46424268f: Preparing
7adf6460d1d7: Preparing
6912849e30f1: Preparing
88a1464a800b: Preparing
efd6e0da275f: Preparing
b352b61d0fe4: Preparing
d06ff5e5272b: Preparing
6b27de954cca: Preparing
efd6e0da275f: Waiting
b352b61d0fe4: Waiting
d06ff5e5272b: Waiting
6b27de954cca: Waiting
88a1464a800b: Pushed
38c696cd649b: Pushed
7adf6460d1d7: Pushed
efd6e0da275f: Pushed
b352b61d0fe4: Pushed
6b27de954cca: Pushed
d06ff5e5272b: Pushed
6912849e30f1: Pushed
6ca46424268f: Pushed
v1: digest: sha256:a42d2f94e2219a1f56b749aabf49d2f8f0987dd2f4dc586eaeef98588c4c2b33 size: 2209
2021/04/18 01:09:32 Successfully pushed image: acr11501.azurecr.io/ratings-web:v1
2021/04/18 01:09:32 Step ID: build marked as successful (elapsed time in seconds: 221.063758)
2021/04/18 01:09:32 Populating digests for step ID: build...
2021/04/18 01:09:34 Successfully populated digests for step ID: build
2021/04/18 01:09:34 Step ID: push marked as successful (elapsed time in seconds: 29.396205)
2021/04/18 01:09:34 The following dependencies were found:
2021/04/18 01:09:34
- image:
    registry: acr11501.azurecr.io
    repository: ratings-web
    tag: v1
    digest: sha256:a42d2f94e2219a1f56b749aabf49d2f8f0987dd2f4dc586eaeef98588c4c2b33
  runtime-dependency:
    registry: registry.hub.docker.com
    repository: library/node
    tag: 13.5-alpine
    digest: sha256:a5a7ff4267a810a019c7c3732b3c463a892a61937d84ee952c34af2fb486058d
  git: {}
 
Run ID: de2 was successful after 4m16s

 

푸시된 이미지 레지스트리와 이름(예: acr11501.azurecr.io/ratings-web:v1)을 기록해 둔다. Kubernetes 배포를 구성할 때 이 정보를 사용한다.

 

 

 

이미지 확인

1. Cloud Shell에서 다음 명령을 실행하여 이미지가 만들어지고 레지스트리에 저장되었는지 확인한다.


az acr repository list \
--name $ACR_NAME \
--output table

 

이 명령의 출력은 다음 예제와 비슷하다.

kim@Azure:~/mslearn-aks-workshop-ratings-web$ az acr repository list \
> --name $ACR_NAME \
> --output table
Result
-----------
ratings-api
ratings-web

 

이제 이미지를 사용할 준비가 되었다.

 

 

 

컨테이너 레지스트리에 대해 인증할 AKS 클러스터 구성

서비스 간 통신을 허용하려면 컨테이너 레지스트리와 Kubernetes 클러스터 간에 인증을 설정해야 한다.

AKS_CLUSTER_NAME  ACR_NAME에 대해 유효한 값을 제공하여 컨테이너 레지스트리를 기존 AKS 클러스터와 통합해 보겠다. az aks update 명령을 실행하여 두 리소스 간에 필수 서비스 주체 인증을 자동으로 구성할 수 있다.

 

(이전 편에 이어 바로 실습을 진행하지 않고 새로 실습을 진행하는 경우 이전 실습에서 생성한 AKS 이름을 확인하여 AKS_CLUSTER_NAME 변수에 입력 후 진행한다.)

kim@Azure:~/mslearn-aks-workshop-ratings-web$ AKS_CLUSTER_NAME=aksworkshop-25918

 

다음 명령을 실행한다.


az aks update \
--name $AKS_CLUSTER_NAME \
--resource-group $RESOURCE_GROUP \
--attach-acr $ACR_NAME

 

kim@Azure:~$ az aks update \
> --name $AKS_CLUSTER_NAME \
> --resource-group $RESOURCE_GROUP \
> --attach-acr $ACR_NAME
{| Finished ..
  "aadProfile": null,
  "addonProfiles": null,
  "agentPoolProfiles": [
    {
      "availabilityZones": null,
      "count": 2,
      "enableAutoScaling": null,
      "enableEncryptionAtHost": null,
      "enableNodePublicIp": false,
      "kubeletConfig": null,
      "kubeletDiskType": "OS",
      "linuxOsConfig": null,
      "maxCount": null,
      "maxPods": 30,
      "minCount": null,
      "mode": "System",
      "name": "nodepool1",
      "nodeImageVersion": "AKSUbuntu-1804gen2containerd-2021.03.29",
      "nodeLabels": {},
      "nodePublicIpPrefixId": null,
      "nodeTaints": null,
      "orchestratorVersion": "1.19.7",
      "osDiskSizeGb": 128,
      "osDiskType": "Managed",
      "osType": "Linux",
      "podSubnetId": null,
      "powerState": {
        "code": "Running"
      },
      "provisioningState": "Succeeded",
      "proximityPlacementGroupId": null,
      "scaleSetEvictionPolicy": null,
      "scaleSetPriority": null,
      "spotMaxPrice": null,
      "tags": null,
      "type": "VirtualMachineScaleSets",
      "upgradeSettings": null,
      "vmSize": "Standard_DS2_v2",
      "vnetSubnetId": "/subscriptions/1199b626-xxxx-xxxx-xxxx-cabaxxxxee88/resourceGroups/aksworkshop/providers/Microsoft.Network/virtualNetworks/aks-vnet/subnets/aks-subnet"
    }
  ],
  "apiServerAccessProfile": null,
  "autoScalerProfile": null,
  "autoUpgradeProfile": null,
  "azurePortalFqdn": "aksworksho-aksworkshop-1199b6-9c9e685c.portal.hcp.koreacentral.azmk8s.io",
  "diskEncryptionSetId": null,
  "dnsPrefix": "aksworksho-aksworkshop-1199b6",
  "enablePodSecurityPolicy": null,
  "enableRbac": true,
  "fqdn": "aksworksho-aksworkshop-1199b6-9c9e685c.hcp.koreacentral.azmk8s.io",
  "fqdnSubdomain": null,
  "id": "/subscriptions/1199b626-xxxx-xxxx-xxxx-cabaxxxxee88/resourcegroups/aksworkshop/providers/Microsoft.ContainerService/managedClusters/aksworkshop-25918",
  "identity": {
    "principalId": "6b18b894-9dbd-4c63-bcd7-aa6f48ad02c6",
    "tenantId": "917bfe84-0ca6-488d-ad3a-236e41ceafe9",
    "type": "SystemAssigned",
    "userAssignedIdentities": null
  },
  "identityProfile": {
    "kubeletidentity": {
      "clientId": "29e95bec-6b16-4b98-a87e-8d9661ddd1c8",
      "objectId": "96403de2-52b8-4350-9a3c-dc1e747dc817",
      "resourceId": "/subscriptions/1199b626-xxxx-xxxx-xxxx-cabaxxxxee88/resourcegroups/MC_aksworkshop_aksworkshop-25918_koreacentral/providers/Microsoft.ManagedIdentity/userAssignedIdentities/aksworkshop-25918-agentpool"
    }
  },
  "kubernetesVersion": "1.19.7",
  "linuxProfile": {
    "adminUsername": "azureuser",
    "ssh": {
      "publicKeys": [
        {
          "keyData": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDNv2eLCX5Bkdn3zt0uG3CfL6hWaM5feriY4K8qTDrO64jOAPRyFrKgfrZKP7f85SAaK5QDoM//5niYYHMqoV8n0+x4qsXfYrODzly4z7TLocHJl/Osb1lxCxdgx64HZYWhVXmRarfJ0ffDOhAhUIKcpKIf2HR9YmMdbj4UYT2YTYUCR7AE8QsD2hzr53fHc7TSxIGe8tFGJ+N+dumqT/y8XKDK9VDWN1h8tt+MuHYB4JWrKsA8NqIdNFrgqAzNDxLX7XHwDV7GsBKkz5CcZmQpD4Hq2LjL+EeQf7WFxokpsXJRnoX74y4ozeVggXnEAOfTzD5jXel+L39zn+xJIK8D kim@cc-80381d60-cbc8669fb-s87xb\n"
        }
      ]
    }
  },
  "location": "koreacentral",
  "maxAgentPools": 10,
  "name": "aksworkshop-25918",
  "networkProfile": {
    "dnsServiceIp": "10.2.0.10",
    "dockerBridgeCidr": "172.17.0.1/16",
    "loadBalancerProfile": {
      "allocatedOutboundPorts": null,
      "effectiveOutboundIps": [
        {
          "id": "/subscriptions/1199b626-xxxx-xxxx-xxxx-cabaxxxxee88/resourceGroups/MC_aksworkshop_aksworkshop-25918_koreacentral/providers/Microsoft.Network/publicIPAddresses/d7853cb1-46d1-43ef-8f78-be8c6fb3426e",
          "resourceGroup": "MC_aksworkshop_aksworkshop-25918_koreacentral"
        }
      ],
      "idleTimeoutInMinutes": null,
      "managedOutboundIps": {
        "count": 1
      },
      "outboundIpPrefixes": null,
      "outboundIps": null
    },
    "loadBalancerSku": "Standard",
    "networkMode": null,
    "networkPlugin": "azure",
    "networkPolicy": null,
    "outboundType": "loadBalancer",
    "podCidr": null,
    "serviceCidr": "10.2.0.0/24"
  },
  "nodeResourceGroup": "MC_aksworkshop_aksworkshop-25918_koreacentral",
  "podIdentityProfile": null,
  "powerState": {
    "code": "Running"
  },
  "privateFqdn": null,
  "provisioningState": "Succeeded",
  "resourceGroup": "aksworkshop",
  "servicePrincipalProfile": {
    "clientId": "msi",
    "secret": null
  },
  "sku": {
    "name": "Basic",
    "tier": "Free"
  },
  "tags": null,
  "type": "Microsoft.ContainerService/ManagedClusters",
  "windowsProfile": {
    "adminPassword": null,
    "adminUsername": "azureuser",
    "enableCSIProxy": true,
    "licenseType": null
  }
}

 

 

 

요약

이 연습에서는 Fruit Smoothies 애플리케이션에 대한 컨테이너 레지스트리를 만들었다. 그런 다음, ratings-api  ratings-web에 대한 컨테이너 이미지를 작성하고 컨테이너 레지스트리에 추가했다. 그런 다음, 컨테이너 이미지를 확인하고 컨테이너 레지스트리를 인증하도록 AKS 클러스터를 구성했다.

다음으로, 평가 앱을 배포하는 첫 단계를 수행한다. 배포할 첫 번째 구성 요소는 문서 저장 데이터베이스인 MongoDB이며, Kubernetes용 Helm 패키지 관리자를 사용하는 방법을 알아본다.

 

 

4편에서 계속

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
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
글 보관함