Lab3

Lab3 : Orchestrating the Cloud with Kubernetes

Lab ๋ชฉํ‘œ

  • Kubernetes Engine์„ ํ™œ์šฉํ•œ Kubernetes cluster provision

  • kubectl ์ด์šฉํ•œ ๋„์ปค ์ปจํ…Œ์ด๋„ˆ ๋ฐฐํฌ ๋ฐ ๊ด€๋ฆฌ

  • Kubernetes์˜ Deployments์™€ Services๋ฅผ ํ™œ์šฉํ•ด application์„ microservice ๋กœ ์ชผ๊ฐœ๊ธฐ

gcloud config set compute/zone us-central1-b

zone ์„ค์ •

gcloud container clusters create io

ํด๋Ÿฌ์Šคํ„ฐ ์ƒ์„ฑ

1. Get the sample code

gsutil cp -r gs://spls/gsp021/* .

GitHub repository๋ฅผ ํด๋ก ํ•œ๋‹ค.

gs ๋กœ ์‹œ์ž‘ํ•˜๋Š”๊ฒŒ google cloud storage ์ ‘๊ทผํ•˜๋Š”๊ฒƒ.

ํ•„์š”ํ•œ ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™ํ•œ๋‹ค.

2. Quick Kubernetes Demo

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค๋ฅผ ์‹œ์ž‘ํ•˜๋Š” ๊ฐ€์žฅ ์‰ฌ์šด ๋ฐฉ๋ฒ•์€ kbect1 create ์ปค๋งจ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

kubectl create deployment nginx --image=nginx:1.10.0

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

์‹คํ–‰์ค‘์ธ ๋…ธ๋“œ์— ์žฅ์• ๊ฐ€ ๋ฐœ์ƒํ•˜๋”๋ผ๋„ ๋ฐฐํฌ๋Š” ๊ณ„์† ์‹คํ–‰๋œ๋‹ค.

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์—์„œ๋Š” ๋ชจ๋“  ์ปจํ…Œ์ด๋„ˆ๋“ค์ด pod์—์„œ ์‹คํ–‰๋œ๋‹ค.

kubectl get pods

์‹คํ–‰์ค‘์ธ nginx ์ปจํ…Œ์ด๋„ˆ๋ฅผ ํ™•์ธํ•œ๋‹ค.

kubectl expose deployment nginx --port 80 --type LoadBalancer

nginx ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์‹คํ–‰์ค‘์ด๋ฉด ์œ„ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ์™ธ๋ถ€์— expose ํ•  ์ˆ˜ ์žˆ๋‹ค.

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค๊ฐ€ ๊ณต์šฉ IP ์ฃผ์†Œ๋ฅผ ํ†ตํ•ด ์™ธ๋ถ€ ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ๋ฅผ ์ƒ์„ฑํ–ˆ๋‹ค.

ํ•ด๋‹น ๊ณต์šฉ IP ์ฃผ์†Œ๋ฅผ ์กฐํšŒํ•˜๋Š” ๋ชจ๋“  ํด๋ผ์ด์–ธํŠธ๋Š” ํ•ด๋‹น pod๋กœ ๋ผ์šฐํŒ…๋œ๋‹ค.

์œ„ ๊ฒฝ์šฐ์—๋Š” nginx pod๋กœ ๋ผ์šฐํŒ…๋œ๋‹ค.

kubectl get services

ํ˜„์žฌ ์‚ฌ์šฉ์ค‘์ธ ์„œ๋น„์Šค ๋ฆฌ์ŠคํŠธ๋ฅผ ์กฐํšŒํ•œ๋‹ค.

curl http://<External IP>:80

Nginx ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์›๊ฒฉ์œผ๋กœ hit ํ•˜๊ธฐ ์œ„ํ•ด ์œ„ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

3. Pods

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์˜ ํ•ต์‹ฌ์—๋Š” Pod ๊ฐ€ ์žˆ๋‹ค.

