Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How do SpringCloud and Kubernetes compare at the micro-service level?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

What is the comparison between SpringCloud and Kubernetes at the micro-service level? in view of this question, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Both Spring Cloud and Kubernetes claim to be the best environments for developing and running microservices, but they are very different in nature and solve different problems. We will look at how each platform delivers a Micro Services Architecture (MSA). What areas are they good at? And how to make full use of these two areas to achieve success in the journey of micro-services.

Background

Recently I have read a lot about building a micro-service architecture using Spring Cloud in conjunction with containerization. If you haven't read it, you should read it more, because it provides a comprehensive overview of how to use Spring Cloud to create a simple micro-service-based system. In order to build a scalable and resilient micro-service system, which can even expand to dozens or hundreds of services, it must be centrally managed and governed with the help of a toolset with extensive build-time and runtime functions. Using the Spring Cloud process involves implementing functional services (such as statistics services, account services, and notification services) and supporting infrastructure services (such as log analysis, configuration servers, service discovery, authentication services). The following is a diagram that describes this MSA using Spring Cloud:

This diagram covers the runtime aspects of the system, but does not cover packaging, continuous integration, extension, high availability, and self-repair, which are also important in the MSA world. Assuming that most Java developers are familiar with Spring Cloud, we will make a comparison to understand the relationship between Kubernetes and Spring Cloud by solving these additional problems.

Micro-service focus

Instead of comparing each feature, let's take a look at the broader micro-service concerns and see how Spring Cloud and Kubernetes solve these problems. One of the advantages of MSA today is that it is an architectural style, and its advantages and disadvantages are well balanced. Microservices support strong module boundaries, independent deployment, and technology diversity, but they come at the cost of developing distributed systems and significant operational and cost overhead. Therefore, this is a key success factor, and focusing on the tools around you will help you address as many MSA concerns as possible. It's important to start quickly and easily, but the learning process is long, so you need to be patient enough to get there.

Micro-service framework solves the problem

In the chart above, we can see a list of the most common technical concerns (we do not include non-technical concerns, such as organizational structure, culture, and so on), all of which must be addressed in MSA. This is my personal view, different organizations will have different views, but in most cases, it should apply to everyone.

Contrast picture

The two platforms are very different and there is no direct functional equivalence between them. If we map each MSA concern to the technology / project used to solve it on both platforms, we will get the following table.

Comparison of Kubernetes and Spring Cloud

The main conclusions from the above table are as follows:

Spring Cloud has a rich set of well-integrated Java libraries that solve all run-time problems as part of the application stack. Therefore, the microservice itself has libraries and runtime agents for client service discovery, load balancing, configuration updates, indicator detection and other functions. But these services are managed in JVM.

Kubernetes supports multiple languages. It not only aims at the Java platform, but also solves the challenges of distributed computing in a general way. It provides services such as configuration management, service discovery, load balancing, tracking, measurement, proxy, scheduling jobs, and so on, on the platform layer outside the application stack. Applications do not need to add any client logic libraries or agents and can be written in any language.

In some areas, both platforms rely on similar third-party tools. For example, ELK and EFK stacks, link tracking libraries, and so on.

Some components, such as Hystrix and Spring Boot, are useful in both environments. In some areas, the two platforms are complementary and can be combined to create a more powerful solution (KubeFlix and Spring Cloud Kubernetes are examples).

Necessary conditions for micro-service

To illustrate the scope of each project, there is an (almost) end-to-end table of MSA requirements, starting with the hardware at the bottom, DevOps and self-service deployment services at the top, and its relationship to the Spring Cloud and Kubernetes platforms.

In some cases, two projects use different approaches to deal with the same requirements, and in some areas, one may be stronger than the other. But the two platforms also have a complementary point that can be combined to provide a better micro-service experience. For example, Spring Boot provides a Maven plug-in for building a single jar application package. The declarative deployment and scheduling capabilities of Docker and Kubernetes make it very easy to run microservices. Similarly, there are rich application class libraries within Spring Cloud to create resiliency, fault tolerance, and so on, using Hystrix (with circuit breaker, current limiting, and circuit breaker modes) and Ribbon (for load balancing). But this alone is not enough, when it is combined with Kubernetes health check, process restart and automatic extension and other functions to turn microservices into a true anti-vulnerability system.

Advantages and disadvantages

Since the two platforms are not compared directly by function, but at the technical level, the following is a summary of the advantages and disadvantages of each platform.

Spring Cloud

Spring Cloud provides developers with tools to quickly build common patterns in distributed systems, such as configuration management, service discovery, circuit breakers, routing, and so on. It is based on the Netflix oss library and is written in Java for use by Java developers.

Advantages

The unified programming model provided by the Spring platform itself, as well as the rapid application development capability of Spring Boot, provide developers with a good micro-service development experience. For example, you can configure central services with very few annotations, and client libraries can use your back-end services with very few annotations.

There are a wealth of libraries to choose from, covering most runtime issues. Because all libraries are written in Java, it provides a variety of features, greater control, and fine-tuning options.

The different Spring cloud libraries are well integrated with each other. For example, a Feign client can also use Hystrix as a circuit breaker and Ribbon as the request payload. Everything is annotation-driven, easy to develop, and feels like a paradise for Java developers.

Shortcoming

