๐ŸŒฑ Infra/Container_AWS_ECS

ECS ๊ธฐ์ดˆ, ๊ฐœ๋…์žก๊ธฐ ๐Ÿ‘๐Ÿป๐Ÿ‘๐Ÿป๐Ÿ‘๐Ÿป

mini_world 2021. 9. 1. 18:47
๋ชฉ์ฐจ ์ ‘๊ธฐ

 

์•ˆ๋…•ํ•˜์„ธ์š” ๐Ÿ˜Š๐Ÿ˜Š๐Ÿ˜Š๐Ÿ˜Š

์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” ECS์— ๋Œ€ํ•ด ์กฐ๊ธˆ ๋‹ค๋ค„๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

์ •๋ง ๋‹ค์–‘ํ•œ ์ปจํ…Œ์ด๋„ˆ ์˜ค์ผ€์ด์ŠคํŠธ๋ ˆ์ด์…˜ ํˆด์ด ์กด์žฌํ•˜๊ณ , ์ตœ๊ทผ์—๋Š” Kubernetes(k8s)๊ฐ€ ๊ฑฐ์˜ ๋ฉ”์ธ ์ŠคํŠธ๋ฆผ์ธ๋ฐ์š”,
AWS์—๋„ EKS๋ผ๋Š” ๊ด€๋ฆฌํ˜• ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ์„œ๋น„์Šค๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.
ํ•˜์ง€๋งŒ, AWS๋Š” EKS๋ณด๋‹ค ECS(Amazon Elastic Container Service)๋ฅผ ๋” ๋ฐ€๊ณ ์žˆ๋Š”๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

์•„๋ฌดํŠผ! ์ง€๊ธˆ๋ถ€ํ„ฐ ECS์— ๋Œ€ํ•ด ์•Œ์•„๋ด…์‹œ๋‹ค!!

 


ECS๋Š” ๋‹ค๋ฅธ ์˜ค์ผ€์ŠคํŠธ๋ ˆ์ด์…˜ ํˆด์— ๋น„ํ•ด  ์–ด๋–ค ์žฅ์ ์ด ์žˆ์„๊นŒ์š”?

1. ๊ฐœ๋…์ด ์ •๋ง ๊ฐ„๋‹จํ•˜๊ณ , (์ฟ ๋ฒ„๋„คํ‹ฐ์Šค๋ณด๋‹ค ์ดํ•ดํ•˜๊ธฐ ํ›จ์”ฌ ์‰ฝ์Šต๋‹ˆ๋‹ค.)
2. ๋‹ค๋ฅธ AWS์„œ๋น„์Šค์™€ ํ†ตํ•ฉ์ด ๊ฐ„ํŽธํ•˜๊ณ , (์˜ˆ์ œ๋„ ์ •๋ง ๋งŽ์Šต๋‹ˆ๋‹ค.)
3. aws Copilot ๊ณผ ๊ฐ™์€ ECS๋ฅผ ์œ„ํ•œ ์ „์šฉ CLI๊ฐ€ ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.

๋ฌผ๋ก , AWS์—์„œ ์‚ฌ์šฉํ•˜๊ธฐ ๊ธฐ์ค€์ด๊ฒ ์ฃ ! ๐Ÿ˜

 


ECS  EC2? Fargate? External?  ์—ฌ๋Ÿฌ๊ฐ€์ง€๊ฐ€ ์žˆ๋˜๋ฐ.... ๋ญ๊ฐ€ ๋‹ค๋ฅธ๊ฐ€์š”?

ECS๋Š” ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์šด์˜ํ•˜๋Š” ํ˜ธ์ŠคํŠธ ํ˜•ํƒœ์— ๋”ฐ๋ผ EC2, Fargate, External ๋กœ ๋‚˜๋ˆ ์ง‘๋‹ˆ๋‹ค. 
์ฆ‰, ์–ด๋””์—์„œ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋„์šธ๊ฑด์ง€์— ๋Œ€ํ•œ ์ •์˜ ์ž…๋‹ˆ๋‹ค. ์ดํ•ดํ•˜๊ธฐ ์‰ฝ๋„๋ก ์•„๋ž˜ ๊ทธ๋ฆผ์„ ๋ด…์‹œ๋‹ค

