๋ฐ˜์‘ํ˜•

๐Ÿ“‚ Container & K8S 9

[K8S] Karpenter์™€ Cluster AutoScaler(CA)

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์—์„œ Auto Scaling Auto Scaling์€ ๋ถ€ํ•˜์™€ ์š”๊ตฌ ์‚ฌํ•ญ์— ๋”ฐ๋ผ ์ปดํ“จํŒ… ๋ฆฌ์†Œ์Šค๋ฅผ ์ž๋™์œผ๋กœ ์กฐ์ •ํ•˜์—ฌ ์ตœ์ ์˜ ์„ฑ๋Šฅ๊ณผ ๋น„์šฉ ํšจ์œจ์„ฑ์„ ์ œ๊ณตํ•˜๋Š” ํ”„๋กœ์„ธ์Šค์ž…๋‹ˆ๋‹ค. EKS์—์„œ Auto Scaling์€ ‘Pod Auto Scaling’๊ณผ ‘Node Auto Scaling’ 2๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. Pod์˜ Auto Scaling Horizontal Pod Autoscaler(HPA) : pod์˜ ์ˆ˜ํ‰์ ์ธ scaling(scale out/in)์„ ๋‹ด๋‹นํ•˜๋Š” ์ปดํฌ๋„ŒํŠธ Vertical Pod Autoscaler(VPA) : pod์˜ ์ˆ˜์ง์ ์ธ scaling(scale up/down)์„ ๋‹ด๋‹นํ•˜๋Š” ์ปดํฌ๋„ŒํŠธ Node์˜ Auto Scaling Cluster AutoScaler(CA) : k8s ํด๋Ÿฌ์Šคํ„ฐ์—์„œ ๋…ธ๋“œ๋ฅผ s..

[K8S] kubectl ๋ช…๋ น์–ด ์ •๋ฆฌ

kubectl ๊ตฌ๋ฌธ kubectl [COMMAND] [TYPE] [NAME] [FLAGS] COMMAND : ๋ฆฌ์†Œ์Šค์— ์ˆ˜ํ–‰ํ•˜๋Š” ๋™์ž‘์„ ์ง€์ •(create, get, describe, delete ๋“ฑ) TYPE : ๋ฆฌ์†Œ์Šค ํƒ€์ž…์„ ์ง€์ •(node, pod, service) NAME : ๋ฆฌ์†Œ์Šค ์ด๋ฆ„์„ ์ง€์ • FLAGS : ๋ถ€๊ฐ€์ ์„ ์„ค์ •ํ•  ์˜ต์…˜(--helo, --dry-run, -o yaml ๋“ฑ) kubectl ์•ฝ์–ด(shortname) ns -> namespace sa -> serviceaccount no -> node po -> pod rs -> replicaset deploy -> deployment sts -> statefulset ds -> daemonsets svc -> service ing -> ingre..

[Docker] ๋„์ปค ๋„คํŠธ์›Œํฌ์™€ ๋ช…๋ น์–ด

๋„์ปค ๋„คํŠธ์›Œํฌ ๋“œ๋ผ์ด๋ฒ„ ์ข…๋ฅ˜ bridge : ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์ง€์ •ํ•˜์ง€ ์•Š๊ณ  createํ•˜๋ฉด ์ƒ๊ธฐ๋Š” ๊ธฐ๋ณธ ๋„คํŠธ์›Œํฌ ๋“œ๋ผ์ด๋ฒ„์ž…๋‹ˆ๋‹ค. host : ํ˜ธ์ŠคํŠธ์˜ ๋„คํŠธ์›Œํฌ๋ฅผ ์ง์ ‘ ์‚ฌ์šฉํ•˜๋Š” ๋“œ๋ผ์ด๋ฒ„์ž…๋‹ˆ๋‹ค. overlay : ์—ฌ๋Ÿฌ ํ˜ธ์ŠคํŠธ์— ๋ถ„์‚ฐ๋˜์–ด ์žˆ๋Š” ์ปจํ…Œ์ด๋„ˆ๊ฐ„ ๋„คํŠธ์›Œํฌ ๊ตฌ์ถ•ํ•ด์•ผ ํ•  ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. macvlan : ์ปจํ…Œ์ด๋„ˆ์— MAC ์ฃผ์†Œ๋ฅผ ํ• ๋‹นํ•˜์—ฌ ๋„คํŠธ์›Œํฌ์—์„œ ๋ฌผ๋ฆฌ์  ์žฅ์น˜์ฒ˜๋Ÿผ ๋ณด์ด๊ฒŒํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” VM์„ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ํ•˜๊ฑฐ๋‚˜ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ๊ณ ์œ ์˜ MAC ์ฃผ์†Œ๋ฅผ ๊ฐ€์ง„ ๋ฌผ๋ฆฌ์  ํ˜ธ์ŠคํŠธ์ฒ˜๋Ÿผ ๋ณด์ด๋„๋ก ๋งŒ๋“ค์–ด์•ผํ•  ๋•Œ ์‚ฌ์šฉ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ, ์„œ๋กœ ๋‹ค๋ฅธ macvlan ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋ฌถ์–ด์„œ VLAN์„ ๊ตฌ์„ฑ ํ•  ์ˆ˜์žˆ์Šต๋‹ˆ๋‹ค. none : ๋ชจ๋“  ๋„คํŠธ์›Œํฌ๋ฅผ ๋น„ํ™œ์„ฑํ™”ํ•œ ์ƒํƒœ์ž…๋‹ˆ๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ ์‚ฌ์šฉ์ž ์ง€์ • ๋„คํŠธ์›Œํฌ ๋“œ๋ผ์ด๋ฒ„์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋„์ปค ๋„ค..