One of the main advantages and disadvantages of Spring Cloud is that it is limited to Java. A powerful motivation for MSA is the ability to change technology stacks, libraries, and even languages when needed. This is impossible for Spring Cloud. If you want to consume Spring Cloud/Netflix OSS infrastructure services, such as configuration management, service discovery, and load balancing, this solution is not perfect. The Netflix Prana project implements the sidecar pattern to expose Java-based client libraries on HTTP, and applications written in non-java languages may exist in the Netflix ecosystem, but it is not very elegant. In addition, since I wrote this article, Pivotal has announced a new project called SteelToe, which allows service discovery and configuration of Java service invocations using net clients.

Java developers have too many responsibilities to care about and deal with Java applications. Each microservice needs to run a variety of clients for configuration retrieval, service discovery, and load balancing. It's easy to set these up, but it doesn't hide build time and runtime dependencies on the environment. For example, I can easily create a configuration server with the @ EnableConfigServer annotation, but this is just a simple method. Every time I want to run a microservice, I need to start the configuration server and run it. For a controlled environment, I have to consider making the configuration server highly available because it can be supported by Git or Svn, so I need to share the file system for it. Similarly, for service discovery, I need to start the Eureka server first. For a controlled environment, I need to deploy multiple copies of it using multiple instances on each AZ, and so on. As a Java developer, in addition to implementing all the functional services, I also have to build and manage an important micro-services platform.

Only the application scope of Spring Cloud in the field of micro-services is limited. In order to get a complete micro-service experience, you also need to consider automatic deployment, scheduling, resource management, process isolation, self-healing, building pipes and other issues. In this regard, I think it is unfair to compare Spring Cloud with Kubernetes alone, and a fairer comparison should be to compare Spring Cloud + Cloud Foundry (or Docker Swarm) with Kubernetes. But it also means that to have a complete end-to-end microservice experience, Spring Cloud must be complemented by platforms such as Kubernetes.

Kubernetes

Kubernetes is an open source system for automating the deployment, extension, and management of containerized applications. It supports multiple languages and provides good support for configuring, running, extending and managing distributed systems.

Advantages

Kubernetes is a multilingual general container management platform capable of running native clouds and traditional containerized applications. The services it provides, such as configuration management, service discovery, load balancing, metrics collection, log aggregation, can be used in various languages. This allows a platform in the organization that can be used by multiple teams (including Java developers using the Spring framework) and serves a variety of purposes: application development, test environment, build environment (for running source control systems, build services)

Compared with Spring Cloud, Kubernetes solves a wider range of MSA problems. In addition to providing run-time services, Kubernetes allows you to provide the environment, set resource constraints, RBAC, manage the application lifecycle, support automatic scaling and self-healing (behaving almost like an anti-fragile platform).

I can't help mentioning that Kubernetes technology is based on Google's 15 years of experience in developing and managing containers. In addition, with nearly 1000 submitters, it is one of the most active open source communities on Github.

Shortcoming

Kubernetes supports multiple languages, so the services it provides are generic and are not optimized for different platforms or languages, such as Spring Cloud for JVM. For example, the configuration is passed to the application as an environment variable or a file system. It does not have a Spring Cloud Config feature that provides configuration automatic updates.

Kubernetes is not a developer-focused platform. It is designed to be used by DevOps-aware It personnel. Therefore, Java developers need to learn some new concepts and learn new ways to solve problems with an open mind. Although it is easy for developers to start Kubernetes instances using MiniKube, manually installing a highly available Kubernetes cluster can be costly.

Kubernetes is still a relatively new platform, and it is still actively developing and growing. As a result, a lot of new features are added to each version, which may be difficult to keep up with. The good news is that it has advanced design ideas, and API is extensible and backward compatible.

A perfect combination of the two

As you can see, both platforms have advantages in some areas and improvements in others. Spring Cloud is a fast-starting, developer-friendly platform, while Kubernetes is DevOps-friendly with a steep learning curve but covers a wider range of micro-service concerns. The following is a summary of these views.

The two frameworks address a different range of MSA concerns, and they take a completely different approach. The Spring Cloud approach attempts to make it easier for developers to solve each MSA challenge in JVM, while the Kubernetes approach attempts to make developers' problems disappear by solving problems at the platform level. Spring Cloud is very powerful in JVM, and Kubernetes is very powerful in managing these JVM. Therefore, it is natural to combine them and benefit from the best parts of the two projects.

Through this combination, Spring provides application packaging, while Docker and Kubernetes provide deployment and scheduling. Spring provides isolation within the application through the Hystrix thread pool, and Kubernetes provides isolation through resources, processes, and namespaces. Spring provides a health interface for each microservice, and Kubernetes performs a health check and exposes traffic to the outside world based on health status. Spring externalizes and updates the configuration, and Kubernetes distributes the configuration to each microservice. Such examples abound.

Micro service technology stack

What is my favorite micro-service platform? To be honest, I like both. I like the developer experience provided by the Spring framework. It is completely annotation-driven and covers components with a variety of functional requirements. I also like Apache Camel because it integrates connectors, messaging, routing, resiliency, and fault tolerance at the application level. Then I can solve anything related to cluster management of multiple application instances, and I prefer the amazing Kubernetes capabilities. Whenever there is an overlap of functions, such as service discovery, load balancing, and configuration management, I certainly try to use the capabilities provided by Kubernetes.

This is the answer to the question about the comparison between SpringCloud and Kubernetes at the micro-service level. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report