Pods๋Š” ํ•˜๋‚˜ ์ด์ƒ์˜ ์ปจํ…Œ์ด๋„ˆ ์ง‘ํ•ฉ์„ ๋‚˜ํƒ€๋‚ธ๋‹ค. ์„œ๋กœ์— ๋Œ€ํ•œ ์˜์กด๋„๊ฐ€ ๋†’์€ ์—ฌ๋Ÿฌ๊ฐœ์˜ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋‹จ์ผ pod ๋‚ด์— ํŒจํ‚ค์ง•ํ•œ๋‹ค.

Pods์—๋Š” Volumes๊ฐ€ ์žˆ๋‹ค.

๋ณผ๋ฅจ์€ pods๊ฐ€ ์‚ด์•„์žˆ๋Š” ๋™์•ˆ ์ง€์†๋˜๋Š” ๋ฐ์ดํ„ฐ ๋””์Šคํฌ๋กœ, ํ•ด๋‹น pod์˜ ์ปจํ…Œ์ด๋„ˆ์—์„œ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•˜๋‹ค. Pods๋Š” ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๋‚ด์šฉ์— ๋Œ€ํ•œ shared namespace๋ฅผ ์ œ๊ณตํ•˜์—ฌ pod ๋‚ด๋ถ€์˜ ์ปจํ…Œ์ด๋„ˆ๋“ค์ด ์„œ๋กœ ํ†ต์‹ ํ•  ์ˆ˜ ์žˆ๊ณ , ์—ฐ๊ฒฐ๋˜์–ด ์žˆ๋Š” ๋ณผ๋ฅจ๋„ ๊ณต์œ ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค.

Pods๋Š” network namespace๋„ ๊ณต์œ ํ•˜์—ฌ ํ•˜๋‚˜์˜ pod๋‹น ํ•˜๋‚˜์˜ IP Address๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค.

4. Creating pods

Pod๋Š” pod configuration file์„ ํ†ตํ•ด ์ƒ์„ฑ๋œ๋‹ค.

cat pods/monolith.yaml
  • ํ˜„์žฌ pod๋Š” ํ•˜๋‚˜์˜ ์ปจํ…Œ์ด๋„ˆ (monolith)๋กœ ์ด๋ฃจ์–ด์ ธ์žˆ๋‹ค.

  • ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์‹œ์ž‘ํ•  ๋•Œ ๋ช‡๊ฐ€์ง€ argument๋“ค์„ ์ „๋‹ฌํ•œ๋‹ค.

  • http traffic ์„ ์œ„ํ•ด 80๋ฒˆ ํฌํŠธ๋ฅผ ์—ฐ๋‹ค.

kubectl create -f pods/monolith.yaml

์œ„ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•ด monolith pod๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

kubectl get pods

default namespace์—์„œ ์‹คํ–‰์ค‘์ธ ๋ชจ๋“  pod ๋ฆฌ์ŠคํŠธ๋ฅผ ํ™•์ธํ•œ๋‹ค.

kubectl describe pods monolith

monolith pod ์— ๋Œ€ํ•œ ์ •๋ณด๋“ค ์ถœ๋ ฅ

  • Pod IP ์ฃผ์†Œ์™€ event log๋ฅผ ํฌํ•จํ•œ ์ •๋ณด๋“ค์„ ํ™•์ธ ๊ฐ€๋Šฅํ•˜๋‹ค.

    • troubleshooting ์‹œ ์šฉ์ดํ•˜๊ฒŒ ์‚ฌ์šฉ๊ฐ€๋Šฅ

5. Interacting with pods

๊ธฐ๋ณธ์ ์œผ๋กœ pod๋“ค์€ ํ• ๋‹น๋œ ์‚ฌ์„ค IP ์ฃผ์†Œ์ด๊ณ  ํด๋Ÿฌ์Šคํ„ฐ ์™ธ๋ถ€์—์„œ ์ ‘๊ทผ์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค. ๋”ฐ๋ผ์„œ kubecgtl port-forward ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ๋กœ์ปฌ ํฌํŠธ๋ฅผ monolith pod ๋‚ด๋ถ€๋กœ ๋งคํ•‘ํ•ด์•ผํ•œ๋‹ค.

์ƒˆ๋กœ์šด ํ„ฐ๋ฏธ๋„์„ ์—ด์–ด ํ•˜๋‚˜๋Š” kubectl port-forward ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ๋‹ค๋ฅธ ํ„ฐ๋ฏธ๋„์€ curl ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•œ๋‹ค.