[Docker] ๋„์ปค ๋ณผ๋ฅจ๊ณผ ๋ณผ๋ฅจ ๋ช…๋ น์–ด

์ปจํ…Œ์ด๋„ˆ๋Š” ํœ˜๋ฐœ์„ฑ ํ”„๋กœ์„ธ์Šค๋กœ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์‚ญ์ œ๋œ๋‹ค๋ฉด, ์ปจํ…Œ์ด๋„ˆ ๋‚ด๋ถ€์˜ ๋ฐ์ดํ„ฐ๋„ ํ•จ๊ป˜ ์‚ฌ๋ผ์ง€๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— ๋ฐ์ดํ„ฐ์˜ ์˜์†์„ฑ์„ ํ™•๋ณดํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ปจํ…Œ์ด๋„ˆ ์™ธ๋ถ€์— ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ๋ฅผ ์ปจํ…Œ์ด๋„ˆ ์™ธ๋ถ€(ํ˜ธ์ŠคํŠธ)์— ์ €์žฅํ•˜๋Š” ์˜ต์…˜์€ Volumes, Bind Mounts, tmpfs 3๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. Volumes์€ Docker๊ฐ€ ๊ด€๋ฆฌํ•˜๋Š” ํŒŒ์ผ์‹œ์Šคํ…œ(/var/lib/docker/volumes/)์— ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. Non-Docker ํ”„๋กœ์„ธ์Šค๋Š” ํ•ด๋‹น ํŒŒ์ผ์‹œ์Šคํ…œ์„ ์ˆ˜์ •ํ•ด์„œ๋Š” ์•ˆ๋ฉ๋‹ˆ๋‹ค. (๋„์ปค์—์„œ ๋ฐ์ดํ„ฐ ์˜์†์„ฑ์„ ํ™•๋ณดํ•˜๋Š” ๊ฐ€์žฅ ์ข‹์€ ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.) Bind Mounts ๋Š” ํ˜ธ์ŠคํŠธ์˜ ํŒŒ์ผ ์‹œ์Šคํ…œ ์–ด๋””์—๋‚˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” ์ค‘์š”ํ•œ ์‹œ์Šคํ…œ ํŒŒ์ผ์ด๋‚˜ ๋””๋ ‰ํ„ฐ๋ฆฌ์—๋„ ์‚ฌ์šฉ ํ•  ์ˆ˜ ์žˆ๊ณ , N..

[Docker] ๋„์ปค ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ์™€ ๋„์ปค ํ—ˆ๋ธŒ

