๐ŸŽก Pod์˜ ๊ฐœ๋…๊ณผ ํŠน์ง•

Contents

๊ฐœ์š”

๊ฝค ์˜ค๋ž˜ ์ „, ์ธํ”„๋Ÿฐ์— ๊ฒฐ์ œํ•ด ๋‘” ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ๊ฐ•์˜(Reference ์ฐธ๊ณ )๊ฐ€ ์žˆ์—ˆ๋‹ค. ๋‹น์‹œ์—๋Š” ์‹ค๋ฌด์—์„œ ์‚ฌ์šฉํ•  ์ผ์ด ์—†์–ด์„œ ์ด๋ก  ๊ฐ•์˜๋งŒ ๋ช‡ ๊ฐœ ๋“ฃ๊ณ  ๋ฌตํ˜€๋‘์—ˆ๋Š”๋ฐ ์ด์ง์„ ํ•˜๊ณ  ๋งก๊ฒŒ ๋œ ํ”„๋กœ์ ํŠธ์—๋Š” ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ๊ธฐ๋ฐ˜ ์ธํ”„๋ผ ๊ตฌ์„ฑ์ด ๋˜์–ด์žˆ์–ด ์ €๋ฒˆ ์ฃผ๋ง๋ถ€ํ„ฐ ๋‹ค์‹œ ๊ฐ•์˜๋ฅผ ๋ณด๊ธฐ ์‹œ์ž‘ํ–ˆ๋‹ค.

์˜ค๋Š˜์€ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์˜ ์ฃผ์š” ๊ฐœ๋… ์ค‘ ํ•˜๋‚˜์ธ Pod์˜ ํŠน์ง•์— ๋Œ€ํ•ด ์ •๋ฆฌํ•ด๋ณด๋ ค ํ•œ๋‹ค.

Pod

Pod๋Š” ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์ตœ์†Œ ๋‹จ์œ„์ด๋‹ค. ์—ฌ๋Ÿฌ ๊ฐœ์˜ ์ปจํ…Œ์ด๋„ˆ๋กœ ๊ตฌ์„ฑ๋œ Pod๋„ ์žˆ๊ณ , ๋‹จ์ผ ์ปจํ…Œ์ด๋„ˆ๋กœ๋งŒ ์ด๋ฃจ์–ด์ง„ Pod๋„ ์žˆ๋‹ค. Container๋ฅผ Pod๋กœ ๊ทธ๋ฃนํ™”ํ•˜๋Š” ์ด์œ ๋Š” ๋ฆฌ์†Œ์Šค๋ฅผ ๋” ์ง€๋Šฅ์ ์œผ๋กœ ๊ณต์œ ํ•˜๊ธฐ ์œ„ํ•ด์„œ์ด๋‹ค. ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ์‹œ์Šคํ…œ์—์„œ๋Š” ๊ฐ™์€ Pod์— ์†ํ•œ ์ปจํ…Œ์ด๋„ˆ๋ผ๋ฆฌ ๋™์ผํ•œ ์ปดํ“จํŒ… ๋ฆฌ์†Œ์Šค๋ฅผ ๊ณต์œ ํ•œ๋‹ค.

Pod์˜ ํŠน์ง•์—๋Š” ํฌ๊ฒŒ Container, Label, Node Schedule์ด ์žˆ๋‹ค.

Container

pod.png

  • Pod ์•ˆ์—๋Š” ํ•˜๋‚˜์˜ ์„œ๋น„์Šค๋ฅผ ๊ตฌ๋™ํ•  ์ˆ˜ ์žˆ๋Š” ๋…๋ฆฝ์ ์ธ ์ปจํ…Œ์ด๋„ˆ๋“ค์ด ์žˆ์Œ
  • ๊ทธ ์ปจํ…Œ์ด๋„ˆ๋“ค์€ ๊ฐ๊ฐ์˜ ์„œ๋น„์Šค๋ฅผ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ๋„๋ก ํฌํŠธ๋ฅผ ๊ฐ€์ง

    • ํ•œ Pod ๋‚ด์—์„œ ์ปจํ…Œ์ด๋„ˆ๋“ค๋ผ๋ฆฌ ํฌํŠธ๊ฐ€ ์ค‘๋ณต๋  ์ˆ˜๋Š” ์—†์Œ
  • Pod๊ฐ€ ์ƒ์„ฑ๋  ๋•Œ ๊ณ ์œ ์˜ IP ์ฃผ์†Œ๊ฐ€ ํ• ๋‹น์ด ๋จ

    • ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ํด๋Ÿฌ์Šคํ„ฐ ์•ˆ์—์„œ๋งŒ ํ•ด๋‹น IP๋ฅผ ํ†ตํ•ด Pod์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์Œ
    • ์™ธ๋ถ€์—์„œ๋Š” ์ ‘๊ทผ ๋ถˆ๊ฐ€
    • ์žฌ์ƒ์„ฑ ์‹œ IP๋Š” ๋ณ€๊ฒฝ์ด ๋จ (ํœ˜๋ฐœ์„ฑ)