ECS ํ˜ธ์ŠคํŠธ ์œ ํ˜• 1) EC2

๊ธฐ๋ณธ ์œ ํ˜•์ธ EC2 ์œ ํ˜•์ž…๋‹ˆ๋‹ค. ์ฆ‰, ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์šด์˜๋˜๋Š” ์ปดํ“จํ„ฐ๊ฐ€ AWS EC2์ธ ํƒ€์ž… ์ž…๋‹ˆ๋‹ค.
์šฉ๋Ÿ‰๊ณต๊ธ‰์ž(Capacity Providers)๋ฅผ ํ†ตํ•ด EC2 Auto-ScalingGroup์„ ์—ฐ๊ฒฐํ•ฉ๋‹ˆ๋‹ค. 
ECS์—์„œ ์ œ๊ณตํ•˜๋Š” ๊ด€๋ฆฌํ˜• ์ง€ํ‘œ "CapacityProviderReservation"์— ๋”ฐ๋ผ EC2๋ฅผ ์šฉ๋Ÿ‰์„ ์ถ”๊ฐ€/์ œ๊ฑฐ ํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ,
์ปจํ…Œ์ด๋„ˆ์˜ ์ˆซ์ž์˜ ์ฆ๊ฐ€/์ถ•์†Œ์— ๋”ฐ๋ผ EC2๋„ ํ•จ๊ป˜ ์ฆ๊ฐ€/์ถ•์†Œํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. 
* EC2 ์œ ํ˜• ๋น„์šฉ: ํ˜ธ์ŠคํŠธ๋กœ ์‚ฌ์šฉํ•˜๋Š” EC2 ์š”๊ธˆ๋งŒ ๊ณผ๊ธˆ๋ฉ๋‹ˆ๋‹ค. 

ECS ํ˜ธ์ŠคํŠธ ์œ ํ˜• 2) Fargate

Fargate๋Š” ์„œ๋ฒ„๋ฆฌ์Šค ์œ ํ˜•์œผ๋กœ, EC2๋ฅผ ๋ฐฐํฌํ•˜๊ฑฐ๋‚˜ ๊ด€๋ฆฌํ•  ํ•„์š” ์—†์ด ๊ทธ๋ƒฅ ์„œ๋น„์Šค๋งŒ ์šด์˜ํ•˜๋ฉด ๋˜๋Š” ์œ ํ˜• ์ž…๋‹ˆ๋‹ค.
์ฆ‰, ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์–ด๋””์„œ ์šด์˜๋˜๋Š”์ง€ ๊ณ ๋ฏผ/๊ด€๋ฆฌํ•  ํ•„์š” ์—†๋Š” ํƒ€์ž… ์ž…๋‹ˆ๋‹ค.
ํ•œ๊ฐ€์ง€ ๋ฌธ์ œ์ ์€ EC2์™€ ๋น„๊ตํ–ˆ์„๋•Œ ๋น„์‹ธ๋‹ค๋Š”๊ฒƒ์ž…๋‹ˆ๋‹ค ใ…Žใ…Ž
๊ทธ๋ž˜๋„ Savings Plan ๋“ฑ์„ ํ†ตํ•ด ์š”๊ธˆ์„ ํ• ์ธ๋ฐ›์„ ์ˆ˜ ์žˆ๊ณ , EC2์— ๋Œ€ํ•œ ๊ด€๋ฆฌ๊ฐ€ ํ•„์š”์—†์œผ๋‹ˆ ์žฅ์ ๋„ ํฐ๊ฒƒ๊ฐ™์Šต๋‹ˆ๋‹ค.๐Ÿ˜
* Fargate ์œ ํ˜• ๋น„์šฉ: ์‹œ๊ฐ„๋‹น vCPU, Storage ์šฉ๋Ÿ‰ ๋น„์šฉ์ด ๋ถ€๊ณผ๋ฉ๋‹ˆ๋‹ค. Fargate ์š”๊ธˆ

ECS ํ˜ธ์ŠคํŠธ ์œ ํ˜• 3) External (ECS AnyWhere)

