Istio ๐Ÿ‘บ

bo-yoonยท2021๋…„ 6์›” 20์ผ
1

msa

๋ชฉ๋ก ๋ณด๊ธฐ
7/7
post-thumbnail

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค๋กœ ์„œ๋น„์Šค๋ฅผ ์šด์˜ ํ•˜๋ฉฐ "์ด์Šคํ‹ฐ์˜ค"๋ฅผ ๊ฐ™์ด ์‚ฌ์šฉํ•œ๋‹ค. ์ด์Šคํ‹ฐ์˜ค๋ฅผ ๋ฌด์—‡์ด๊ณ , ์ด์Šคํ‹ฐ์˜ค๋ฅผ ์‚ฌ์šฉํ•˜๋ฏ€๋กœ์จ ์–ป์„ ์ˆ˜ ์žˆ๋Š” ์žฅ์ ์€ ๋ฌด์—‡์ผ์ง€ ์‚ดํŽด๋ณด์ž!


์ •์˜

๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค ๊ฐ„ ๋ฐ์ดํ„ฐ ๊ณต์œ ๋ฅผ ์ œ์–ด ๋ฐ ์„œ๋น„์Šค ํƒ์ƒ‰, ๋กœ๋“œ ๋ฒจ๋Ÿฐ์‹ฑ, ํŠธ๋ Œ์ ์…˜ ๊ด€๋ฆฌ, ์ถ”์ , ์„œํ‚ท ๋ธŒ๋ ˆ์ดํฌ ๋“ฑ msa ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•œ ์˜คํ”ˆ์†Œ์Šค ์„œ๋น„์Šค ๋ฉ”์‹œ ํ”Œ๋žซํผ.

๋งˆ์ดํฌ๋กœ ์„œ๋น„์Šค๋ฅผ ์‚ฌ์šฉํ•˜๋‹ค ๋ณด๋ฉด ์—ฌ๋Ÿฌ ์ด์Šˆ๊ฐ€ ๋งŽ์ด ๋ฐœ์ƒํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ์„œ๋น„์Šค๊ฐ€ ๋ถ„๋ฆฌ๊ฐ€ ๋˜์–ด์žˆ๋‹ค๋ณด๋‹ˆ ํŠธ๋ Œ์ ์…˜ ๊ด€๋ฆฌ๊ฐ€ ์–ด๋ ค์›Œ์กŒ๊ณ , ์–ด๋–ค ์„œ๋น„์Šค๋กœ ์–ด๋–ป๊ฒŒ ์ฐพ์•„ ๊ฐˆ์ง€์— ๋Œ€ํ•œ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์‹ฑ ๋ฌธ์ œ๋„ ๋ฐœ์ƒํ•˜์˜€๋‹ค. ์ด์Šคํ‹ฐ์˜ค๋Š” ์ด๋Ÿฌํ•œ ๋ฌธ์ œํ•ด๊ฒฐ์„ ์œ„ํ•œ ๊ธฐ๋Šฅ์„ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง๊ณผ ๋ถ„๋ฆฌํ•ด, ์ธํ”„๋ผ ๊ณ„์ธต์—์„œ ์ˆ˜ํ–‰ํ•˜๊ฒŒ ๋„์™€์ฃผ๋Š” ์„œ๋น„์Šค ๋ฉ”์‹œ ํ”Œ๋žซํผ์ด๋‹ค



์„œ๋น„์Šค ๋ฉ”์‹œ๋ž€?

๊ทธ๋Ÿผ ์„œ๋น„์Šค ๋ฉ”์‹œ๋ž€ ๋ฌด์—‡์ผ๊นŒ? ์„œ๋น„์Šค ๋ฉ”์‹œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ •์˜ํ•œ๋‹ค.

์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๋‹ค์–‘ํ•œ ๋ถ€๋ถ„์ด ์„œ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๊ณต์œ ํ•˜๋Š” ๋ฐฉ์‹์„ ์ œ์–ดํ•˜๋Š” ๋ฐฉ๋ฒ•์ด์ž, ์„œ๋น„์Šค ํƒ์ƒ‰ ๋ฐ ์ถ”์ , ๋กœ๋“œ๋ฒจ๋Ÿฐ์‹ฑ ๋“ฑ msa ๋ฌธ์ œ ํ•ด๊ฒฐ์„ ๋„์™€์ค€๋‹ค.
์„œ๋น„์Šค ๋ฉ”์‹œ์—์„œ๋Š” ์‚ฌ์ด๋“œ์นด(sidecar)๋กœ ์ฃผ์ž…๋œ ์„œ๋น„์Šค์— ์žˆ๋Š” ํ”„๋ก์‹œ ๋ผ๋ฆฌ ํ†ต์‹ ํ•œ๋‹ค.

