๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ’Ž/DevOps

[DevOps] DevOps์˜ ์ดํ•ด

by dar0m! 2021. 7. 29.
'DevOps : Infrastructure as Code with ํ…Œ๋ผํผ(Terraform) and AWS ์ดˆ๊ธ‰, ์ž…๋ฌธํŽธ'์„ ๋ณด๊ณ  ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค.

 

DevOps : Infrastructure as Code with ํ…Œ๋ผํผ(Terraform) and AWS ์ดˆ๊ธ‰, ์ž…๋ฌธํŽธ - ์ธํ”„๋Ÿฐ | ๊ฐ•์˜

์ด ๊ฐ•์˜๋Š” DevOps์˜ ๊ธฐ๋ณธ ์ด๋ก ๊ณผ ํ•จ๊ป˜ DevOps์˜ ๊ธฐ๋ณธ ์ค‘ ํ•˜๋‚˜์ธ Infrastructure as Code(IaC)์— ๋Œ€ํ•ด ๋ฐฐ์šธ ์ˆ˜ ์žˆ๋Š” ๊ฐ•์˜์ž…๋‹ˆ๋‹ค. ๋ณธ ๊ฐ•์˜๋ฅผ ํ†ตํ•ด IT๊ธฐ๋ฐ˜์˜ ์„œ๋น„์Šค๋ฅผ DevOps๊ด€์ ์—์„œ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ดํ•ดํ•˜๊ณ , ์„œ๋น„์Šค

www.inflearn.com

 

1. DevOps์˜ ์ดํ•ด

๊ฐœ๋…

๋ฐ๋ธŒ์˜ต์Šค๋Š” ํ•ฉ์„ฑ์–ด : ์†Œํ”„ํŠธ์›จ์–ด ๊ฐœ๋ฐœ(Development) + ์šด์˜(Operations

ํ˜„์žฌ๋Š” ๋‹จ์ˆœํžˆ ๊ฐœ๋ฐœ๊ณผ ์šด์˜์˜ ํ†ตํ•ฉ์€ ์•„๋‹ˆ๊ณ , ๊ฐœ๋ฐœํŒ€๊ณผ ์šด์˜ํŒ€์˜ ๊ฐ„๊ทน์„ ์ค„์—ฌ๋‚˜๊ฐ€๊ณ ์ž ํ•˜๋Š” ๊ฒƒ์ด ๋ฐœ์ „ํ•˜์—ฌ ์†Œํ”„ํŠธ์›จ์–ด ๊ฐœ๋ฐœ๊ณผ ์šฐ๋ฆฌ์˜ ์ผ์— ๊ด€ํ•œ ํฌ๊ด„์ ์ธ ์ฒ ํ•™๊ณผ ๋ฐฉ๋ฒ•๋ก ์ด ๋˜์—ˆ๋‹ค.

5๊ฐ€์ง€ ์ฒ ํ•™

  1. ๋ฌธํ™”(Culture) : DevOps๋ฅผ ํ†ตํ•ด ํ•˜๋‚˜์˜ ๋ฌธํ™”๋ฅผ ๋งŒ๋“ค์–ด ๋‚˜๊ฐ
    ex) ์‚ฌ๋žŒ, ์ผ, ์„œ๋น„์Šค, ์ž์›, ์‹œ๊ฐ„
  2. ์ž๋™ํ™”(Automation) : ์ž๋™ํ™”๋ฅผ ํ†ตํ•ด ํšจ์œจ์„ฑ๊ณผ ๋น ๋ฅธ ์†๋„๋ฅผ ์ง€ํ–ฅ
    ex) ์ธํ”„๋ผ ๋ฐ ๋ณด์•ˆ, ์–ธ์–ด ๋ฐ ๋„๊ตฌ, ์ง€์†์  ํ†ตํ•ฉ / ๋ฐฐํฌ, ๋ชจ๋‹ˆํ„ฐ๋ง
  3. ์ธก์ •(Measurement) : ์ง€ํ‘œ๋ฅผ ์ธก์ •ํ•˜์—ฌ ์ง€์†์ ์œผ๋กœ ๊ฐœ์„ 
    ex) ๋ณ€๊ฒฝ์‚ฌํ•ญ ๋ฐœ์ƒ ์‹œ ํ•ญ์ƒ ์ธก์ •, ์„ฑ๋Šฅ, ๊ฐœ๋ฐœ ์†๋„ ๋ชจ๋‹ˆํ„ฐ๋ง, ๋‚˜์•„์ง€๊ณ  ์žˆ๋Š”์ง€ ์•„๋‹Œ์ง€ ์ธก์ •, ์˜์‚ฌ๊ฒฐ์„ฑ์‹œ ์ถ”์ธก์ด ์•„๋‹Œ ์˜ˆ์ธก๊ณผ ํ™•์‹ ์œผ๋กœ ๋งŒ๋“ฆ
  4. ๊ณต์œ (Sharing) : ๊ณต์œ ๋ฅผ ํ†ตํ•ด ํ•จ๊ป˜ ๋ฐœ์ „
    ex) ๊ตฌ์„ฑ์› ๋ชจ๋‘๊ฐ€ ์–ธ์ œ๋“  ์ ‘๊ทผ ๊ฐ€๋Šฅํ•œ ํˆฌ๋ช…ํ•œ ๋ฐ์ดํ„ฐ, ์ง€์‹์˜ ๊ณต์œ , ์šฐ๋ฆฌ์˜ ๋ฌธ์ œ - ํ•จ๊ป˜ ํ•ด๊ฒฐ, ์ผ์˜ ๊ฐ€์†๋„
  5. ์ถ•์ (File up & Pile up) : ๊ธฐ๋ก์„ ์ถ•์ ํ•˜์—ฌ ์ž์‚ฐ์„ ๋งŒ๋“ฆ

