Lab2

Google Kubernetes Engine์€ ๋ฐฐํฌ, ๊ด€๋ฆฌ ๊ทธ๋ฆฌ๊ณ  scaling your containerized applicationํ•˜๋Š” ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•œ๋‹ค.

GKE ํด๋Ÿฌ์Šคํ„ฐ๋ฅผ ์‹คํ–‰ ์‹œ์˜ benefits

1. Set a default compute zone

gcloud config set compute/zone us-central1-a

zone์„ ์ง€์ •ํ•œ๋‹ค.

2. Create a CKE cluster

cluster๋Š” ์ตœ์†Œ ํ•˜๋‚˜์˜ cluster master machine์„ ํฌํ•จํ•˜๋ฉฐ, โ€˜๋…ธ๋“œ'๋ผ๊ณ  ๋ถˆ๋ฆฌ๋Š” ๋‹ค์ˆ˜์˜ worker machine์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค.

  • Nodes : Compute Engine virtual machine (VM) instances that run the Kubernetes processes necessary to make them part of the cluster. ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ํ”„๋กœ์„ธ์Šค๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๊ฐ€์ƒ๋จธ์‹  ์ธ์Šคํ„ด์Šค๋“ค.

gcloud container clusters create [CLUSTER-NAME]

3. Get authentication credentials for the cluster

ํด๋Ÿฌ์Šคํ„ฐ ์ƒ์„ฑ ํ›„ authentication credential์„ ๋ฐ›์•„ interact ํ•ด์•ผ ํ•œ๋‹ค.

gcloud container clusters get-credentials [CLUSTER-NAME]

์ธ์ฆ๋ฐ›๊ธฐ ์œ„ํ•ด์„œ๋Š” ์œ„ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

4. Deploy an application to the cluster

์ด์ œ ํด๋Ÿฌ์Šคํ„ฐ์— ์ปจํ…Œ์ด๋„ˆํ™” ๋œ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋ฐฐํฌํ•ด๋ณด์ž.

GKE๋Š” ํด๋Ÿฌ์Šคํ„ฐ์˜ ์ž์›์„ ์ƒ์„ฑํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด Kubernetes objects๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

kubectl create deployment hello-server --image=gcr.io/google-samples/hello-app:1.0
  • ์œ„์˜ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ๋ช…๋ น์–ด๋Š” hello-server๋ผ๋Š” Deployment object๋ฅผ ์ƒํ—ํ•œ๋‹ค.

  • --image ๋Š” ๋ฐฐํฌํ•  ์ปจํ…Œ์ด๋„ˆ ์ด๋ฏธ์ง€๋ฅผ ๋ช…์‹œํ•œ๋‹ค.

  • ๋ช…๋ น์–ด๋Š” Container Registry ๋ฒ„ํ‚ท์œผ๋กœ๋ถ€ํ„ฐ ์ด๋ฏธ์ง€๋ฅผ pull ํ•œ๋‹ค.

  • [gcr.io/google-samples/hello-app:1.0](<http://gcr.io/google-samples/hello-app:1.0>) ์€ pull ํ•ด ์˜ฌ ์ด๋ฏธ์ง€์˜ ์ƒ์„ธ ๋ฒ„์ „๋“ฑ์„ ๋ช…์‹œํ•œ๋‹ค. ๋งŒ์•ฝ ๋ฒ„์ „์ด ๋ช…์‹œ๋˜์–ด ์žˆ์ง€ ์•Š์œผ๋ฉด ๊ฐ€์žฅ ์ตœ์‹  ๋ฒ„์ „์„ ์‚ฌ์šฉํ•œ๋‹ค.

kubectl expose deployment hello-server --type=LoadBalancer --port 8080

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ์„œ๋น„์Šค๋ฅผ ์ƒ์„ฑํ•˜๊ธฐ ์œ„ํ•ด ์œ„ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

  • --port ๋Š” ์ปจํ…Œ์ด๋„ˆ๊ฐ€ expose ํ•  ํฌํŠธ ๋ฒˆํ˜ธ๋ฅผ ๋ช…์‹œํ•œ๋‹ค.

  • type="LoadBalancer" ๋Š” ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์œ„ํ•œ Compute Engine load balancer๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

kubectl get service

hello-server ์ ๊ฒ€ํ•˜๊ธฐ ์œ„ํ•œ ๋ช…๋ น์–ด

http://[EXTERNAL-IP]:8080

์œ„์˜ external ip ์ฃผ์†Œ๋ฅผ ์ž…๋ ฅํ•ด์„œ ์›น ์ฐฝ์— ์น˜๋ฉด ํ•ด๋‹น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์›น ๋ธŒ๋ผ์šฐ์ €์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

5. Deleting the cluster

gcloud container clusters delete [CLUSTER-NAME]

GKE ํด๋Ÿฌ์Šคํ„ฐ๋ฅผ ์‹คํ–‰ ์‹œ, benefits

Last updated