Istio Service Registry
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๋ฅผ ํ์ธํ๋ ๋ฐฉ๋ฒ์ ์ ํฌ์คํธ์์ ์ฐพ์๋ค ๐ก