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.
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.
curl -L https://raw.githubusercontent.com/apache/dubbo-kubernetes/master/release/downloadDubbo.sh | sh -
cd dubbo-$version
export PATH=$PWD/bin:$PATH
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.
Check if the environment is ready:
kubectl get services -n dubbo-system
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
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.
Local builds may take a long time. If you encounter problems with local builds, you can use the following command to skip the build
process.
dubboctl deploy --image=apache/dubbo-demo:quickstart_0.1
# `--image` specifies using an officially prepared example image
Next, deploy the application to the Kubernetes environment.
kubectl apply -f ./kube.yaml
Check the deployment status:
kubectl get services -n dubbo-demo
After a successful deployment, you can check the application status in the following ways.
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
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
To continue testing Dubbo services through the triple protocol, execute the following command for port mapping:
kubectl port-forward <pod-name> 50051:50051
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……