๋”ฐ๋ผ์„œ ์„œ๋น„์Šค ๋ฉ”์‹œ๋Š” ๊ฒ€์ƒ‰, ์นด๋‚˜๋ฆฌ ๋ฐฐํฌ, ์†๋„ ์ œํ•œ, ์—‘์„ธ์Šค ์ œ์–ด, ์•”ํ˜ธํ™”, ์„œํ‚ท ๋ธŒ๋ ˆ์ดํฌ, ๋กœ๋“œ๋ฒจ๋Ÿฐ์‹ฑ, ์žฅ์•  ๋ณต๊ตฌ, ๋ฉ”ํŠธ๋ฆญ ๋ฐ ๋ชจ๋‹ˆํ„ฐ๋ง ๋“ฑ ๋‹ค์–‘ํ•œ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•œ๋‹ค.



์ด๋ฒˆ์—๋Š” ์ด์Šคํ‹ฐ์˜ค ๊ตฌ์„ฑ์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์ž.
์ด์Šคํ‹ฐ์˜ค๋Š”

๊ตฌ์„ฑ : istio 1.10 ์ด์ƒ ๋ฒ„์ „ ๊ธฐ์ค€

  • ๋ฐ์ดํ„ฐ ํ”Œ๋ ˆ์ธ
    ํŠธ๋ž˜ํ”ฝ์„ ์ปจํŠธ๋กค ํ•˜๋Š” ๋ชฉ์ ์œผ๋กœ ์ œ๊ณตํ•˜๋Š” ์˜์—ญ
    ๋ฐ์ดํ„ฐ ํ”Œ๋ž˜์ธ์€ Envoy Proxy ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

  • Envoy proxy
    L4, L7 ์ง€์›, ์„œ๋ฒ„๊ฐ„์˜ ๋ถ€ํ•˜ ๋ถ„์‚ฐ๋Ÿ‰ ์กฐ์ ˆ๊ฐ€๋Šฅ.
    ๋‹ค์–‘ํ•œ ํ†ต๊ณ„ ๊ธฐ๋Šฅ ์ œ๊ณต
    tls ์•”ํ˜ธํ™”, ์ธ์ฆ ๋ฐ ์•ˆ์ „ํ•œ ํ†ต์‹  ์ œ๊ณต
    ๋กœ๋“œ ๋ฒจ๋Ÿฐ์‹ฑ ๋“ฑ ์•ก์„ธ์Šค ์ œ์–ด ๋ฐ ์†๋„์ œํ•œ, ํ• ๋‹น๋Ÿ‰ ์ง€์›
    Zipkin์„ ํ†ตํ•œ ๋ถ„์‚ฐํŠธ๋žœ์ ์…˜ ์ถ”์  ๊ธฐ๋Šฅ ์ œ๊ณต
    ํ’๋ถ€ํ•œ ๋ผ์šฐํŒ… ๊ทœ์น™, ์žฌ์‹œ๋„, ์žฅ์•  ์กฐ์น˜๋“ฑ์œผ๋กœ ํŠธ๋ž˜ํ”ฝ ๋™์ž‘ ์ œ์–ด, ์„œํ‚ท ๋ธŒ๋ž˜์ด์ปค
    http ๋“ฑ tcp ํŠธ๋ž˜ํ”ฝ์— ๋Œ€ํ•œ ์ž๋™ ๋กœ๋“œ ๋ฒจ๋Ÿฐ์‹ฑ ์ œ๊ณต

  • ์ปจํŠธ๋กค ํ”Œ๋ ˆ์ธ
    ๋ฐ์ดํ„ฐ ์˜์—ญ์œผ๋กœ ์–ด๋–ค ๋ฐฉ์‹์œผ๋กœ ์–ด๋– ํ•œ ํŠธ๋ž˜ํ”ฝ์œผ๋กœ ํ๋ฅด๋„๋ก ์ œ์–ดํ•˜๋Š” ์˜์—ญ
    ๋ฐ์ดํ„ฐ ์˜์—ญ์— ๋Œ€ํ•œ ์ปจํ”ผ๊ทธ ๊ฐ’์„ ์ €์žฅํ•œ๋‹ค.

