Spring Cloud

Spring Cloud vs Kubernetes

微服务关注点 Spring Cloud 或其他 Kubernetes 补充说明
Configuration Management Spring Cloud Consul ConfigMap
Secret
- ConfigMap和Secret可以通过云提供的或第三方工具(如:External-secret)和外部存储(如:HashiCorp Vault,Azure Key Vault,GCP Secret Manager等)结合使用,将存储在的内容以ConfigMap,Secret或Volume形式注入K8S集群。
Service Discovery Spring Cloud Netflix
Spring Cloud Consul
Spring Cloud Zookeeper
Service - 在非K8S环境下,不推荐使用Eureka,开发维护并不活跃。推荐使用Consul并使用DNS方式。
Load Balancing Spring Cloud Load Balancer Service - SCLB支持多种负载均衡算法,如Round-robin,Least Connection,IP Hash等。K8S Service默认只提供Round-robin,如云提供伤提供其他算法,也可以通过annotation指定,但往往只有LoadBalancer类型的Service支持。
API Gateway Spring Cloud Gateway
Netflix Zuul 2
Gateway, Ingress - Spring Cloud Gateway或Zuul提供灵活的编程模型用于实现Routing,AA,限流等功能
- 默认的Ingress只实现Routing功能,其他附加功能需要专门的实现如Kong,Nginx Gateway Fabrick或公有云提供的实现。
Central Logging ELK, Grafana Loki EFK, Grafana Loki - K8S和非K8S环境使用相同的Elasticsearch和Kibana方案,只是LogShiper实现不一样。
- EK是全文索引因而支持更灵活的日志搜索,但运行和存储成本高。
- Loki可使用便宜的对象存储(如S3,GCS)存放日志数据,并使用Grafana作为GUI,成本较低。但日志搜索能力偏弱。
Central Metrics Micrometer, Prometheus, Grafana Micrometer, Prometheus, Grafana - Prometheus支持基于Consul的服务发现
Distributed Tracing Micrometer,OpenTelemetry,Jaeger Micrometer,OpenTelemetry,Jaeger - Micrometer作为API Facade层桥接OpenTelemetry
- OpenTelemetry收集和发送tracing数据
- Jaeger用于tracing数据可视化
Resilience & Fault Tolerance Resilience4j Istio
Gateway
- Istio的主要职责是在网络层面提供流量控制,包括路由、重试、超时、熔断等。在不使用Istio的情况下,白盒的应用程序内置的熔断是必要的。
- Istio不支持fallback响应功能,fallback只能在应用中实现。

Spring Cloud Stream

提供基于Java的SupplierFunctionConsumer接口实现的流式处理API抽象,并绑定到不同的底层实现作为binder。目的是同一套业务逻辑实现可以无缝应用到不同的流失系统,如Kafka,GCP Pub/Sub,Amazon Kinesis等。

Spring Cloud OpenFeign

提供声明式API用于快速简单地创建RESTful客户端。并且方便地和Spring Cloud Load Balancer和Resilience4j集成。

参考信息

  • https://www.infoq.cn/article/comparing-api-gateway-performances
  • http://www.ofbizian.com/2016/12/spring-cloud-compared-kubernetes.html
  • https://dzone.com/articles/the-future-of-spring-cloud-microservices-after-net
  • https://marketsplash.com/tutorials/kubernetes/how-to-use-kubernetes-services-for-load-balancing/
  • https://amithkumarg.medium.com/distributed-tracing-with-spring-boot-micrometer-opentelemetry-and-jaeger-fafd5c0bd282