๋„์ปค ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ๋Š” ๋„์ปค ์ด๋ฏธ์ง€๋ฅผ ์ €์žฅํ•˜๊ณ  ๋ฐฐํฌ ํ•  ์ˆ˜ ์žˆ๋Š” ์„œ๋ฒ„ ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ, ์ด๋ฏธ์ง€๋ฅผ ์ €์žฅํ•˜๊ณ  ๋ฐฐํฌํ•˜๋Š” ํ‘œ์ค€ ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. ๋„์ปค ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ๋Š” Apache ๋ผ์ด์„ผ์Šค๋ฅผ ๋”ฐ๋ฅด๋Š” ์˜คํ”ˆ์†Œ์Šค์ž…๋‹ˆ๋‹ค. ๋„์ปค ํ—ˆ๋ธŒ๋Š” ๋„์ปค ์‚ฌ์—์„œ ํ˜ธ์ŠคํŒ…ํ•˜๋Š” ๋„์ปค ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ์ด๋ฉฐ, ๋„์ปค์—์„œ ๊ธฐ๋ณธ์œผ๋กœ ์ฐธ์กฐํ•ฉ๋‹ˆ๋‹ค. ๋„์ปค ํ—ˆ๋ธŒ ๊ณ„์ • ๋กœ๊ทธ์ธ / ๋กœ๊ทธ์•„์›ƒ docker login docker logout ๋„์ปค ํ—ˆ๋ธŒ๋กœ ์ด๋ฏธ์ง€ Push / Pull docker image push {๊ณ„์ •๋ช…}/{์ €์žฅ์†Œ๋ช…}:[ํƒœ๊ทธ ์ด๋ฆ„] docker image pull {๊ณ„์ •๋ช…}/{์ €์žฅ์†Œ๋ช…}:[ํƒœ๊ทธ ์ด๋ฆ„] # ex) ๋„์ปค ํ—ˆ๋ธŒ "hyuckang" ๊ณ„์ •์˜ "test_ubuntu" ๋ ˆํฌ์ง€ํ† ๋ฆฌ์— "1.0" ํƒœ๊ทธ๋กœ push/pull docker image push hyuckang/t..

[Docker] ๋„์ปค ์ด๋ฏธ์ง€ ๋นŒ๋“œ์™€ ๋„์ปคํŒŒ์ผ

docker image build๋Š” Dockerfile๋กœ ๋ถ€ํ„ฐ ์ด๋ฏธ์ง€๋ฅผ ๋งŒ๋“œ๋Š” ๋ช…๋ น ์ž…๋‹ˆ๋‹ค. ๋„์ปค ์ด๋ฏธ์ง€ ๋นŒ๋“œ (docker image build) docker image build [OPTIONS] PATH | URL | - # Build an image from a Dockerfile # -t, --tag list : ์ด๋ฏธ์ง€ ์ด๋ฆ„๊ณผ ํƒœ๊ทธ๋ฅผ ์ง€์ •ํ•œ๋‹ค # -f, --file string : ๋„์ปคํŒŒ์ผ์˜ ์ด๋ฆ„์„ ์ง€์ •ํ•œ๋‹ค. ๊ธฐ๋ณธ๊ฐ’์€ "PATH" ์— ์กด์žฌํ•˜๋Š” Dockerfile # --build-arg list : ๋นŒ๋“œ ๋  ๋•Œ ๋ณ€์ˆ˜๊ฐ€ ์„ธํŒ…๋œ๋‹ค. (Set build-time variables) # ex) ํ˜„์žฌ ๋””๋ ‰ํ„ฐ๋ฆฌ์— ์žˆ๋Š” "Dockerfile"๋ฅผ "hyuckang_image:1.0" ์ด๋ฏธ์ง€๋กœ ๋นŒ๋“œํ•œ๋‹ค. doc..

[Docker] ๋„์ปค ์ด๋ฏธ์ง€ ๋ช…๋ น์–ด ์ •๋ฆฌ

๋„์ปค ์ด๋ฏธ์ง€ ์กฐํšŒ (docker image ls) docker image ls [OPTIONS] [REPOSITORY[:TAG]] # List images # -a, --all : ๋ชจ๋“  ์ด๋ฏธ์ง€ ์กฐํšŒ ๋„์ปค ์ด๋ฏธ์ง€ ํƒœ๊ทธ (docker image tag) docker image tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG] # Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE # ex) ์ด๋ฏธ์ง€ ๋ช…์ด 'ubuntu' ์ด๊ณ , latest ํƒœ๊ทธ๋ฅผ ๊ฐ€์ง„ ์ด๋ฏธ์ง€์— # ์ด๋ฏธ์ง€ ๋ช…์ด 'hyuckang/test_os' ์ด๊ณ  ํƒœ๊ทธ๋Š” '1'์ด ๋˜๋กœ๋ก ๋ณ€๊ฒฝํ•จ docker image tage ubuntu:lates..

