Microservices Governance of Microservices Engine (MSE) provides microservices governance capabilities for Spring Cloud applications and Dubbo applications in an open source Kubernetes cluster. You do not need to modify your business code. The microservices governance capabilities include graceful shutdown, outlier ejection, service query, service authentication, service testing, and canary release. The microservices governance capabilities help significantly improve the stability and development efficiency of online microservice applications. This topic describes how to connect applications in an open source Kubernetes cluster to Microservices Governance of MSE.
Prerequisites
Microservices Governance is activated. For more information, see Activate Microservices Governance.
The version of your Kubernetes api-server component is 1.16 or later.
The cluster in which your applications are deployed can be accessed over the Internet.
To mount the MSE Java agent, make sure that the size of the Java virtual machine (JVM) heap memory is greater than 256 MB.
Step 1: Install the ack-onepilot component
Run the following
wgetcommand to download the ack-onepilot installation package:wget 'https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator/ack-onepilot-4.0.1.tgz'Run the following command to decompress the installation package:
tar xvf ack-onepilot-4.0.1.tgzModify the following parameters in the
ack-onepilot/values.yamlfile in the directory to which the installation package is decompressed based on your business requirements. Then, save the ack-onepilot/values.yaml file.registry: registry-__ACK_REGION_ID__.ack.aliyuncs.com/acs/ cluster_id: __ACK_CLUSTER_ID__ accessKey: __ACCESSKEY__ accessKeySecret: __ACCESSKEY_SECRET__ uid: "__ACK_UID__" region_id: __ACK_REGION_ID__registry: the prefix of the image address of the ack-onepilot component. You only need to replace __ACK_REGION_ID__ with the related pilot image address.If you transfer the image address to another storage system, you need to change the registry prefix after the transfer. You also need to transfer the following three images:
registry-__ACK_REGION_ID__.ack.aliyuncs.com/acs/ack-onepilot:4.0.1
registry-__ACK_REGION_ID__.ack.aliyuncs.com/acs/ack-onepilot-init:4.0.1
registry-__ACK_REGION_ID__.ack.aliyuncs.com/acs/ack-onepilot-alpine:3.18
cluster_id: the ID of the Kubernetes cluster.If the cluster is a self-managed cluster and is not connected to Container Service for Kubernetes (ACK), we recommend that you specify this parameter in the
<uid>-<clusterid>format. The uid parameter is the ID of your Alibaba Cloud account and the clusterid parameter is the unique ID of the client.If the cluster is an ACK cluster or an ACK managed cluster, the value of this parameter is the cluster ID.
accessKeyandaccessKeySecret: the AccessKey ID and AccessKey secret of your Alibaba Cloud account. For more information about how to obtain the AccessKey ID and AccessKey secret of your Alibaba Cloud account, see Obtain an AccessKey pair.ImportantIf the AccessKey ID of a RAM user is used, you must make sure that the RAM user is attached with the AliyunARMSFullAccess and AliyunMSEFullAccess policies.
uid: the ID of your Alibaba Cloud account. To obtain the ID of your Alibaba Cloud account, move the pointer over the profile picture in the upper-right corner of the Alibaba Cloud Management Console.region_id: the ID of the region in which you want to enable Microservices Governance for the application. For more information about the regions in which MSE is supported, see Supported regions.
Run the following command to install the ack-onepilot component:
ImportantBefore you run the command, make sure that the content of the config file in the ~/.kube directory is replaced by the configurations of the Kubernetes cluster that needs to access Microservice Governance.
helm3 upgrade --install ack-onepilot ack-onepilot --namespace ack-onepilot --create-namespace
Step 2: Modify the YAML file of the application
Run the following command to view the configurations of the desired Deployment application:
### View the configurations of the specified Deployment application. kubectl get deployment {Name of the Deployment application} -o yamlNoteIf you do not know the
name of the Deployment application, run the following command to view the information about all Deployment applications. Then, find the Deployment application whose configurations you want to view in the command output, and view the configurations of the Deployment application.### View the configurations of all the Deployment applications. kubectl get deployments --all-namespaceRun the following command to edit the YAML file of the Deployment application:
kubectl edit deployment {Name of the Deployment application} -o yamlIn the YAML file, go to the spec > template > metadata > labels directory and add the following content:
msePilotAutoEnable: "on" # Enable Microservices Governance of MSE. msePilotCreateAppName: xxx # The name of your application. mseNamespace: default # The MSE namespace where your application resides. If you do not specify this parameter, the default namespace is used.After you save the preceding configurations, the application automatically restarts and the configurations take effect.
After two to five minutes, if your application is listed on the page in the MSE console and data of the application is reported, the application is successfully connected to Microservices Governance of MSE.
What to do next
After you perform the preceding steps for your applications that are deployed in the open source Kubernetes cluster, Microservices Governance of MSE is enabled for your applications. You can log on to the MSE console, and use Microservices Governance of MSE to perform service governance for your Spring Cloud applications and Dubbo applications.
Uninstall the ack-onepilot component
If you no longer need to manage applications and services in an open source Kubernetes cluster by using Microservices Governance of MSE, you can uninstall the ack-onepilot component.
The ack-onepilot component is shared by MSE and Application Real-Time Monitoring Service (ARMS). Before you uninstall the ack-onepilot component, make sure that your product is not connected to ARMS. Otherwise, ARMS cannot be used after the ack-onepilot component is uninstalled.
Run the following command to uninstall the ack-onepilot component:
helm3 uninstall --namespace ack-onepilot ack-onepilotRestart the pod of your application.