Istio์—์„œ ์ ‘๊ทผ ๊ฐ€๋Šฅํ•œ ์—”๋“œํฌ์ธํŠธ๋ฅผ ๋ชจ์•„๋‘” Registry๋ฅผ ํ™•์ธํ•˜๋Š” ๋ฐฉ๋ฒ•. ServiceEntry๋กœ Registry์— ์—”๋“œํฌ์ธํŠธ ์ถ”๊ฐ€ํ•˜๊ธฐ.

2 minute read

Service Registry๋ž€

Istio maintains an internal service registry containing the set of services, and their corresponding service endpoints, running in a service mesh. Istio uses the service registry to generate Envoy configuration.

Istio๋Š” ๋ฉ”์‰ฌ์—์„œ ์ ‘๊ทผ ๊ฐ€๋Šฅํ•œ ๋ชจ๋“  K8s Service ์—”๋“œํฌ์ธํŠธ๋ฅผ ๋ชจ์•„ Service Registry๋ผ๋Š” ๊ณณ์— ์ €์žฅํ•ด๋‘”๋‹ค. (์ฐธ๊ณ ๋กœ non-istio ์›Œํฌ๋กœ๋“œ์˜ K8s Svc ์—”๋“œํฌ์ธํŠธ๋„ Service Registry์— ๋“ค์–ด๊ฐ€๊ธด ํ•œ๋‹ค.)

์š” Service Registry๋ฅผ ํ™•์ธํ•˜๋ ค๋ฉด ์•„๋ž˜ ์ปค๋งจ๋“œ๋ฅผ ํ†ตํ•ด istio pilot์˜ debug/registryz ์—”๋“œํฌ์ธํŠธ์— ์ ‘๊ทผํ•˜๋ฉด ๋œ๋‹ค.

$ export PILOT_NAMESPACE=istio-system
$ export PILOT_POD_NAME=$(kubectl get po -n $PILOT_NAMESPACE -l istio=pilot -o jsonpath='{.items[0].metadata.name}')

$ kubectl exec -n $PILOT_NAMESPACE $PILOT_POD_NAME -- curl localhost:15014/debug/registryz | jq '.[].hostname' -r
---
details.default.svc.cluster.local
helloworld.default.svc.cluster.local
httpbin.default.svc.cluster.local
istiod.istio-system.svc.cluster.local
jaeger-collector.istio-system.svc.cluster.local
kiali.istio-system.svc.cluster.local
kube-dns.kube-system.svc.cluster.local
kubernetes.default.svc.cluster.local
metrics-server.kube-system.svc.cluster.local
...

ServiceEntry์— ๋“ฑ๋ก๋œ host๋Š” Service Registry์— ๋“ฑ๋ก๋œ๋‹ค

Istio does not provide service discovery, although most services are automatically added to the registry by Pilot adapters that reflect the discovered services of the underlying platform (Kubernetes, Consul, plain DNS). Additional services can also be registered manually using a ServiceEntry configuration.

Istio Egress Gateway๋ฅผ ์‚ดํŽด๋ณผ ๋•Œ ๋งŒ๋‚œ ServiceEntry๋ผ๋Š” ๋ฆฌ์†Œ์Šค๋Š” Istio ์›Œํฌ๋กœ๋“œ๊ฐ€ ๋ฉ”์‰ฌ ์™ธ๋ถ€๋กœ ๋‚˜๊ฐˆ ๋•Œ์˜ ํŠธ๋ž˜ํ”ฝ์„ ๋ชจ๋‹ˆํ„ฐ๋ง ํ•˜๊ฒŒ ํ•œ๋‹ค.

$ kubectl apply -f - <<EOF
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: google
spec:
  hosts:
  - www.google.com
  ...
  location: MESH_EXTERNAL
EOF

์ด๋•Œ, hosts ํ•„๋“œ์— ์ ํžŒ ๊ฐ’์€ Istio Service Registry์— ๋“ฑ๋ก๋œ๋‹ค.

Registry Only

IstioOperator์˜ MeshConfig ์ค‘์—” OutboundTrafficPolicy.Mode๋ผ๊ณ  outbound ํŠธ๋ž˜ํ”ฝ์— ๋Œ€ํ•œ ์˜ต์…˜์ด ์žˆ๋‹ค. ์ด๊ฑธ REGISTRY_ONLY๋กœ ์„ค์ •ํ•˜๋ฉด Istio Service Registry์— ๋“ฑ๋ก๋œ ์ฃผ์†Œ๋กœ๋งŒ ์š”์ฒญ์„ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋‹ค.

# Registry์— ๋“ฑ๋ก๋œ ๊ฒƒ๋งŒ
$ istioctl install --set meshConfig.outboundTrafficPolicy.mode=REGISTRY_ONLY

# ์ „์ฒด ํ—ˆ์šฉ
$ istioctl install --set meshConfig.outboundTrafficPolicy.mode=ALLOW_ANY
~ $ curl https://naver.com
curl: (35) Recv failure: Connection reset by peer

naver๋Š” Istio Service Registry์— ๋“ฑ๋ก๋˜์ง€ ์•Š์•„์„œ ์ ‘๊ทผ์ด ๋ถˆ๊ฐ€!

์ด์ „์˜ Istio Security ํฌ์ŠคํŠธ์˜ PeerAuthentication ๋ถ€๋ถ„์—๋„ ์ ์–ด๋’€๋Š”๋ฐ, ์š” ServiceEntry๋Š” โ€œistio โžก๏ธ non-istioโ€ ๋ฐฉํ–ฅ์˜ ํŠธ๋ž˜ํ”ฝ ์ค‘ non-istio external endpoint๋กœ ๊ฐ€๋Š” ํŠธ๋ž˜ํ”ฝ์„ ํ—ˆ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค.

์ฐธ๊ณ ์ž๋ฃŒ

  • trstringer์˜ ํฌ์ŠคํŠธ
    • Istio Service Registry๋ฅผ ํ™•์ธํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์š” ํฌ์ŠคํŠธ์—์„œ ์ฐพ์•˜๋‹ค ๐Ÿ’ก