Gateway
standalone envoy proxy ํ˜•ํƒœ๋กœ istio-ingress-gateway์—์„œ ์ง์ ‘์ ์œผ๋กœ ํŠธ๋ž˜ํ”ฝ์„ ๋ฐ›์œผ๋ฉฐ ์„œ๋น„์Šค ๋ฉ”์‹œ์— ๋Œ€ํ•œ inbound, outbound ํŠธ๋ž˜ํ”ฝ์„ ๊ด€๋ฆฌํ•œ๋‹ค.

Virtual Service
์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ์„œ๋น„์Šค๋กœ ๋ผ์šฐํŒ… ๋˜๊ฒŒ ๊ตฌ์„ฑํ•˜๋Š” ์ด์Šคํ‹ฐ์˜ค ์˜ค๋ธŒ์ ํŠธ
๋ฒ„์ถ”์–ผ ์„œ๋น„์Šค๊ฐ€ ์—†๋Š” ๊ฒฝ์šฐ, envoy proxy ๋Š” ๋ชจ๋“  ์„œ๋น„์Šค ์ธ์Šคํ„ด์Šค ๊ฐ„์— ๋ผ์šด๋“œ๋กœ๋นˆ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์‹ฑ์„ ์‚ฌ์šฉํ•ด ํŠธ๋ž˜ํ”ฝ์„ ๋ถ„์‚ฐ์‹œํ‚ด.

destination role
์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ์„œ๋น„์Šค ๋‚ด์—์„œ ์–ด๋Š ํŒŒ๋“œ๋กœ ํŠธ๋ž˜ํ”ฝ์„ ๋ณด๋‚ผ์ง€์— ๊ด€๋ จ๋จ.



์ด์Šคํ‹ฐ์˜ค ์„ค์น˜

๊ธฐ๋ณธ ์„ค์น˜

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

istioctl install --set profile=demo -y

์—๋“œ์˜จ ์„ค์น˜

  • ์ด์Šคํ‹ฐ์˜ค ์—๋“œ์˜จ
    https://github.com/istio/istio.git

  • grafana : ์˜คํ”ˆ ์†Œ์Šค ๋ฐ์ดํ„ฐ ์‹œ๊ฐํ™” ๋„๊ตฌ, ๋ฉ”ํŠธ๋ฆญ ๋ถ„์„ ํ”Œ๋žซํผ

  • jaeger : ๋ถ„์‚ฐ ์„œ๋น„์Šค๊ฐ„ ํŠธ๋žœ์žญ์…˜์„ ์ถ”์ ํ•˜๋Š” ์˜คํ”ˆ ์†Œ์Šค ์†Œํ”„ํŠธ์›จ์–ด

  • kiali : ์ด์Šคํ‹ฐ์˜ค๋ฅผ ํ†ตํ•ด ์„œ๋น„์Šค ๋งค์‰ฌ๋ฅผ ๊ตฌ์„ฑํ•˜๊ณ  ์ด๋ฅผ ๋ชจ๋‹ˆํ„ฐ๋ง ํ•  ์ˆ˜ ์žˆ๋Š” ํˆด

  • prometheus : ์˜คํ”ˆ ์†Œ์Šค ๋ชจ๋‹ˆํ„ฐ๋ง ํˆด

/sample/addons

kubectl apply -f grafana.yaml
kubectl apply -f prometheus.yaml
kubectl apply -f jaeger.yaml

์‹ค์Šต (์ผ๋ฐ˜)

https://istio.io/latest/docs/examples/bookinfo/

bookinfo ์˜ˆ์ œ

1) ์‚ฌ์ด๋“œ์นด ์ฃผ์ž…

  • ํ•ด๋‹น
 kubectl label namespace default istio-injection=enabled
 

2) ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋„์šฐ๊ธฐ

kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.10/samples/bookinfo/platform/kube/bookinfo.yaml
  • ์„œ๋น„์Šค ๋œฌ๊ฒƒ์ด ๋งŽ์Œ
โžœ  bookinfo kubectl get all
NAME                                  READY   STATUS    RESTARTS   AGE
pod/details-v1-79f774bdb9-t77qz       1/1     Running   0          13m
pod/productpage-v1-6b746f74dc-z24zv   1/1     Running   0          13m
pod/ratings-v1-b6994bb9-xxmg2         1/1     Running   0          13m
pod/reviews-v1-545db77b95-f725q       1/1     Running   0          13m
pod/reviews-v2-7bf8c9648f-6557r       1/1     Running   0          13m
pod/reviews-v3-84779c7bbc-4hqbr       1/1     Running   0          13m