๋”ฐ๋ผ์„œ

๋ฐ๋ธŒ์˜ต์Šค๋Š” ์–ด๋–ค ์š”๊ตฌ์‚ฌํ•ญ์„ ํšจ์œจ์ ์œผ๋กœ ๋งŒ์กฑ์‹œํ‚ค๊ธฐ ์œ„ํ•ด ์ผ์„ ์ž๋™ํ™”ํ•˜๋ฉฐ ๋ณ€๊ฒฝ์‚ฌํ•ญ ์ง€ํ‘œ๋“ค์„ ์ธก์ •ํ•˜๊ณ , ๊ณต์œ ํ•˜๊ณ , ์ด ๋ชจ๋“  ๊ฒฐ๊ณผ๋ฌผ๋“ค์„ ์ง€์†์ ์œผ๋กœ ์ถ•์ ํ•ด ๋‚˜์•„๊ฐ€๋Š” ๋ฌธํ™”๋ฅผ ๋งŒ๋“ค์–ด๊ฐ€๋Š” ์ฒ ํ•™, ๋ฐฉ๋ฒ•๋ก , ๊ธฐ์ˆ ์ด๋‹ค.

ํ˜„๋Œ€ ์„œ๋น„์Šค๋Š” ๋„ˆ๋ฌด๋‚˜๋„ ๋ณต์žกํ•˜๊ณ  ์ˆ˜๋งŽ์€ ๋ณต์žกํ•œ ๋ฌธ์ œ๋“ค์„ DevOps ์ฒ ํ•™๊ณผ ๋ฐฉ๋ฒ•๋ก ์œผ๋กœ ํ’€์–ด๋‚˜๊ฐˆ ์ˆ˜ ์žˆ๋‹ค. → ์†๋„์™€ ํšจ์œจํ™”

 

2. DevOps ์—”์ง€๋‹ˆ์–ด์˜ ์—ญํ• 

DevOps ์—”์ง€๋‹ˆ์–ด

์˜ฌ๋ฐ”๋ฅธ DevOps ๋ฌธํ™”๋ฅผ ์œ„ํ•ด ์„œ๋น„์Šค ํ˜น์€ S/W LifeCycle ์—์„œ ๋ฐ˜๋ณต์ ์ธ ์ผ์„ ์ž๋™ํ™”ํ•˜๊ณ , ๊ธฐ์ˆ ์  ๋ฌธ์ œ ํ˜น์€ ํŒ€์˜ ์ฐจ์ด๋ฅผ ๊ธฐ์ˆ ์ ์œผ๋กœ ์˜ˆ๋ฐฉํ•˜๊ณ  ํ•ด์†Œ์‹œํ‚ค๋Š” ์‚ฌ๋žŒ

