Kubernetes native service discovery
Kubernetes 本身可以进行(服务器端)服务发现(请参阅:[role="bare"][role="bare"]https://kubernetes.io/docs/concepts/services-networking/service/#discovering-services)。使用原生 Kubernetes 服务发现可确保与其他工具兼容,如 Istio ([role="bare"][role="bare"]https://istio.io),这是一种能够进行负载平衡、断路器、故障转移等操作的服务网格。
Kubernetes itself is capable of (server side) service discovery (see: [role="bare"]https://kubernetes.io/docs/concepts/services-networking/service/#discovering-services). Using native kubernetes service discovery ensures compatibility with additional tooling, such as Istio ([role="bare"]https://istio.io), a service mesh that is capable of load balancing, circuit breaker, failover, and much more.
然后,调用者服务只需引用在特定 Kubernetes 集群中可解析的名称即可。一种简单的方法可能是使用引用完全限定域名 (FQDN) 的 Spring RestTemplate
,例如 https://{service-name}.{namespace}.svc.{cluster}.local:{service-port}
。
The caller service then need only refer to names resolvable in a particular Kubernetes cluster. A simple implementation might use a spring RestTemplate
that refers to a fully qualified domain name (FQDN), such as https://{service-name}.{namespace}.svc.{cluster}.local:{service-port}
.
此外,您可以对以下内容使用 Hystrix:
Additionally, you can use Hystrix for:
-
Circuit breaker implementation on the caller side, by annotating the spring boot application class with
@EnableCircuitBreaker
-
Fallback functionality, by annotating the respective method with
@HystrixCommand(fallbackMethod=