๐Ÿฅ” ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ๋ชจ๋‹ˆํ„ฐ๋ง [Istio, ๋ฉ”์‹œ ๋ชจ๋‹ˆํ„ฐ๋ง]

๊น€์„ฑ์ธยท2023๋…„ 10์›” 21์ผ
0

[DevOps] ๐ŸณDocker & Kubernetes

๋ชฉ๋ก ๋ณด๊ธฐ
49/62

https://istio.io/latest/about/service-mesh/

Istio

๊ฐ๊ฐ ์ปจํ…Œ์ด๋„ˆ์˜ ํŠธ๋ž˜ํ”ฝ์„ ๊ด€์ฐฐํ•  ์ˆ˜ ์žˆ๋„๋ก ํ”„๋ก์‹œ๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜

  • ๋‹ค์ˆ˜ ์ปจํ…Œ์ด๋„ˆ ํ™˜๊ฒฝ์—์„œ ๊ฐ ์ปจํ…Œ์ด๋„ˆ์˜ ํŠธ๋ž˜ํ”ฝ ๊ด€์ฐฐ์ด ์ •์ƒ ๋™์ž‘ํ•˜๋Š”์ง€ ๋ชจ๋‹ˆํ„ฐ๋ง ํ•˜๊ธฐ ์–ด๋ ค์›€
  • ๊ฐœ๋ฐœ์ž๋Š” ์ด์‹์„ฑ์„ ์œ„ํ•ด MSA๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์•„ํ‚คํ…์ฒ˜๋ฅผ ์„ค๊ณ„ํ•˜๊ณ , ์šด์˜์ž๋Š” ํ•ด๋‹น ์ปจํ…Œ์ด๋„ˆ๋“ค์„ ๋‹ค์–‘ํ•œ ํด๋Ÿฌ์Šคํ„ฐ์— ๋ฐฐํฌํ•˜๊ณ  ๊ด€๋ฆฌ
  • ์„œ๋น„์Šค ๋ฉ”์‹œ์˜ ํฌ๊ธฐ์™€ ๋ณต์žก์„ฑ์ด ์ปค์ง์— ๋”ฐ๋ผ ์ดํ•ดํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๊ธฐ ์–ด๋ ค์›Œ์ง (๋กœ๋“œ๋ฐธ๋Ÿฐ์‹ฑ, ์žฅ์• ๋ณต๊ตฌ, ๋ฉ”ํŠธ๋ฆญ & ๋ชจ๋‹ˆํ„ฐ๋ง ๋“ฑ)

1. Istio ๋‹ค์šด๋กœ๋“œ

https://istio.io/latest/docs/setup/getting-started/#download

curl -L https://istio.io/downloadIstio | sh -
cd istio-1.19.3
export PATH=$PWD/bin:$PATH

istioctl: istio๋Š” kubectl ์„ ๋‚ด๋ถ€์ ์œผ๋กœ ์‚ฌ์šฉํ•จ

2. Istio ์„ค์น˜

https://istio.io/latest/docs/setup/getting-started/#install

  1. demo configuration prpofile ์‚ฌ์šฉ.
  • ํ”Œ๋žซํผ์— vendor-config profile์ด ์žˆ๋Š” ๊ฒฝ์šฐ demo ํ”„๋กœํ•„ ๋Œ€์‹  ๋‹ค๋ฅธ ๊ฒƒ์„ ์‚ฌ์šฉ
    istioctl install --set profile=demo -y
  1. ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋ฐฐํฌํ•  ๋•Œ Envoy ์‚ฌ์ด๋“œ์นด ํ”„๋ก์‹œ๋ฅผ ์ž๋™์œผ๋กœ ์‚ฝ์ž…ํ•˜๋„๋ก Istio์— ๋„ค์ž„์ŠคํŽ˜์ด์Šค ๋ผ๋ฒจ์„ ์ถ”๊ฐ€
    kubectl label namespace default istio-injection=enabled
  • ์ดํ›„ ๋ฐฐ์น˜๋˜๋Š” ํฌ๋“œ์— ์‚ฌ์ด๋“œ์นด ํ”„๋ก์‹œ๊ฐ€ ๊ตฌ์„ฑ์ด๋จ

3. sample ์•ฑ ๋””ํ”Œ๋กœ์ด & ๋ฐฐํฌ ํ™•์ธ

kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
kubectl get services
kubectl get pods
kubectl exec "$(kubectl get pod -l app=ratings -o jsonpath='{.items[0].metadata.name}')" -c ratings -- curl -sS productpage:9080/productpage | grep -o "<title>.*</title>"

istioctl install ์•ˆํ•˜๊ณ  ์•ฑ ๋“œํ•„๋กœ์ด ์‹œ ์—๋Ÿฌ ๋ฐœ์ƒ

Warning  FailedCreate  2s (x13 over 23s)  replicaset-controller  Error creating: Internal error occurred: failed calling webhook "namespace.sidecar-injector.istio.io": failed to call webhook: Post "https://istiod.istio-system.svc:443/inject?timeout=10s": service "istiod" not found

4. ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์™ธ๋ถ€ ํŠธ๋ž˜ํ”ฝ

  1. Istio ์ธ๊ทธ๋ ˆ์Šค ๊ฒŒ์ดํŠธ์›จ์ด ์ƒ์„ฑ
    kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
  2. istioctl ์ด์ƒ ์—†๋‚˜ ํ™•์ธ
    istioctl analyze

๊ฒŒ์ดํŠธ์›จ์ด ์ƒ์„ฑ ์ „ 3. ์•ฑ ๋””ํ”Œ๋กœ์ด ์™„์„ฑ๋˜์–ด์•ผํ•จ

$ kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
Error from server (InternalError): error when creating "samples/bookinfo/networking/bookinfo-gateway.yaml": Internal error occurred: failed calling webhook "validation.istio.io": failed to call webhook: Post "https://istiod.istio-system.svc:443/validate?timeout=10s": service "istiod" not found

5. ์ธ๊ทธ๋ ˆ์„œ IP, ํฌํŠธ ์„ค์ •

https://istio.io/latest/docs/setup/getting-started/#determining-the-ingress-ip-and-ports

5-1) kubectl get svc istio-ingressgateway -n istio-system ๋ฅผ ํ†ตํ•ด External Ip๋ฅผ ํ• ๋‹น๋œ ๊ฑธ ๋ณด๊ณ  ๋กœ๋“œ๋ฐธ๋Ÿฐ์‹ฑ์ด ์ž‘๋™ํ•˜๋Š”์ง€ ํ™•์ธ.

  • ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค๋ฉด NodePort๋ฅผ ํ†ตํ•ด ์ ‘์† ๊ฐ€๋Šฅํ•จ.

5-2) ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ธ๊ทธ๋ ˆ์Šค IP, ํฌํŠธ ์„ค์ •

export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}')
export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].port}')

ํŠน์ • ํ™˜๊ฒฝ์—์„œ Ingress๊ฐ€ External IP๊ฐ€ ์•„๋‹Œ hostname์„ ํ†ตํ•ด์„œ expose ๋œ๋‹ค๋ฉด,
export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') ๋ฅผ ํ†ตํ•ด์„œ INGRESS_HOST๋ณ€์ˆ˜๋ฅผ ์„ค์ •ํ• ๊ฒƒ.

5-3) ๋…ธ๋“œํฌํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ธ๊ทธ๋ ˆ์Šค IP, ํฌํŠธ ์„ค์ •

export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].nodePort}')
export INGRESS_HOST=worker-node-address

GKE ํ™˜๊ฒฝ์—์„œ ๋ฐฉํ™”๋ฒฝ ์ œ๊ฑฐ ํ• ๊ฒƒ
gcloud compute firewall-rules create allow-gateway-http --allow "tcp:$INGRESS_PORT"
gcloud compute firewall-rules create allow-gateway-https --allow "tcp:$SECURE_INGRESS_PORT"

5-4) ๊ฒŒ์ดํŠธ์›จ์ด URL ์„ค์ •

export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT
echo "$GATEWAY_URL"

5-5) ์™ธ๋ถ€ ์ ‘๊ทผ ํ™•์ธ

echo "http://$GATEWAY_URL/productpage" : ๊ฒฐ๊ณผ๋ฅผ ์›น ๋ธŒ๋ผ์šฐ์ €์— ๋ถ™์—ฌ๋„ฃ๊ธฐ ํ•ด์„œ ํŽ˜์ด์ง€๊ฐ€ ๋œจ๋Š”์ง€ ํ™•์ธ

6. ๋Œ€์‹œ๋ณด๋“œ ๋ณด๊ธฐ

6-1) Kiali, Addons๋ฅผ ์‚ฌ์šฉํ•ด ๋ฐฐํฌ

kubectl apply -f samples/addons
kubectl rollout status deployment/kiali -n istio-system

6-2) Kiali ๋Œ€์‹œ๋ณด๋“œ ์ ‘๊ทผ

istioctl dashboard kiali

6-3) ๋„ค๋น„๊ฒŒ์ด์…˜ ์„ค์ •

  • Graph -> Namespace -> default ์„ ํƒ

6-4)

To see trace data, you must send requests to your service. The number of requests depends on Istioโ€™s sampling rate and can be configured using the Telemetry API. With the default sampling rate of 1%, you need to send at least 100 requests before the first trace is visible. To send a 100 requests to the productpage service, use the following command:

$ for i in $(seq 1 100); do curl -s -o /dev/null "http://$GATEWAY_URL/productpage"; done

profile
๊ฐœ๋ฐœ์ž๊ฐ€ ๊ฟˆ์ธ 25์‚ด ๋Œ€ํ•™์ƒ์ž…๋‹ˆ๋‹ค.

0๊ฐœ์˜ ๋Œ“๊ธ€