๊ฐ–์ถฐ์•ผํ•  ๊ธฐ์ˆ 

  1. ์†Œํ”„ํŠธ ์Šคํ‚ฌ
    ์‚ฌํšŒ ๊ธฐ์ˆ , ์˜์‚ฌ ์†Œํ†ต ๊ธฐ์ˆ , ์„ฑ๊ฒฉ ๋˜๋Š” ์„ฑ๊ฒฉ ํŠน์„ฑ, ์ง์—… ์†์„ฑ, ์†Œ์…œ ์ธํ…”๋ฆฌ์ „์Šค ๋ฐ ๊ฐ์„ฑ ์ธํ…”๋ฆฌ์ „์Šค ์ง€์ˆ˜ ๋“ฑ์˜ ์กฐํ•ฉ์œผ๋กœ ์‚ฌ๋žŒ๋“ค์ด ํ™˜๊ฒฝ์„ ํƒ์ƒ‰ํ•˜๊ณ  ๋‹ค๋ฅธ ์‚ฌ๋žŒ๋“ค๊ณผ ์ž˜ ์ผํ•˜๋Š” ๋Šฅ๋ ฅ์„ ๋งํ•จ

    ex) ๋ฌธ์ œ๋ฅผ ์ธ์‹ํ•˜๋Š” ๋Šฅ๋ ฅ, ์ •ํ™•ํ•˜๊ฒŒ ์„ ํƒ๊ณผ ์ง‘์ค‘์„ ๊ตฌ๋ณ„ํ•˜๋Š” ๋Šฅ๋ ฅ, ๊ฒฐ์ • ๋ฐ ํŒ๋‹จ ๋Šฅ๋ ฅ
  2. ํ…Œํฌ๋‹ˆ์ปฌ ์Šคํ‚ฌ
    ๊ธฐ์ˆ ์  ์Šคํ‚ฌ์€ ํŠน์ •ํ•œ ์ผ์„ ํšจ๊ณผ์ ์œผ๋กœ ์ˆ˜ํ–‰ํ•˜๋Š” ์ง€์‹๊ณผ ๋Šฅ๋ ฅ์„ ๋งํ•จ

    ex) ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด ์ž‘์„ฑ ๋Šฅ๋ ฅ, S/W ๋””์ž์ธ, ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋ฐ ์„œ๋ฒ„๊ด€๋ฆฌ ๋“ฑ ํŠน์ •ํ•œ ๊ธฐ์ˆ ์˜ ์ง€์‹๊ณผ ์ˆ˜ํ–‰๋Šฅ๋ ฅ

IaC(Infrastructure as Code, ์ฝ”๋“œ๋กœ์จ์˜ ์ธํ”„๋ผ)

์ธํ”„๋ผ๋ฅผ ์ด๋ฃจ๋Š” ์„œ๋ฒ„, ๋ฏธ๋“ค์›จ์–ด ๊ทธ๋ฆฌ๊ณ  ์„œ๋น„์Šค ๋“ฑ, ์ธํ”„๋ผ ๊ตฌ์„ฑ์š”์†Œ๋“ค์„ ์ฝ”๋“œ๋กœ ํ†ตํ•ด ๊ตฌ์ถ•ํ•˜๋Š” ๊ฒƒ.

IaC๋Š” ์ฝ”๋“œ๋กœ์จ์˜ ์žฅ์ , ์ฆ‰ ์ž‘์„ฑ์šฉ์ด์„ฑ, ์žฌ์‚ฌ์šฉ์„ฑ, ์œ ์ง€๋ณด์ˆ˜ ๋“ฑ์˜ ์žฅ์ ์„ ๊ฐ€์ง„๋‹ค.

ํ…Œ๋ผํผ

ํ˜„์žฌ ๊ฐ€์žฅ ๋งŽ์ด ์“ฐ์ด๋Š” IaC ๋„๊ตฌ

