Quick Deployment of Dubbo Applications

Quick Deployment of Dubbo Applications

In the previous article, we created a Dubbo application from scratch and detailed its code structure. Next, we will learn how to deploy this Dubbo application.

This article will explain the deployment of Dubbo applications based on a Kubernetes cluster, and the deployment architecture is shown in the diagram below. Dubbo+Kubernetes+Nacos Deployment Architecture

Prerequisites

The Dubbo community provides tools and solutions to simplify the packaging and deployment process in the entire Kubernetes environment. Therefore, we need to install the relevant tools before we begin.

  1. Install dubboctl (if not already installed)
    curl -L https://raw.githubusercontent.com/apache/dubbo-kubernetes/master/release/downloadDubbo.sh | sh -
    
    cd dubbo-$version
    export PATH=$PWD/bin:$PATH
    

Deploying the Application

Initialize Microservices Cluster

  1. Once dubboctl is installed, initialize the microservice deployment environment with the following command:

    dubboctl manifest install --profile=demo
    

    For demonstration purposes, the above command will install Zookeeper, Dubbo Control Plane, Prometheus, Grafana, Zipkin, Ingress, and other components at once. For more explanations and configurations about --profile=demo, please refer to the documentation.

  2. Check if the environment is ready:

    kubectl get services -n dubbo-system
    
  3. Finally, enable the automatic injection mode for the target Kubernetes namespace, so that the application can automatically connect to the Zookeeper registry and other components after deployment.

    kubectl label namespace dubbo-demo dubbo-injection=enabled --overwrite
    

Deploying the Dubbo Application

Next, we will package the image for the application created earlier (please ensure that Docker is installed locally and the Docker process is running). Run the following command in the application’s root directory:

dubboctl build --dockerfile=./Dockerfile

The build command packages the source code into an image and pushes it to a remote repository. Depending on the network situation, it may take some time to complete the command.

Next, we need to generate the Kubernetes resource files for deploying the application by running the following command:

dubboctl deploy

The deploy command will generate the Kubernetes resource manifests using the image just packaged by build. After successful execution of the command, you will see the generated kube.yaml file in the current directory, which includes the definitions of Kubernetes resources such as deployment and service.

Next, deploy the application to the Kubernetes environment.

kubectl apply -f ./kube.yaml

Check the deployment status:

kubectl get services -n dubbo-demo

Accessing the Application

After a successful deployment, you can check the application status in the following ways.


  1. If you are using a local Kubernetes cluster, please use the following method to access the application and verify the deployment status:

    dubboctl dashboard admin
    
  2. The above command will automatically open the admin console. If it doesn’t open in your environment, please visit the following address with your browser: http://localhost:38080/admin

  3. To continue testing Dubbo services through the triple protocol, execute the following command for port mapping:

    kubectl port-forward <pod-name> 50051:50051
    
  4. Access the service using curl:

    curl \
        --header "Content-Type: application/json" \
        --data '["Dubbo"]' \
        http://localhost:50051/com.example.demo.dubbo.api.DemoService/sayHello/
    

For cloud-hosted Kubernetes clusters, you can verify using the following method. Here, taking Alibaba Cloud ACK Cluster as an example:

ACK ingress-controller access method……

Last modified September 30, 2024: Translate (22d3d83a3b)