NAME                  TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
service/details       ClusterIP   10.108.214.88   <none>        9080/TCP   13m
service/kubernetes    ClusterIP   10.96.0.1       <none>        443/TCP    17d
service/productpage   ClusterIP   10.103.117.9    <none>        9080/TCP   13m
service/ratings       ClusterIP   10.105.22.13    <none>        9080/TCP   13m
service/reviews       ClusterIP   10.98.132.54    <none>        9080/TCP   13m

NAME                             READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/details-v1       1/1     1            1           13m
deployment.apps/productpage-v1   1/1     1            1           13m
deployment.apps/ratings-v1       1/1     1            1           13m
deployment.apps/reviews-v1       1/1     1            1           13m
deployment.apps/reviews-v2       1/1     1            1           13m
deployment.apps/reviews-v3       1/1     1            1           13m

NAME                                        DESIRED   CURRENT   READY   AGE
replicaset.apps/details-v1-79f774bdb9       1         1         1       13m
replicaset.apps/productpage-v1-6b746f74dc   1         1         1       13m
replicaset.apps/ratings-v1-b6994bb9         1         1         1       13m
replicaset.apps/reviews-v1-545db77b95       1         1         1       13m
replicaset.apps/reviews-v2-7bf8c9648f       1         1         1       13m
replicaset.apps/reviews-v3-84779c7bbc       1         1         1       13m

3) ๊ฒŒ์ดํŠธ์›จ์ด, ๋ฒ„์ธ„์–ผ ์„œ๋น„์Šค
: ๋„คํŠธ์›Œํฌ ์„ค์ •์„ ํ•ด์ค€๋‹ค.

  • ์ผ๋ฐ˜์ ์ธ ๊ฒŒ์ดํŠธ์›Œ์ด : ํ†ต์—ญ์‚ฌ ( ๋‘๊ฐœ์˜ ์ปดํ“จํ„ฐ๊ฐ€ ํ†ต์‹ ํ•˜๋ฉด ๊ฐ™์€ ํ”„๋กœํ† ์ฝœ์„ ์‚ฌ์šฉํ•ด์•ผํ•˜๋Š”๋ฐ, ๋‹ค๋ฅธ ๋„คํŠธ์›Œํฌ์— ๋‹ค๋ฅธ ํ”„๋กœํ† ์ฝœ์„ ์‚ฌ์šฉํ•˜๋Š” ์„œ๋น„์Šค๋ฅผ ์„œ๋กœ ์—ฐ๊ฒฐ )

  • VirtaulService : ํ˜ธ์ŠคํŠธ ์ฃผ์†Œ๊ฐ€ ์ง€์ • ๋  ๋•Œ ํŠธ๋ž˜ํ”ฝ ๋ผ์šฐํŒ… ๊ทœ์น™ ์ •์˜ํ•œ๋‹ค.

kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.10/samples/bookinfo/networking/bookinfo-gateway.yaml

4) ๊ตฌ์„ฑ์— ๋ฌธ์ œ ์—†๋Š”์ง€ ํ™•์ธ

istioctl analyze

5) ์ ‘์† ํ•ด๋ณธ๋‹ค
http://localhost/productpage

6) ์—๋“œ์˜จ ์ฒดํฌ

istioctl dashboard jaeger

istioctl dashboard grafana

์ฐธ๊ณ 

https://istio.io/
https://www.redhat.com/ko/topics/microservices/what-is-istio
https://gruuuuu.github.io/cloud/service-mesh-istio/
https://bcho.tistory.com/1297
https://nesoy.github.io/articles/2018-06/Load-Balancer -> ๋กœ๋“œ ๋ฒจ๋Ÿฐ์‹ฑ ๊ฐœ๋…
https://findstar.pe.kr/2021/03/25/install-istio-on-docker-desktop/
https://www.44bits.io/ko/keyword/grafana
https://www.redhat.com/ko/jaeger%EB%9E%80
https://aws-diary.tistory.com/127
https://medium.com/finda-tech/prometheus%EB%9E%80-cf52c9a8785f
https://prometheus.io/docs/introduction/overview/
https://phantasmicmeans.tistory.com/entry/Istio-%ED%8C%8C%ED%97%A4%EC%B9%98%EA%B8%B0

profile
๊ฐœ๋ฐœ ๋กœ๊ทธ ๐ŸŽ ๐ŸŽ ๐ŸŽ

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