๋งˆ์ง€๋ง‰ ์œ ํ˜•์ธ๋ฐ์š”, Exrernal ์ธ์Šคํ„ด์Šค ํƒ€์ž…์ž…๋‹ˆ๋‹ค. ์ด ์œ ํ˜•์€ AWS์ธํ”„๋ผ๊ฐ€ ์•„๋‹Œ ๊ณณ์— ์œ„์น˜ํ•œ ํ˜ธ์ŠคํŠธ์—์„œ๋„ ECS์—์„œ ์ •์˜ํ•œ ์„œ๋น„์Šค, ์ž‘์—…์„ ์‹คํ•ผ ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.
์ฆ‰, ํ˜ธ์ŠคํŠธ&์ปจํ…Œ์ด๋„ˆ ๋“ฑ ์‹ค์ œ ์„œ๋น„์Šค๋Š” ๋ฌผ๋ฆฌ์ ์œผ๋กœ AWS๋ฐ–์—์„œ ๋™์ž‘ํ•˜์ง€๋งŒ, ๊ด€๋ฆฌ๋Š” AWS์ฝ˜์†”์—์„œ ํ•  ์ˆ˜ ์žˆ๋Š” ํƒ€์ž… ์ž…๋‹ˆ๋‹ค. 
๋‹ค๋ฅธ ๋ฐ์ดํ„ฐ์„ผํ„ฐ์™€ ํ•จ๊ป˜ AWS๋ฅผ ์šด์˜์ค‘ํ•ด์•ผํ•˜๋Š” ํ•˜์ด๋ธŒ๋ฆฌ๋“œ ํ™˜๊ฒฝ์— ์ ํ•ฉํ•œ ์˜ต์…˜์ด ๋ ๊ฑฐ๊ฐ™๋„ค์š”. 
๋‹จ, ํ˜ธ์ŠคํŠธ์—๋Š” ECS Agnet, SSM Agent ๊ฐ€ ์„ค์น˜ ๋˜์–ด์•ผ ํ•˜๋ฉฐ, ์ธํ„ฐ๋„ท์—ฐ๊ฒฐ์ด ์•ˆ์ •์ ์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
* External ์œ ํ˜• ๋น„์šฉ: ๊ธฑ External ์ธ์Šคํ„ด์Šค๋งˆ๋‹ค ์‹œ๊ฐ„๋‹น 0.01025USD ๋น„์šฉ์ด ๋ถ€๊ณผ๋ฉ๋‹ˆ๋‹ค. External ์š”๊ธˆ

 


ECS๋Š” ๋ฌด์—‡์œผ๋กœ ๊ตฌ์„ฑ๋˜๋‚˜์š”?

์ œ๊ฐ€ ์ƒ๊ฐํ–ˆ์„๋•Œ.. ECS์˜ ํ•ต์‹ฌ ๊ตฌ์„ฑ์š”์†Œ(์ปดํฌ๋„ŒํŠธ)๋Š”, ์ž‘์—…์ •์˜ & ์„œ๋น„์Šค ์ž…๋‹ˆ๋‹ค. (ECS๊ณต์‹๋ฌธ์„œ)

์ž‘์—…์ •์˜ ํ›„ ์„œ๋น„์Šค๋งŒ ์ž˜ ์ƒ์„ฑํ•ด๋„ ์ปจํ…Œ์ด๋„ˆ ์šด์˜์ด ๊ฐ€๋Šฅํ•˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ๐Ÿค—
์•„๋ž˜ ๊ทธ๋ฆผ์„ ๋ณด๋ฉด์„œ ์ž์„ธํžˆ ํ™•์ธํ•ด๋ณผ๊นŒ์š”?

ECS๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๊ฐ€์žฅ๋จผ์ €, ์ž‘์—…์ •์˜(Task Definition)์„ ์ƒ์„ฑํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค.
์ž‘์—… ์ •์˜๋ž€, ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์„ค๋ช…ํ•˜๋Š” Json ํŒŒ์ผ์ž…๋‹ˆ๋‹ค. ์ •์˜ํ•  ์ˆ˜ ์žˆ๋Š” ๋‚ด์šฉ์€ ์•„์ฃผ ๋งŽ์Šต๋‹ˆ๋‹ค.
(Task ๋„คํŠธ์›Œํฌ ๋ชจ๋“œ(Bridge, Host, awsvpc, None)/ ์ปจํ…Œ์ด๋„ˆ ์ด๋ฏธ์ง€/ ์ปจํ…Œ์ด๋„ˆ์— ํ• ๋‹น ๋  ๋ฆฌ์†Œ์Šค(vCPU/MEM) ๋“ฑ..)