ํ…Œ๋ผํผ์€ ์ธํ”„๋ผ๋ฅผ ๋งŒ๋“ค๊ณ , ๋ณ€๊ฒฝํ•˜๊ณ , ๊ธฐ๋กํ•˜๋Š” IaC๋ฅผ ์œ„ํ•ด ๋งŒ๋“ค์–ด์ง„ ๋„๊ตฌ๋กœ์จ, ๋ฌธ๋ฒ•์ด ์‰ฌ์›Œ ๋น„๊ต์  ๋‹ค๋ฃจ๊ธฐ ์‰ฝ๊ณ  ์‚ฌ์šฉ์ž๊ฐ€ ๋งŽ์•„ ์ฐธ๊ณ ํ•  ์ˆ˜ ์žˆ๋Š” ์˜ˆ์ œ๊ฐ€ ๋งŽ๋‹ค.
.tf ํ˜•์‹์˜ ํŒŒ์ผ ํ˜•์‹์„ ๊ฐ€์ง„๋‹ค.

AWS, Azure, GCP ๊ฐ™์€ ํผ๋ธ”๋ฆญ ํด๋ผ์šฐ๋“œ ๋ฟ๋งŒ์•„๋‹ˆ๋ผ ๋‹ค์–‘ํ•œ ์„œ๋น„์Šค๋„ ์ง€์›ํ•œ๋‹ค.

DevOps ๋กœ๋“œ๋งต

 

Developer Roadmaps

Community driven roadmaps, articles, guides, quizzes, tips and resources for developers to learn from, identify their career paths, know what they don't know, find out the knowledge gaps, learn and improve.

roadmap.sh

 

3. Terraform ๊ธฐ๋ณธ

๊ตฌ์„ฑ์š”์†Œ

  • provider : ํ…Œ๋ผํผ์œผ๋กœ ์ƒ์„ฑํ•  ์ธํ”„๋ผ์˜ ์ข…๋ฅ˜
  • resource : ํ…Œ๋ผํผ์œผ๋กœ ์‹ค์ œ๋กœ ์ƒ์„ฑํ•  ์ธํ”„๋ผ ์ž์›
  • state : ํ…Œ๋ผํผ์„ ํ†ตํ•ด ์ƒ์„ฑํ•œ ์ž์›์˜ ์ƒํƒœ. ํŒŒ์ผ ํ˜•ํƒœ๋กœ ๋‚จ๊ฒŒ ๋จ(ํ…Œ๋ผํผ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•œ ๊ฒฐ๊ณผ๋ฌผ .tfstate)
    โœ” ์Šคํ…Œ์ดํŠธ ํŒŒ์ผ๊ณผ ํ˜„์žฌ ์ธํ”„๋ผ์˜ ์ƒํƒœ๋ฅผ ๋˜‘๊ฐ™์ด ์œ ์ง€ํ•˜๋Š” ๊ฒƒ์ด ํ‚คํฌ์ธํŠธ โœ”
    ํ…Œ๋ผํผ ์ฝ”๋“œ๋ฅผ ์ƒ์„ฑํ•œ ๋ฆฌ์†Œ์Šค์˜ ๊ฒฐ๊ณผ๊ฐ’์ผ ๋ฟ ์ธํ”„๋ผ์˜ ์‹ค์ œ ์ƒํƒœ๋Š” ์•„๋‹˜
  • output : ํ…Œ๋ผํผ์œผ๋กœ ๋งŒ๋“  ์ž์›์„ ๋ณ€์ˆ˜ ํ˜•ํƒœ๋กœ state์— ์ €์žฅํ•˜๋Š” ๊ฒƒ์„ ์˜๋ฏธ
  • module : ๊ณตํ†ต์ ์œผ๋กœ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์ฝ”๋“œ๋ฅผ ๋ฌธ์ž ๊ทธ๋Œ€๋กœ ๋ชจ๋“ˆ ํ˜•ํƒœ๋กœ ์ •์˜. ์žฌ์‚ฌ์šฉ์— ๊ฐ•์ !!
    ํ•œ ๋ฒˆ ๋งŒ๋“ค์–ด์ง„ ํ…Œ๋ผํผ ์ฝ”๋“œ๋กœ ๊ฐ™์€ ํ˜•ํƒœ๋ฅผ ๋ฐ˜๋ณต์ ์œผ๋กœ ๋งŒ๋“ค์–ด๋‚ผ๋•Œ ์ฃผ๋กœ ์‚ฌ์šฉ๋จ
  • remote : ๋‹ค๋ฅธ ๊ฒฝ๋กœ์˜ state๋ฅผ ์ฐธ์กฐํ•˜๋Š” ๊ฒƒ์„ ๋งํ•จ. output ๋ณ€์ˆ˜๋ฅผ ๋ถˆ๋Ÿฌ์˜ฌ๋•Œ ์ฃผ๋กœ ์‚ฌ์šฉ
    ์›๊ฒฉ ์ฐธ์กฐ ๊ฐœ๋…์œผ๋กœ ์ดํ•ดํ•˜๋ฉด ์ข‹๋‹ค.

