이번 실습에서는 aws-cli대신에 ecs에 특화된 ecs-cli를 사용해야 합니다.
# ecs-cli 설치
$sudo curl -Lo /usr/local/bin/ecs-cli https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-linux-amd64-latest
그다음에는 이제 ecs상에서 해커들의 공격과 같은것을 막기 위해, 권한을 설정해 주는 곳이 있습니다. 이를 하기 위해서는 gnupg를 깔고 public key를 놓아야 합니다. 이 과정을 진행해 보도록 하겠습니다.
$sudo apt-get install
$cd keys
$vim amazon-ecs-public-key.gpg
/amazon-ecs-public-key.gpg
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2
mQINBFq1SasBEADliGcT1NVJ1ydfN8DqebYYe9ne3dt6jqKFmKowLmm6LLGJe7HU
jGtqhCWRDkN+qPpHqdArRgDZAtn2pXY5fEipHgar4CP8QgRnRMO2fl74lmavr4Vg
7K/KH8VHlq2uRw32/B94XLEgRbGTMdWFdKuxoPCttBQaMj3LGn6Pe+6xVWRkChQu
BoQAhjBQ+bEm0kNy0LjNgjNlnL3UMAG56t8E3LANIgGgEnpNsB1UwfWluPoGZoTx
N+6pHBJrKIL/1v/ETU4FXpYw2zvhWNahxeNRnoYj3uycHkeliCrw4kj0+skizBgO
2K7oVX8Oc3j5+ZilhL/qDLXmUCb2az5cMM1mOoF8EKX5HaNuq1KfwJxqXE6NNIcO
lFTrT7QwD5fMNld3FanLgv/ZnIrsSaqJOL6zRSq8O4LN1OWBVbndExk2Kr+5kFxn
5lBPgfPgRj5hQ+KTHMa9Y8Z7yUc64BJiN6F9Nl7FJuSsfqbdkvRLsQRbcBG9qxX3
rJAEhieJzVMEUNl+EgeCkxj5xuSkNU7zw2c3hQZqEcrADLV+hvFJktOz9Gm6xzbq
lTnWWCz4xrIWtuEBA2qE+MlDheVd78a3gIsEaSTfQq0osYXaQbvlnSWOoc1y/5Zb
zizHTJIhLtUyls9WisP2s0emeHZicVMfW61EgPrJAiupgc7kyZvFt4YwfwARAQAB
tCRBbWF6b24gR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K0avpFzUtbJd24lRA3WJpkEiMqKv
RDVZkE4b6TW61f0o+LaVfK6E8oLpixegS4fiqC16mFrOdyRk+RJJfIUyz0WTDVmt
g0U1CO1ezokMSqkJ7724pyjr2xf/r9/sC6aOJwB/lKgZkJfC6NqL7TlxVA31dUga
LEOvEJTTE4gl+tYtfsCDvALCtqL0jduSkUo+RXcBItmXhA+tShW0pbS2Rtx/ixua
KohVD/0R4QxiSwQmICNtm9mw9ydIl1yjYXX5a9x4wMJracNY/LBybJPFnZnT4dYR
z4XjqysDwvvYZByaWoIe3QxjX84V6MlI2IdAT/xImu8gbaCI8tmyfpIrLnPKiR9D
VFYfGBXuAX7+HgPPSFtrHQONCALxxzlbNpS+zxt9r0MiLgcLyspWxSdmoYGZ6nQP
RO5Nm/ZVS+u2imPCRzNUZEMa+dlE6kHx0rS0dPiuJ4O7NtPeYDKkoQtNagspsDvh
cK7CSqAiKMq06UBTxqlTSRkm62eOCtcs3p3OeHu5GRZF1uzTET0ZxYkaPgdrQknx
ozjP5mC7X+45lcCfmcVt94TFNL5HwEUVJpmOgmzILCI8yoDTWzloo+i+fPFsXX4f
kynhE83mSEcr5VHFYrTY3mQXGmNJ3bCLuc/jq7ysGq69xiKmTlUeXFm+aojcRO5i
zyShIRJZ0GZfuzDYFDbMV9amA/YQGygLw//zP5ju5SW26dNxlf3MdFQE5JJ86rn9
MgZ4gcpazHEVUsbZsgkLizRp9imUiH8ymLqAXnfRGlU/LpNSefnvDFTtEIRcpOHc
bhayG0bk51Bd4mioOXnIsKy4j63nJXA27x5EVVHQ1sYRN8Ny4Fdr2tMAmj2O+X+J
qX2yy/UX5nSPU492e2CdZ1UhoU0SRFY3bxKHKB7SDbVeav+K5g==
=Gi5D
-----END PGP PUBLIC KEY BLOCK-----
$curl -Lo ecs-cli.asc https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-linux-amd64-latest.asc
$gpg --verify ecs-cli.asc /usr/local/bin/ecs-cli
$sudo chmod +x /usr/local/bin/ecs-cli
$ecs-cli --version
# ecs-cli version 1.21.0 (bb0b8f0)
이정도 하면 ecs-cli의 설치는 완료된 것입니다. 다음으로는 ecr에다 이전에 만든 django, nginx이미지를 올리기 위해서 aws-cli를 사용해 보도록 하겠습니다.
$sudo apt-get install awscli
$aws configure
$aws ecr get-login --no-include-email --region ap-northeast-2
$docker login -u AWS -p eyJwYXlsb2FkIjoiWDJhVmVMMHI5bGswVXB6NENZZkxmM3B4Nko2SVN5MnN3UGUvVk5jZDNtYlBDNUVISEM1OEpMa2RMMUNHRk9iZkFWS3NnSHowNDhUb1lsS3A0MzFnSjJCUVBRQklBWEQxZ3pEZVJhMm9TM0UzcFFSS3o2dk1nMFNlRS9JSWFyUjBHQllySU14dDNONXZPQ2FpMzErVjdzTzhWWlVKZDdmcWdvSTJuVmpEWE4ydnF1RkpER2xuMUxrQzMySmJ3eENES0FhQ3NJUlZNdGtjMkRERU9Mc3A2K3ZsanpmSTFOckt0R0o3SVFJWHBYQnMvT1BpSVVYRzhqNjNTT0l4OGVNVHl3bTFpNTlBVzRIQkRveUJnN1d5d2d3WjZkMDZoOE1MVjI1N1BzOE1TdEdBQVpGbko0a2c1NDhNRWQ1MlNFWVB6L3p5OUdTNDJOaDN6d25ZU2xxZ3hqZFl5Yk9wOHc5ajlKVVdsLzFDdmdIRlMrb3orRm1ISU83Sm9VYWNONVV2S0t6TnVLMzU3MmdXeS9RY1h1cTY5R2I3MDlhV2VEdU56aHpGdWZaWWlKNlNVQWhHNlBMMWNmbzB1ZjhEZlMrTnRvOCtZbFYzYy83cGtkT3ZDQzBvN3lydmtPNE9wWmtGVVo2bWJsa1F0SHo1ZThCRHdWSW9vT29mbWRJd3pJaTM4YnB4OTY3anpkM1ZsRTI2TC9oMC8yREdDZ25pc0VGVTUxdHBTTzBNU1BCRUxma2xkMTlwTURvQ2lJSzBJUUdjTzJscHd0NXVNby84c0F5VG8zcWFDSHJ1bkRVU01vNTVSaWV1RnM5STk5MkVDdHhDa2hDQmkvd2hM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$docker-compose up -d --build
그 다음에는 이제 ecr에 레포지토리를 만들고 태깅하고 올려보도록 하겠습니다
이에 맞는 cli-compose-django, cli-compose-nginx이라는 두 레포지토리를 만들어 주었습니다.
# docker-django/django 이미지 배포
$docker tag docker-django/django 154309361967.dkr.ecr.ap-northeast-2.amazonaws.com/cli-compose-django
$docker push 154309361967.dkr.ecr.ap-northeast-2.amazonaws.com/cli-compose-django
이와 동일하게 nginx이미지도 배포하겠습니다.
# docker-django/nginx 이미지 배포
$docker tag docker-django/nginx 154309361967.dkr.ecr.ap-northeast-2.amazonaws.com/cli-compose-nginx
$docker push 154309361967.dkr.ecr.ap-northeast-2.amazonaws.com/cli-compose-nginx
그다음에는 권한을 설정해 주겠습니다.
# iam 사용자의 ecs권한을 부여해 준다.
$aws iam attach-role-policy \
--role-name ecsTaskExecutionRole \
--policy-arn arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy
그 다음에는 빈 클러스터를 하나 만들어 주겠습니다.
# cli-cluster라는 빈 클러스터를 만든다.
$ecs-cli up --empty --cluster cli-cluster
그다음에 ecs-cli구성을 시작하도록 하겠습니다.
# 기본 코드
$ecs-cli configure profile --profile-name profile_name --access-key $AWS_ACCESS_KEY_ID --secret-key $AWS_SECRET_ACCESS_KEY
# 내 환경
$ecs-cli configure profile --profile-name hyunseo --access-key AKIASH3MOAEX5U3DG7GE --secret-key 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
# 사용자 설정
$ecs-cli configure profile default --profile-name hyunseo
이 외에도 hyunseo2이라는 프로필을 만드는 것은 상관없습니다. 그리고 저는 그 중 hyunseo를 기본 사용자로 설정해 놓겠습니다.
그다음으로는 ecs-cli를 누가 사용하고 있는지 설정하고 있는 거였다면, 이번에는 어떤 cluster를 사용할 것인지에 대한 설정입니다.
# 기본 코드
$ecs-cli configure --cluster cluster_name --default-launch-type launch_type --region region_name --config-name configuration_name
# 내 환경
$ecs-cli configure --cluster cli-cluster --default-launch-type FARGATE --region ap-northeast-2 --config-name cli-config
# 설정 등록
$ecs-cli configure default --config-name cli-config
이에 대한 설정의 집합을 cli-configure로 설정해 두었습니다. 이는 언제든지 바꿀 수 있습니다. 그리고 --default-launch-type은 당연히 FARGATE로 하고 위에서 만든 빈 클러스처인 cli-cluster를 대상 클러스터로 지정해 주었습니다.
다음으로는 docker-server로 들어가서 docker-compose.yml을 앞에서 말했던 대로 조금 수정해 주도록 하겠습니다.
/docker-compose.yml ( 수정 버전 )
version: '3'
services:
nginx:
image: 154309361967.dkr.ecr.ap-northeast-2.amazonaws.com/cli-compose-nginx:latest
ports:
- "80:80"
volumes:
- /srv/docker-django
- /var/log/nginx
django:
image: 154309361967.dkr.ecr.ap-northeast-2.amazonaws.com/cli-compose-django:latest
command: uwsgi --ini uwsgi.ini
volumes:
- /srv/docker-django
- /var/log/uwsgi
원래는 image에는 폴더를 적어 주었는데, 여기에서는 이미지가 저장되어 있는 레포지토리 URI를 적어 주었습니다. 또한 원래 container_name, build옵션은 없어도 되는데, 불안하니까 그냥 넣어 주었습니다. 또한 volumnes앞에 원래 폴더 값이 있었지만 이를 싹다 지워 주었습니다.
그 다음에는 이제docker를 compose하기 위한 parameter를 정의한 ecs-params.yml을 적어주겠습니다.
/ecs-params.yml ( 수정 버전 )
version: 1
task_definition:
task_execution_role: ecsTaskExecutionRole
ecs_network_mode: awsvpc
task_size:
mem_limit: 0.5GB
cpu_limit: 256
services:
django:
essential: true
nginx:
essential: true
depends_on:
- container_name: "django"
run_params:
network_configuration:
awsvpc_configuration:
subnets:
- "subnet-0b4587f0ed8afde31"
- "subnet-06e9ee302a0c6bc11"
security_groups:
- "sg-0fadc624a81cff9aa"
assign_public_ip: ENABLED
이제 이를 바탕으로 서비스를 만들고 직접 작업을 실행해서 컨테이너를 구동시켜 보도록 하겠습니다.
$ecs-cli compose --file docker-compose.yml --ecs-params ecs-params.yml service create --launch-type FARGATE
$ecs-cli compose --file docker-compose.yml service start
작업의 Public IP의 80번 포트로 들어가시면 정상적으로 서비스가 배포된 것을 확인할 수 있으실 겁니다.
모든 실습이 완료되었습니다!