์ž‘์—…์ •์˜๋ฅผ ์ƒ์„ฑํ–ˆ๋‹ค๋ฉด, ์ˆœ์„œ๋Œ€๋กœ ECS Cluster, ECS Service๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
• ECS Cluster : ๋„คํŠธ์›Œํฌ ๊ตฌ์„ฑ ๋ฐ OS๋ฅผ ์ •์˜ํ•˜๋Š” ๋‹จ๊ณ„์ž…๋‹ˆ๋‹ค. (์–ด๋–ค VPC๋ฅผ ์‚ฌ์šฉํ• ์ง€, ์–ด๋–ค OS๋ฅผ ์‚ฌ์šฉํ• ์ง€ (Windows / Linux ))
• ECS Service : ์•ž์„œ ๋งŒ๋“ค์–ด๋†“์€ ์ž‘์—…์ •์˜(Task Definition)์„ ์—ฐ๊ฒฐํ•˜๊ณ , Task ์ˆ˜๋Ÿ‰, Auto-Scaling ์—ฌ๋ถ€ ๋“ฑ์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

 


ECS๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์‹ถ์–ด์š”, ์–ด๋–ค ์ˆœ์„œ๋กœ ํ•˜๋‚˜์š”?

์•„๋ž˜์˜ ๊ทธ๋ฆผ ์ˆœ์„œ๋Œ€๋กœ ์ง„ํ–‰ํ•˜์—ฌ ECS์„œ๋น„์Šค๋ฅผ ๊ฐ„๋‹จํžˆ ํ…Œ์ŠคํŠธ ํ•ด๋ณผ ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

์‹คํ–‰ํ•˜๋Š” ์ˆœ์„œ๋Š” ๋ฐฑ๋ฌธ์ด๋ถˆ์—ฌ์ผ๊ฒฌ! ํ•œ๋ฒˆ ECS๋ฅผ ์ง์ ‘ ๊ตฌ์„ฑํ•ด๋ณด์‹œ๋Š”๊ฒƒ์„ ๊ถŒ์žฅ ๋“œ๋ฆฝ๋‹ˆ๋‹ค!!!
Hands-On ํ•ด๋ณผ ์ˆ˜ ์žˆ๋„๋ก ๋ช‡๊ฐœ ๋งํฌ ํ•จ๊ป˜ ๋‚จ๊น๋‹ˆ๋‹ค. ๐ŸŽ‰ ํ™”์ดํŒ…!! ๐Ÿ‘๐Ÿป

1) CI/CD WORKSHOP FOR AMAZON ECS : https://cicd-for-ecs.workshop.aws/en/

 

CI/CD workshop for Amazon ECS

CI/CD workshop for Amazon ECS Welcome to the CI/CD Workshop for Amazon ECS! In this workshop, we will use AWS CI/CD tools to implement a number of pipeline patterns that you can use to develop and deploy your Amazon ECS workloads.

cicd-for-ecs.workshop.aws

2) DEMOGO - CATS AND DOGS : https://ecs-cats-dogs.workshop.aws/en/

 

DemoGo - Amazon ECS Cats and Dogs

DemoGo - Cats and Dogs Searching for Love and Happiness This workshop is designed to educate engineers that might not be familiar with Amazon ECS, Fargate, and possibly even Docker container workflow. Amazon ECS Amazon Elastic Container Service (Amazon ECS

ecs-cats-dogs.workshop.aws

3) Building your first DevOps Blue/Green pipeline with Amazon ECS : https://catalog.us-east-1.prod.workshops.aws/v2/workshops/4b59b9fb-48b6-461c-9377-907b2e33c9df/en-US

 

Workshop Studio

 

catalog.us-east-1.prod.workshops.aws

 

 

 

728x90