[Docker] ๋„์ปค ์ปจํ…Œ์ด๋„ˆ ๋ช…๋ น์–ด ์ •๋ฆฌ

๋„์ปค ๋ฒ„์ „ ํ™•์ธ(docker version) docker version # Show the Docker version information ๋„์ปค ์ƒ์„ธ์ •๋ณด ํ™•์ธ(docker inspect) docker inspect [OPTIONS] NAME|ID [NAME|ID...] # Return low-level information ์ปจํ…Œ์ด๋„ˆ ์ƒ์„ฑ ๋ฐ ์‹คํ–‰(docker container run) docker container run [OPTIONS] IMAGE [COMMAND] [ARG...] # Run a command in a new container # -d, --detach : ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋ฐฑ๊ทธ๋ผ์šด๋“œ๋กœ ์‹คํ–‰ํ•˜๊ณ , ์ปจํ…Œ์ด๋„ˆ ID๋ฅผ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค. # -p, --publish list : ํ˜ธ์ŠคํŠธ์˜ ํฌํŠธ์™€ ์ปจํ…Œ์ด๋„ˆ์˜ ..

[Docker] ๋„์ปค๋ž€? ๋„์ปค์™€ ์ปจํ…Œ์ด๋„ˆ ์ •๋ฆฌ

๋„์ปค๋ž€? ์ปจํ…Œ์ด๋„ˆ๋ž€? ๋„์ปค๋Š” ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋Š” ์˜คํ”ˆ ์†Œ์Šค ํ”Œ๋žซํผ์ž…๋‹ˆ๋‹ค. ์ปจํ…Œ์ด๋„ˆ๋Š” ๋ฆฌ๋ˆ…์Šค ์ปค๋„์—์„œ ์ œ๊ณตํ•˜๋Š” Namespcae, Cgroups ๋“ฑ์˜ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋งŒ๋“  ๋…๋ฆฝ์ ์ธ ๊ฐ€์ƒ์˜ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์‹คํ–‰ํ™˜๊ฒฝ์„ ์˜๋ฏธํ•˜๋ฉฐ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์‹คํ–‰์— ํ•„์š”ํ•œ ๋ชจ๋“  ํŒŒ์ผ์„ ํŒจํ‚ค์ง€ํ™”์‹œํ‚จ ์†Œํ”„ํŠธ์›จ์–ด์˜ ํ‘œ์ค€ ๋‹จ์œ„์ž…๋‹ˆ๋‹ค. ๋„์ปค๊ฐ€ ์„ค์น˜๋˜๊ณ , ์ด๋ฏธ์ง€๋งŒ ์žˆ๋‹ค๋ฉด ์–ด๋””์„œ๋“  ์‹คํ–‰ ํ•  ์ˆ˜ ์žˆ์–ด์„œ ๊ฐœ๋ฐœ๊ณผ ๋ฐฐํฌ ํ™˜๊ฒฝ์„ ๋™์ผํ•˜๊ฒŒ ๊ตฌ์„ฑ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ปจํ…Œ์ด๋„ˆ์™€ ๊ฐ€์ƒ๋จธ์‹ (VM)์˜ ์ฐจ์ด์  ๋…๋ฆฝ์ ์ธ ์‹คํ–‰ํ™˜๊ฒฝ์„ ์ œ๊ณตํ•œ๋‹ค๋Š” ์ ์—์„œ ์ปจํ…Œ์ด๋„ˆ์™€ ๊ฐ€์ƒ๋จธ์‹ ์€ ๋น„์Šทํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ปจํ…Œ์ด๋„ˆ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ OS๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š๊ณ , ๋„์ปค ์—”์ง„์— ์˜ํ•ด ํ†ต์ œ๊ฐ€ ์ด๋ฃจ์–ด์ง‘๋‹ˆ๋‹ค. ๋•Œ๋ฌธ์— ๊ฒŒ์ŠคํŠธ OS๋ฅผ ํฌํ•จํ•˜๊ณ  ํ•˜์ดํผ ๋ฐ”์ด์ € ์œ„์—์„œ ๋™์ž‘ํ•˜๋Š” ๊ฐ€์ƒ๋จธ์‹ ๋ณด๋‹ค ์˜ค๋ฒ„ํ—ค๋“œ๊ฐ€ ์ ๊ณ  ..

๋ฐ˜์‘ํ˜•