๊ธฐ๋ณธ ๋ช…๋ น์–ด

  • init : ํ…Œ๋ผํผ ๋ช…๋ น์–ด ์‚ฌ์šฉ์„ ์œ„ํ•ด ๊ฐ์ข… ์„ค์ •์„ ์ง„ํ–‰
    ์ตœ์ดˆ์˜ ํ…Œ๋ผํผ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•  ๋•Œ ํ•ด์•ผํ•จ
  • plan : ํ…Œ๋ผํผ์œผ๋กœ ์ž‘์„ฑํ•œ ์ฝ”๋“œ๊ฐ€ ์‹ค์ œ๋กœ ์–ด๋–ป๊ฒŒ ๋งŒ๋“ค์–ด์งˆ์ง€์— ๋Œ€ํ•œ ์˜ˆ์ธก ๊ฒฐ๊ณผ๋ฅผ ๋ณด์—ฌ์คŒ
    ์‹ค์ œ๋กœ ๊ฐ€์žฅ ๋งŽ์ด ์“ฐ์ž„
  • apply : ํ…Œ๋ผํผ ์ฝ”๋“œ๋กœ ์‹ค์ œ ์ธํ”„๋ผ๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๋ช…๋ น์–ด
    ์‹ค์ œ ์ธํ”„๋ผ์— ์˜ํ–ฅ์„ ๋ผ์น˜๋Š” ๋ช…๋ น์–ด์ด๋ฏ€๋กœ ์ฃผ์˜๊นŠ๊ฒŒ ์‹คํ–‰ํ•ด์•ผ ํ•œ๋‹ค.
    apply ํ•˜๊ธฐ ์ „์— plan ํ•˜๋Š” ๊ฒƒ์„ ์Šต๊ด€ํ™” ํ•˜๊ธธ ๋ฐ”๋žŒ!
  • import : ์ด๋ฏธ ๋งŒ๋“ค์–ด์ง„ ์ž์›์„ ํ…Œ๋ผํผ state ํŒŒ์ผ๋กœ ์˜ฎ๊ฒจ์ฃผ๋Š” ๋ช…๋ น์–ด
    = ์ด๋ฏธ ๋งŒ๋“ค์–ด์ง„ ์ž์›์„ ์ฝ”๋“œ๋กœ ๋งŒ๋“ค๊ณ  ์‹ถ์„ ๋•Œ ์‚ฌ์šฉํ•จ
  • state : ํ…Œ๋ผํผ state๋ฅผ ๋‹ค๋ฃจ๋Š” ๋ช…๋ น์–ด. ํ•˜์œ„ ๋ช…๋ น์–ด๋กœ mv, push์™€ ๊ฐ™์€ ๋ช…๋ น์–ด๊ฐ€ ์žˆ๋‹ค.
  • destroy : ์ƒ์„ฑ๋œ ์ž์›๋“ค์„ state ํŒŒ์ผ ๊ธฐ์ค€์œผ๋กœ ๋ชจ๋‘ ์‚ญ์ œํ•˜๋Š” ๋ช…๋ น์–ด
    = ๋‹ค์‹œ ๋งŒ๋“ค์–ด์•ผ์ง€! ํ•  ๋•Œ ์“ฐ์ž„

์ด๋ฐ–์— ๋งŽ์€ ๋ช…๋ น์–ด๊ฐ€ ๋งŽ์ง€๋งŒ ๊ธฐ๋ณธ ๋ช…๋ น์–ด ์Šต๋“ ์ดํ›„์— ์‹œ์ž‘ํ•ด๋„ ๊ดœ์ฐฎ๋‹ค. ์‹ค์ œ๋กœ ๊ธฐ๋ณธ ๋ช…๋ น์–ด์˜ ์‚ฌ์šฉ ๋นˆ๋„๊ฐ€ 90% ์ด์ƒ ์ฐจ์ง€ํ•จ

๋Œ“๊ธ€