Introduction to the

Spring Cloud provides developers with tools to quickly build common patterns in distributed systems, such as configuration management, service discovery, circuit breakers, intelligent routing, micro agents, control bus operations, etc. Using Spring Cloud developers can quickly support services and applications that implement these patterns. They will work well in any distributed environment; Has wide influence among Java developers.

Spring Cloud focuses on typical use cases and extensibility mechanisms that provide good out-of-the-box experience; Spring Cloud has become the de facto standard for developing microservices in the Java field due to the simplicity of Spring Boot for the development of large projects and the simple and efficient encapsulation of the components required for the development of microservices. Considering the challenges faced by users when migrating their applications from virtual machines to more native technologies such as containers, this article will introduce a solution for migrating Spring Cloud natively to Ari Cloud for developers’ reference or use.

architecture

Resource dependency architecture diagram Architectural renderings

  • Registering a discovery center Eureka is implemented by software. All Eureka server information needs to be configured in the configuration file to synchronize information between Eureka servers. Therefore, the architectural solution chose to create a separate ECS for Eureka Server deployment in each availability zone, with a separate SLB to fix the access address of each Eureka Server, and a separate ESS to ensure the normal operation of Eureka Server in each availability zone.
  • Gateway is another important component of the microservices architecture. The Gateway itself is a stateless service. With the guarantee of Eureka registration discovery center, each Gateway server can automatically discover the services that need to be invoked. In the architectural solution, a unified SLB is used to expose the URLS of external services; Using an ESS ensures that the Gateway is highly available and scalable. In a real project, Zuul/Gateway in Spring Cloud can be used as an example Gateway component.
  • Using aliyun Kubernetes managed version to deploy the application of actual business, can realize the rapid expansion of business load, flexible scheduling, and reduce the operation and maintenance difficulty of Kubernetes cluster.
  • OSS and CR(Container Image Service), as repositories of application deployment packages and Docker images, can easily connect to various CI/CD solutions in microservices architecture.
  • For various common variables in the system, the parameter repository in OSS is used to store them. It can realize dynamic adjustment of public variables and dynamic injection during application deployment.

advantage

Spring Cloud microservice infrastructures such as Eureka and Gateway need to run for a long time and monopolize single computing resources to ensure high reliability of services. In the architecture, ECS is used to deploy the service, and container communication technology is selected for specific business function modules. Eureka and Gateway services are managed using elastic scaling services.

  • With elastic scaling, you can set scaling rules based on service requirements and policies to ensure computing capacity and reduce costs.
  • The server ECS starts in minutes and lasts for weeks to months.
  • Containerized services start up in seconds and run for tens of minutes to weeks;

precondition

  • Familiar with and opened ALI Cloud resource arrangement ROS; With ROS resource stack management skills, click ROS to view product documentation.
  • Familiar with and opened aliyun private network VPC; With basic network building skills, click VPC to view product documents.
  • Understand and open aliyun elastic expansion ESS; Click ESS to view product documentation.
  • Understand and open Aliyun load balancing SLB; Click SLB to view product documentation.
  • Understand and open Ali Cloud object storage OSS; Click OSS to view product documentation.
  • Understand and open Ali Cloud access control RAM; Click RAM to view product documentation.
  • Understand and open OOS of Ali Cloud operation and maintenance orchestration; Click OOS to view product documentation.
  • Understand and open Aliyun container service Kubernetes version ACK; Click ACK to view product documentation.

Resources deployment

ROS Resources

ALIYUN: : VPC: : EIPAssociation: used for binding elastic public IP

ALIYUN: : ESS: : ScalingConfiguration: used to create scalable for telescopic group configuration.

ALIYUN::VPC::EIP: used to apply for an elastic public IP address.

ALIYUN: : SLB: : LoadBalancer: used to create the load balance.

ALIYUN: : ESS: : ScalingGroupEnable: for enabling telescopic group.

ALIYUN::SLB::Listener: Used to create load balancing listeners.

ALIYUN::OOS::Parameter: Used to create a common Parameter.

ALIYUN::RAM::Role: Used to create RAM roles.

ALIYUN: : CS: : ManagedKubernetesCluster: used to create Kubernetes hosted version of the cluster.

ALIYUN: : ESS: : ScalingGroup: used to create the expansion set. A scaling group is a collection of ECS instances in the same application scenario. The scaling group does not take effect immediately after being created.

ALIYUN: : ESS: : ScalingGroupEnable: enable the expansion set, can trigger the expansion activities, perform scaling rules.

steps

  1. Log in to the Resource Choreography Services console.

  2. Click to enter the Solution Center.

  3. Filter containers & microservices in case screening, find SpringCloud cloud native migration in this type of case, click create resource stack; Or click View Details to view the details of the case and then click Create Resource stack.

  4. On the page for creating a resource stack, set the following parameters:

Basic Information Configuration Eureka configuration Gateway Configuration Kubernetes managed edition cluster configuration

  1. After parameters are filled in, you can preview resources or create resources directly. It takes about 10 minutes to create a resource stack.
  2. After creation, you can query Eureka URL and Gateway URL on the output interface, as shown in the following figure:

The above steps can complete the deployment of resources (ECS, SLB, Kubernetes, etc.) required by Spring Cloud’s native Cloud migration scheme. You can view related resources on the console of the resource.

This article is published by Alibaba Cloud resource choreography service ROS