Cloud-Based Practices for Spring Cloud Applications in Kubernetes: Development
By Guyi, Alibaba Cloud Senior Technical Expert, focusing on EDAS development and user experience optimization
In recent years, cloud-native, Kubernetes, microservice, and Spring Cloud have become trending words in the tech community. Statistics show that an increasing number of teams are using Spring Cloud as the framework for microservices and Kubernetes as the foundation for the operations and maintenance (O&M) of their applications and infrastructure. Spring Cloud and Kubernetes have become the mainstream combination in the industry.
To embrace this trend, our Enterprise Distributed Application Service (EDAS) team has also focused on this typical scenario and optimized developer experiences in different stages, such as development, testing, deployment, joint debugging, and online O&M. This is represented in the latest release of version 3.0. Our team has provided developers with the best practices for using EDAS for applications that use the combined architecture of Spring Cloud and Kubernetes.
This is the first article of a series. In this article, we will focus on development.
Since 2018, Alibaba Group has released open-source Spring Cloud Alibaba, which provides the capabilities of the Group’s former middleware and meets all of the standards for Spring Cloud Netflix. Over the last two years, Spring Cloud Alibaba has become increasingly popular among developers. It has gained 14 thousand stars.
When developers have more choices, they also have some worries. Which version should I use? How can I select dependent services? How can I address the conflicts between public components? To solve these problems, Alibaba Cloud launched a project initialization tool last year, as shown in the following figure.
On this page, we provide a tool with a graphical user interface (GUI) for generating Java applications that are not limited to Spring Cloud applications. For a simple Spring Cloud application, you only have to select one dependency, which is the Nacos Service Discovery component in the Spring Cloud Alibaba section. After you select Nacos Service Discovery, click the orange button that says Generate. The tool will automatically generate a pom.xml file that can be directly packed and run. At the same time, the tool will pack all the content into a standard Java project package for you to download.
Run an Application Locally
In the normal development process of a Spring Cloud application, after you have downloaded the generated project, you need to find a registry, such as Nacos, or build one locally. This procedure often takes some time. At the end of last year, we developed a feature in the Cloud Toolkit (an IDE plug-in released by Alibaba Cloud) that allows you to automatically start or select a registry and adapt your application to the selected registry. The following figure shows the GUI screenshot:
You can select an appropriate registry based on the needs of you and your team. For example, you can select Use Local Registry (for individuals), Join Custom Registry (for teams), or a cloud-based Nacos cluster (for joint debugging with cloud services.) After you select the registry, you can follow the normal procedures to start your application in the IDE. Then, the application will be automatically adapted to the selected registry, which is completely maintenance-free. Therefore, you do not have to build a registry.
What is coming up next? We will specifically explain the interconnection between on-premises and off-premises applications in EDAS in a future article.
Summary and What to Do Next
In this article, we have taken the perspective of developers and recommended two tools respectively for initializing projects and running the application locally. In addition to the features that are mentioned in this article, both tools have more powerful capabilities that we can explore. Our EDAS team will also continue to improve developer experiences. Your comments and suggestions are always welcome.
As one of a series of articles, this article introduces the preceding two scenarios and does not include any topics about Kubernetes. We will provide more Kubernetes-related content in future articles. The next article will focus on deploying applications to the cloud.