kubectl port-forward monolith 10080:80
curl <http://127.0.0.1:10080>

curl ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•ด pod์™€ ์†Œํ†ตํ•˜๊ธฐ

์ปจํ…Œ์ด๋„ˆ์—์„œ โ€œhelloโ€ ๋ฉ”์‹œ์ง€๋ฅผ ์ˆ˜์‹ ํ•œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

curl <http://127.0.0.1:10080/secure>

authroization fail ์‘๋‹ต์„ ์ˆ˜์‹ ํ•œ๋‹ค.

curl -u user <http://127.0.0.1:10080/login>

password๋ฅผ ์ž…๋ ฅํ•˜๋ผ๊ณ  ํ•ด์„œ ์ž…๋ ฅํ•˜๋ฉด ๋กœ๊ทธ์ธ์ด ์„ฑ๊ณตํ•˜๊ณ , JWT token์„ ์ˆ˜์‹ ๋ฐ›๋Š”๋‹ค.

TOKEN=$(curl <http://127.0.0.1:10080/login> -u user|jq -r '.token')

ํ† ํฐ ์ •๋ณด ๋ณ€์ˆ˜ ์ƒ์„ฑ

curl -H "Authorization: Bearer $TOKEN" <http://127.0.0.1:10080/secure>

Bearer Token์„ ๋‹ด์•„ ๋‹ค์‹œ ๋ณด๋‚ด๋ฉด ์ œ๋Œ€๋กœ๋œ ์‘๋‹ต์„ ๋ฐ›๊ฒŒ ๋œ๋‹ค.

kubectl logs monolith

monolith Pod์˜ ๋กœ๊ทธ๋ฅผ ๋ณด๊ธฐ ์œ„ํ•ด ์œ„ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

kubectl logs -f monolith

์ƒˆ๋กœ์šด ํ„ฐ๋ฏธ๋„์—์„œ -f ์˜ต์…˜์„ ๋ถ™์—ฌ ์‹คํ–‰ํ•˜๋ฉด ์‹ค์‹œ๊ฐ„์œผ๋กœ ๋ฐœ์ƒํ•˜๋Š” ๋กœ๊ทธ ์ŠคํŠธ๋ฆผ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค.

kubectl exec monolith --stdin --tty -c monolith -- /bin/sh

Monolith Pod ๋‚ด๋ถ€์—์„œ interactive shell์„ ์‹คํ–‰ํ•˜๊ธฐ ์œ„ํ•ด ์œ„ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

์ด๋Ÿฐ์‹์œผ๋กœ ์™ธ๋ถ€์— ping ๋ช…๋ น์–ด ๋“ฑ์„ ์ด์šฉํ•ด ์™ธ๋ถ€ ์—ฐ๊ฒฐ์„ฑ์„ ํ…Œ์ŠคํŠธํ•  ์ˆ˜ ์žˆ๋‹ค.

exit

interactive shell์„ ์ข…๋ฃŒํ•  ๋•Œ๋Š” exit ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

์„œ๋น„์Šค๋Š” pod์—๋‹ค๊ฐ€ ๋งคํ•‘ํ•ด์„œ ๊ณ„์† ๊ด€๋ฆฌํ•ด์ฃผ๋Š” ํ•˜๋‚˜์˜ cluster๋Š” ์ตœ์†Œ ๋งˆ์Šคํ„ฐ ์„œ๋น„์Šค๋ฅผ ๊ฐ€์ง€๊ณ ์žˆ์Œ.

6. Services

Pods๋“ค์€ ์˜์›ํ•˜์ง€์•Š๋‹ค. ๋งŒ์•ฝ ์žฌ์‹œ์ž‘๋˜๋ฉด ํ•ด๋‹น pod๋“ค์€ ๋‹ค๋ฅธ IP ์ฃผ์†Œ๋ฅผ ๊ฐ€์ง€๊ฒŒ ๋  ๊ฒƒ์ด๋‹ค. ์ด๋Ÿด ๋•Œ Services๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

Services๋Š” pods๋“ค์˜ ๊ณ ์ • endpoint๋ฅผ ์ œ๊ณตํ•œ๋‹ค.

์„œ๋น„์Šค๋Š” ๋ผ๋ฒจ์„ ์‚ฌ์šฉํ•˜์—ฌ ์–ด๋–ค pod์—์„œ ์ž‘๋™ํ•˜๋Š”์ง€ ํŒ๋ณ„ํ•œ๋‹ค.

์„œ๋น„์Šค ํƒ€์ž…์— ๋”ฐ๋ฅธ service ๋‹จ๊ณ„

  • ClusterIP (internal) : ํ•ด๋‹น ์„œ๋น„์Šค๊ฐ€ ํด๋Ÿฌ์Šคํ„ฐ ๋‚ด๋ถ€์—์„œ๋งŒ ๋ณด์ธ๋‹ค

  • NodePort : ํด๋Ÿฌ์Šคํ„ฐ์˜ ๊ฐ ๋…ธ๋“œ์— ์™ธ๋ถ€์—์„œ ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ๋Š” Ip๋ฅผ ์ œ๊ณต

  • LoadBalancer : ํด๋ผ์šฐ๋“œ ์ œ๊ณต์ž์˜ ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์„œ๋น„์Šค์—์„œ ๋…ธ๋“œ๋กœ ํŠธ๋ž˜ํ”ฝ์„ ์ „๋‹ฌํ•œ๋‹ค.

์ด์ œ ์„œ๋น„์Šค๋ฅผ ์ƒ์„ฑํ•˜๊ณ  label selectors๋ฅผ ์ด์šฉํ•˜์—ฌ ์™ธ๋ถ€์— ๋…ธ์ถœํ•˜์ž.

7. Creating a service

์„œ๋น„์Šค ์ƒ์„ฑ ์ „ https traffic๋ฅผ ๋‹ค๋ฃจ๋Š” ์•ˆ์ „ํ•œ pod๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

kubectl create secret generic tls-certs --from-file tls/
kubectl create configmap nginx-proxy-conf --from-file nginx/proxy.conf
kubectl create -f pods/secure-monolith.yaml

secure-monolith pods ์™€ configuration data๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

cat services/monolith.yaml

monolith service configuration file

  • ๋ผ๋ฒจ app: monolith ์™€ secure: enbaled ๊ฐ€ ์žˆ๋Š” pod๋“ค์„ ์ž๋™์œผ๋กœ ์ฐพ๊ณ  expose ํ•˜๋Š” selector๊ฐ€ ์žˆ๋‹ค.

  • ์—ฌ๊ธฐ์— nodeport๋ฅผ exposeํ•ด์„œ 31000๋ฒˆ ํฌํŠธ์—์„œ ngins(port 443)์œผ๋กœ ์™ธ๋ถ€ ํŠธ๋ž˜ํ”ฝ์„ ์ „์†กํ•ด์•ผํ•œ๋‹ค.

kubectl create -f services/monolith.yaml

์œ„ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•ด monolith service configuration file๋กœ๋ถ€ํ„ฐ monolith service๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

์ด์ œ ์„œ๋น„์Šค๋ฅผ expose ํ•˜๊ธฐ ์œ„ํ•ด 31000๋ฒˆ ํฌํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋‹ค.

๋‹ค๋ฅธ ์•ฑ์ด ํ•ด๋‹น ํฌํŠธ์— ๋ฐ”์ธ๋”ฉํ•˜๋ ค๊ณ  ํ•˜๋ฉด ์ถฉ๋Œ์ด ์ƒ๊ธด๋‹ค.

์ผ๋ฐ˜์ ์œผ๋กœ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค๋Š” ์ด๋Ÿฌํ•œ ํฌํŠธ assignment๋ฅผ ์กฐ์ •ํ•œ๋‹ค.

gcloud compute firewall-rules create allow-monolith-nodeport \\
  --allow=tcp:31000

์œ„ ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•ด exposed node port์˜ monolith service๋กœ์˜ ํŠธ๋ž˜ํ”ฝ์„ ํ—ˆ์šฉํ•œ๋‹ค.

์ด์ œ ํด๋Ÿฌ์Šคํ„ฐ ์™ธ๋ถ€์—์„œ port forwarding ์—†์ด๋„ secure-monolith service์— hit ํ•  ์ˆ˜ ์žˆ๋‹ค.

gcloud compute instances list

์œ„ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ๋…ธ๋“œ ์ค‘ ํ•˜๋‚˜์˜ ์™ธ๋ถ€ IP ์ฃผ์†Œ๋ฅผ ํ™•์ธํ•œ๋‹ค.

curl -k https://<EXTERNAL_IP>:31000

์ด๋Ÿฌ๋ฉด ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค. ์ด์ œ ํ•ด๊ฒฐํ•ด๋ณด์ž

8. Adding labels to pods

์ง€๊ธˆ monolith service๋Š” endpoint๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์ง€ ์•Š๋‹ค.

kubectl get pods -l "app=monolith"

monolith label์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์‹คํ–‰์ค‘์ธ pods๋“ค์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

kubectl get pods -l "app=monolith,secure=enabled"

๊ตฌ์ฒด์ ์ธ ๋ผ๋ฒจ๋“ค์„ ํ™•์ธํ•˜๋ฉด?

์•„๋ฌด๋Ÿฐ ๋ฆฌ์†Œ์Šค๋„ ์—†๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— ์œ„์—์„œ ์˜ค๋ฅ˜๊ฐ€ ๋‚ฌ๋˜ ๊ฒƒ์ด๊ณ , secure=enabled ๋ผ๋ฒจ์„ ์ถ”๊ฐ€ํ•ด์ฃผ์–ด์•ผํ•œ๋‹ค.

kubectl label pods secure-monolith 'secure=enabled'
kubectl get pods secure-monolith --show-labels

๋ผ๋ฒจ์„ ๋ถ™์ด๊ณ  ๋ผ๋ฒจ์ด ์—…๋ฐ์ดํŠธ ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค.

kubectl describe services monolith | grep Endpoints

์ •์ƒ์ ์œผ๋กœ ์ž˜ ๋ถ™์—ˆ๋‹ค๋ฉด monolith ์„œ๋น„์Šค์˜ ์—”๋“œํฌ์ธํŠธ ๋ฆฌ์ŠคํŠธ๋ฅผ ํ™•์ธํ•œ๋‹ค.

gcloud compute instances list
curl -k https://<EXTERNAL_IP>:31000

์ž˜ ๋Œ์•„๊ฐ„๋‹ค!

9. Deploying applications with Kubernetes

์ด์ œ ์ปจํ…Œ์ด๋„ˆ๋“ค์„ scalingํ•˜๊ณ  ๋งค๋‹ˆ์ง•ํ•ด๋ณด์ž.

Deployments๋Š” ์‹คํ–‰ ์ค‘์ธ pods์˜ ์ˆ˜๊ฐ€ ์‚ฌ์šฉ์ž๊ฐ€ ์ง€์ •ํ•œ ์›ํ•˜๋Š” pods์˜ ์ˆ˜์™€ ๊ฐ™๋„๋ก ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค.

The main benefit of Deployments is in abstracting away the low level details of managing Pods. Behind the scenes Deployments use Replica Sets to manage starting and stopping the Pods. If Pods need to be updated or scaled, the Deployment will handle that. Deployment also handles restarting Pods if they happen to go down for some reason.

10. Creating deployments

ํ˜„์žฌ ์ง„ํ–‰ํ•˜๋˜ ์•ฑ์„ ์„ธ๊ฐ€์ง€ ํŒŒํŠธ๋กœ ๋‚˜๋ˆ„๋ฉด

  • auth : ์ธ์ฆ๋œ ์‚ฌ์šฉ์ž๋“ค์—๊ฒŒ JWT token ์ƒ์„ฑ

  • hello : ์ธ์ฆ๋œ ์‚ฌ์šฉ์ž๋“ค์—๊ฒŒ ์ธ์‚ฌ

  • frontend : auth์™€ hello ์„œ๋น„์Šค๋“ค์— ํŠธ๋ž˜ํ”ฝ์„ ๋ผ์šฐํŒ…ํ•จ.

auth์™€ hello deployments๋ฅผ ์œ„ํ•œ ๋‚ด๋ถ€์ ์ธ ์„œ๋น„์Šค๋“ค์„ ์ •์˜ํ•˜๊ณ  frontend deployment๋ฅผ ์œ„ํ•œ ์™ธ๋ถ€ ์„œ๋น„์Šค๋ฅผ ์ •์˜ํ•œ๋‹ค.

cat deployments/auth.yaml

auth deployment configuration file ์ƒ์„ฑ

  • deployment๋Š” ํ•˜๋‚˜์˜ replica๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

  • auth ์ปจํ…Œ์ด๋„ˆ์˜ ๋ฒ„์ „ 2.0.0 ์„ ์‚ฌ์šฉํ•œ๋‹ค.

  • When you run the kubectl create command to create the auth deployment it will make one pod that conforms to the data in the Deployment manifest. This means you can scale the number of Pods by changing the number specified in the Replicas field.

kubectl create -f deployments/auth.yaml

์œ„ ๋ช…๋ น์–ด๋กœ deployment object๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

kubectl create -f services/auth.yaml

auth deployment๋ฅผ ์œ„ํ•œ ์„œ๋น„์Šค๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

kubectl create -f deployments/hello.yaml
kubectl create -f services/hello.yaml
kubectl create configmap nginx-frontend-conf --from-file=nginx/frontend.conf
kubectl create -f deployments/frontend.yaml
kubectl create -f services/frontend.yaml

๋™์ผํ•˜๊ฒŒ hello deployment์™€ frontend Deployment์—๋„ ์ ์šฉํ•œ๋‹ค.

kubectl get services frontend
curl -k https://<EXTERNAL-IP>

frontend์˜ ์™ธ๋ถ€ IP ์ฃผ์†Œ๋ฅผ ํ†ตํ•ด curlingํ•ด์„œ interact ํ•œ๋‹ค.

Study More

  • Pod๊ฐ€ ๋ฌด์—‡์ธ์ง€?

  • LoadBalancer

  • Scaling ์ด ๋ฌด์—‡์ด๋ƒ์•…

LoadBalancer ์„œ๋น„์Šค ํƒ€์ž…์€ ๋‹จ์ง€ ํ•œ๊ฐœ์˜ ๋‚ด๋ถ€ ์„œ๋น„์Šค๋ฅผ ์™ธ๋ถ€ ์‚ฌ์šฉ์ž๋“ค์—๊ฒŒ ์ ‘๊ทผ ๊ฐ€๋Šฅํ•˜๋„๋ก ๋งŒ๋“œ๋Š” ์ผ์„ ๋‹ด๋‹นํ•ฉ๋‹ˆ๋‹ค. ๋ฐ˜๋Œ€๋กœ Ingress ์„œ๋น„์Šค ํƒ€์ž…์€ ์—ฌ๋Ÿฌ๊ฐœ์˜ ์„œ๋น„์Šค๊ฐ€ ํ•œ๊ฐœ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๋ฅผ ํ†ตํ•ด ์œ ์—ฐํ•œ ์„ค์ •์„ ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

Kubernetes NodePort vs LoadBalancer vs Ingress? When should I use what?

Kubernetes NodePort vs LoadBalancer vs Ingress? When should I use what?Recently, someone asked me what the difference between NodePorts, LoadBalancers, and Ingress were. They are all different ways to getโ€ฆmedium.com

Load Balancer๋Š” ํ•œ๊ฐœ์˜ ๋‚ด๋ถ€ ์„œ๋น„์Šค๋ฅผ ์™ธ๋ถ€๋กœ ์ ‘๊ทผ ๊ฐ€๋Šฅํ•œ๊ฑฐ๊ณ 

Ingress๋Š” load balancer๋ฅผ ๋Œ€์ฒดํ•˜๋ฉด์„œ ๋“ค์–ด๊ฐ. L7 ๊ณ„์ธต์—์„œ ๋ผ์šฐํŒ…์„ํ•ด์ฃผ๋Š”๊ฒƒ. ๊ทธ๋ž˜์„œ url๊นŒ์ง€ ๋ผ์šฐํŒ…ํ•ด์คŒ.

L4 ๋Š” ๋‹จ์ˆœํžˆ ๋ถ€ํ•˜๋ฅผ ๋ถ„์‚ฐ์‹œํ‚ค๋Š”๊ฒƒ.

Last updated