ewolff / microservice-kubernetes

Microservices example using Kubernetes
Apache License 2.0
207 stars 194 forks source link

some questions about the CatalogClient #6

Closed wuyongdec closed 4 years ago

wuyongdec commented 4 years ago

Hi ewoff, I have trouble in understanding the flowing code in CatalogClient class :

How can Spring get the k8s ip and port ? │s2019-10-10 06:24:02.866 TRACE 7 --- [nio-8080-exec-3] c.e.m.order.clients.CatalogClient : Catalog: URL http://10.104.159.32:8080/catalog/ 2019-10-10 06:24:02.891 TRACE 7 --- [nio-8080-exec-3] c.e.m.order.clients.CustomerClient : Customer: URL http://10.96.95.128:8080/customer/

Br,

ewolff commented 4 years ago

Kubernetes has a build in DNS server that does name resolution. So the host name 'order' is automatically mapped to the IP address of the Kubernetes service. The port would be available as a DNS SRV records, see https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/