apiVersion: v1
kind: Pod
metadata:
	name: pod-1
spec:
	containers:
		- name: container1
			image: ugaemi/p8000
			ports:
				- containerPort: 8000
		- name: container2
			image: ugaemi/p8080
			ports:
				- containerPort: 8080

Label

label.png

  • Pod ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๋ชจ๋“  Object์— ๋‹ฌ ์ˆ˜ ์žˆ๋Š”๋ฐ, ์ฃผ๋กœ Pod์—์„œ ๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉ๋จ
  • ๋ชฉ์ ์— ๋”ฐ๋ผ Object๋“ค์„ ๋ถ„๋ฅ˜ํ•˜๊ณ  ๋ถ„๋ฅ˜๋œ Object๋“ค๋งŒ ๋”ฐ๋กœ ๊ณจ๋ผ์„œ ์—ฐ๊ฒฐํ•˜๊ธฐ ์œ„ํ•จ
  • Key์™€ Value๋กœ ์ด๋ฃจ์–ด์ง
  • ๊ฐ™์€ ๋ผ๋ฒจ์„ ๊ฐ€์ง„ Pod๋“ค๋ผ๋ฆฌ ์„œ๋น„์Šค๋กœ ๋ฌถ์–ด ์ ‘์† ๊ฐ€๋Šฅ
apiVersion: v1
kind: Pod
metadata:
	name: pod-2
	labels:
		type: web
		lo: dev
spec:
	containers:
		- name: container
			image: ugaemi/init
apiVersion: v1
kind: Service
metadata:
	name: svc-1
spec:
	selector:
		type: web
	ports:
		- port: 8080

Node Schedule

  • Pod๋Š” ๊ฒฐ๊ตญ ์—ฌ๋Ÿฌ ๋…ธ๋“œ๋“ค ์ค‘ ํ•˜๋‚˜์˜ ๋…ธ๋“œ์— ์˜ฌ๋ผ๊ฐ€์•ผ ํ•จ
  • ์ง์ ‘ ๋…ธ๋“œ๋ฅผ ์„ ํƒํ•˜๋Š” ๋ฐฉ๋ฒ•๊ณผ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค๊ฐ€ ์ž๋™์œผ๋กœ ์ง€์ •ํ•ด์ฃผ๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์Œ

์ง์ ‘ ์„ ํƒ

node1.png

  • Node์— Label์„ ๋‹ฌ์•„ Pod๋ฅผ ๋งŒ๋“ค ๋•Œ Node์˜ ๋ผ๋ฒจ์„ ์ง€์ •
apiVersion: v1
kind: Pod
metadata:
	name: pod-3
spec:
	nodeSelector:
		hostname: node1
	containers:
		- name: container
			image: ugaemi/init

์ž๋™ ์„ ํƒ

node2.png

  • ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์˜ ์Šค์ผ€์ค„๋Ÿฌ๊ฐ€ ์ž๋™์œผ๋กœ ์–ด๋Š Node์— ์—ฐ๊ฒฐํ• ์ง€ ํŒ๋‹จ
  • Node์—๋Š” ์ „์ฒด ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์ž์›๋Ÿ‰์ด ์žˆ์Œ ex) ๋ฉ”๋ชจ๋ฆฌ, CPU ๋“ฑ
  • Pod์— ํ•„์š”ํ•œ ์ž์›๋Ÿ‰์„ ์ง€์ •ํ•ด๋‘์ง€ ์•Š์œผ๋ฉด ์—ฐ๊ฒฐ๋œ Node์˜ ์ž์›์„ ๋ฌดํ•œ์ • ์‚ฌ์šฉํ•˜๊ฒŒ ๋จ

    • ๋‚˜๋จธ์ง€ Pod๋“ค์ด ์‚ฌ์šฉํ•  ์ž์›์ด ๋ถ€์กฑํ•ด์ ธ ๋‹ค๊ฐ™์ด ์ฃฝ์„ ์ˆ˜ ์žˆ์Œ
    • memory: ์ดˆ๊ณผ ์‹œ Pod ์ข…๋ฃŒ ์‹œํ‚ด
    • cpu: ์ดˆ๊ณผ ์‹œ request๋กœ ๋‚ฎ์ถค, over ์‹œ ์ข…๋ฃŒ๋˜์ง€ ์•Š์Œ
apiVersion: v1
kind: Pod
metadata:
	name: pod-4
spec:
	containers:
		- name: container
			image: ugaemi/init
			resources:
				requests:
					memory: 2Gi
				limits:
					memory: 3Gi

References


Written by@ugaemi
Record things I want to remember

๐Ÿฑ GitHub๐Ÿ“š Reading Space