This article will introduce the development process and practical steps of how to use Nocalhost to quickly develop microservice applications on Rainbond.
Nocalhost can directly develop applications in Kubernetes, and Rainbond can quickly deploy microservice projects without writing Yaml. Nocalhost combined with Rainbond accelerates our microservice development efficiency.
1. Introduction
Nocalhost is an open source IDE-based cloud native application development tool:
- Build, test, and debug applications directly in a Kubernetes cluster
- Provides an easy-to-use IDE plugin (supports VS Code and JetBrains), and Nocalhost maintains the same development experience as local development even when developing and debugging in a Kubernetes cluster
- Develop with instant file sync: Instantly sync your code changes to remote containers without rebuilding images or restarting containers.
Rainbond is a cloud-native application management platform:
- It is easy to use, does not need to understand containers, Kubernetes and the underlying complex technologies, supports the management of multiple Kubernetes clusters, and manages the entire life cycle of enterprise applications. The main functions include application development environment, application market, microservice architecture, application delivery, application operation and maintenance, application-level multi-cloud management, etc.
2. Local + Rainbond development of microservices
In the past, when we developed microservices locally + Rainbond, we ran the modules to be developed locally, and other modules ran on Rainbond. We communicated and debugged with the local through the Rainbond gateway.
This will encounter some problems:
- Difficulty in multi-person collaborative development and joint debugging
- local environment differentiation
- Cannot call other microservices through the registry (Nacos)
- Remote debugging is difficult
- Limited to local resources
3. Use Nocalhost + Rainbond to develop microservices
Now when we develop microservices through Nocalhost + Rainbond, all services run on Rainbond. When developing, the local Vscode is directly connected to the Rainbond component, and is synchronized with the local code to the Rainbond component in real time. When multiple people develop joint debugging, they can conduct joint debugging between services through the built-in Service Mesh of Rainbond.
Using Nocalhost development, you can solve the problems encountered when developing locally:
- Multi-person joint debugging and development are more convenient
- Services all run on Rainbond, no longer limited to local
- closer to production
- Remote Debug
- Call other microservice components through the registry (Nacos)
4. Practical steps
Nocalhost currently supports two development modes:
- Repliace DevMode
- Duplicate DevMode
This article will mainly introduce Replace DevMode. When entering Replace DevMode, Nocalhost will perform the following operations on the component:
- Reduce the number of copies to 1
- Replace the container's image with a development image
- Add a sidecar container.
- Forward a local port to the file sync server.
- Start the local file sync client.
- Open a remote terminal.
4.1 Install Nocalhost plugin
Nocalhost supports VScode
JetBrains
, here we mainly introduce the VScode plugin installation reference official website documentation.
- Open VScode and click the
Extension
button on the left icon - Enter
Nocalhost
in the search box and selectNocalhost 插件
and click the Install button
4.2 Install Rainbond
We choose to install Rainbond based on the host
4.3 Nocalhost docking with Rainbond cluster
- Get the
kubeconfig
file, enter the Rainbond cluster view -> click on node configuration -> kubeconfig
- We copy the
kubeconfig
file to the local and save it asyaml
file. - Open Vscode, click the button <img src="https://nocalhost.dev/zh-CN/img/icons/logo-light.svg" width="3%" />, open the Nocalhost plugin, select Connect to Cluster, Select the path of our
kubeconfig
file and click Add Cluster to add a cluster. - After the addition is complete, as shown below:
<img src="https://static.goodrain.com/wechat/nocalhost/6.png" width="30%" />
4.4 Deploying Spring Cloud Microservices on Rainbond
- Here, choose to install the Spring Cloud Pig microservice component from the open source application store, and search for Pig in the application store to install it.
- After the deployment is complete, the effect is as follows:
4.5 Enter Nocalhost development mode
Above, we have connected the cluster in the local Vscode, and have also installed the Spring Cloud Pig microservice in Rainbond, then we will select one of the components in the local Vscode for development pig-ui
Component.
4.5.1 Clone Pig-ui code to local
git clone https://gitee.com/zhangbigqi/pig-ui
4.5.2 Start local development
Open Vscode, click the button <img src="https://nocalhost.dev/zh-CN/img/icons/logo-light.svg" width="3%" />, find our Pig-ui component, because The application is installed from the open source application store, and the Deployment name is an automatically generated string, which we need to query in the component.
<img src="https://static.goodrain.com/wechat/nocalhost/10.png" width="30%" />
We click 🔨 next to it to enter the development mode,
- When prompted to select a container, we choose
gred5f1c
this container, and the remaining container is Rainbond's Mesh container, which is used for internal communication and cannot be replaced. - Prompt to specify the source code directory, select the code directory we just cloned.
- After waiting for a while, the terminal interface of the remote container will be opened by default and the files in the container will be synchronized with the local in real time, as follows:
4.5.3 Start the project
Install project dependencies, execute
npm install
run the project
npm run dev
The effect after startup is as follows, the port in the container is 80
- Enable port forwarding, click the button <img src="https://nocalhost.dev/zh-CN/img/icons/logo-light.svg" width="3%" />, find our Deployment, right-click and select Port Forward, Add Port Forward, enter
38000:80
to forward the container's port 80 to the local port 38000.
<img src="https://static.goodrain.com/wechat/nocalhost/14.png" width="30%" />
- Through
http://localhost:38000
you can access the page and log in normally.
4.5.4 Modify the code to check the effect
The above has demonstrated that if the service in the remote container is accessed locally, let's modify the code to see the effect.
Modify src/page/wel.vue
, add a piece of code, save. It can be found that when we save, the terminal is automatically restarted, which is consistent with the local development effect.
Modifications to files are synced to the container in real time.
Refresh the page http://localhost:38000
, you can see that the modified content has taken effect.
write at the end
Through the above practical steps, we have been able to develop microservice applications on Rainbond through Nocalhost, get rid of local development, and enter cloud-native rapid development to improve our development efficiency.
This article only introduces the basic development, and you can also configure the Nocalhost development configuration for the project, etc., friends can explore by themselves.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。