All Products
Search
Document Center

Microservices Engine:Enable MSE Microservices Governance for Go microservice applications in an ACK cluster

Last Updated:Sep 20, 2024

You can enable Microservices Governance of Microservices Engine (MSE) for Go microservice applications that are deployed in a Container Service for Kubernetes (ACK) cluster. For example, you can enable Microservices Governance for Go applications that use the Gin framework. This way, you can use a series of service governance capabilities provided by MSE to govern the Go microservice applications. This improves the stability and development efficiency of online microservice applications. This topic describes how to enable Microservices Governance for Go microservice applications.

Note

Microservices Governance for Go microservice applications is in public preview. You can use this feature free of charge during the public preview.

Prerequisites

Procedure

Step 1: Install the Microservices Governance component of MSE in the ACK cluster

  1. Log on to the ACK console.

  2. In the left-side navigation pane, click Clusters. On the Clusters page, click the name of the cluster that you created.

  3. In the left-side navigation pane of the page that appears, choose Operations > Add-ons. On the Add-ons page, search for ack-onepilot by keyword.

    Important

    Make sure that the ack-onepilot version is 3.2.3 or later. By default, the ack-onepilot component supports 1,000 pods. For every additional 1,000 pods in the cluster, you must add 0.5 CPU cores and 512 MB of memory for the component.

  4. On the ack-onepilot card, click Install.

  5. In the dialog box that appears, configure the parameters and click OK. We recommend that you use the default values.

    Note
    1. If you install the ack-onepilot component for the first time, the version you installed by clicking Install is the latest version of the component, which is later than 3.2.3.

    2. After the installation is complete, you can upgrade, configure, or uninstall the ack-onepilot component on the Add-ons page.

Step 2: Enable the advanced governance capability

  1. Log on to the MSE console, and select a region in the top navigation bar.

  2. In the left-side navigation pane, choose Microservices Governance > O&M Center > K8s cluster list. On the K8s cluster list page, click the name of the cluster that you created.

  3. In the Cluster Information section of the page that appears, click Enable for Advanced Governance Capability.

    Note

    The advanced governance capability requires approximately 1 minute to be enabled. After this capability is enabled, the status of Advanced Governance Capability changes from Disabled to Enabled.

Step 3: Compile the Go binary file

  1. Run the wget command to download the compilation tool based on the region where the compilation environment and the compilation machine reside.

    Note

    If you can access Object Storage Service (OSS) over the Internet, you can directly use the public endpoint of the operating system and architecture in the China (Hangzhou) region to obtain the compilation tool.

    Operating system

    Public endpoint

    VPC endpoint

    Linux (AMD64)

    wget "http://arms-apm-{region-id}.oss-{region-id}.aliyuncs.com/instgo/instgo-linux-amd64" -O instgo
    wget "http://arms-apm-{region-id}.oss-{region-id}-internal.aliyuncs.com/instgo/instgo-linux-amd64" -O instgo

    Linux (ARM64)

    wget "http://arms-apm-{region-id}.oss-{region-id}.aliyuncs.com/instgo/instgo-linux-arm64" -O instgo
    wget "http://arms-apm-{region-id}.oss-{region-id}-internal.aliyuncs.com/instgo/instgo-linux-arm64" -O instgo

    macOS (Darwin, ARM64)

    wget "http://arms-apm-{region-id}.oss-{region-id}.aliyuncs.com/instgo/instgo-darwin-arm64" -O instgo
    wget "http://arms-apm-{region-id}.oss-{region-id}-internal.aliyuncs.com/instgo/instgo-darwin-arm64" -O instgo

    macOS (Darwin, ARM64)

    wget "http://arms-apm-{region-id}.oss-{region-id}.aliyuncs.com/instgo/instgo-darwin-amd64" -O instgo
    wget "http://arms-apm-{region-id}.oss-{region-id}-internal.aliyuncs.com/instgo/instgo-darwin-amd64" -O instgo

    Windows (AMD64)

    wget "http://arms-apm-{region-id}.oss-{region-id}.aliyuncs.com/instgo/instgo-windows-amd64.exe" -O instgo.exe
    wget "http://arms-apm-{region-id}.oss-{region-id}-internal.aliyuncs.com/instgo/instgo-windows-amd64.exe" -O instgo.exe

    Replace {region-id} in the preceding endpoints with the region ID of the region where your compilation environment resides. For more information about mappings between regions and region IDs, see Supported regions.

    Note

    You can download the compilation tool in the following regions. More regions will be supported in the future.

    • Regions in China: China (Hangzhou), China (Shanghai), China (Beijing), China (Zhangjiakou), and China (Shenzhen)

    • Regions outside China: Singapore and US (Silicon Valley)

  2. Grant executable permissions on the compilation tool. If your operating system is Linux or macOS (Darwin), perform this step. If your operating system is Windows, skip this step.

    # Grant executable permissions on the compilation tool.
    chmod +x instgo
  3. In the directory where the main function of the Go project is located, use the compilation tool to compile the project. Replace the {licenseKey} parameter in the command with the actual license key. To obtain the license key, click View License Key in the upper-right corner of the Overview page of Microservice Governance in the MSE console.

    Note
    1. The license keys of different regions in the same Alibaba Cloud account are different. Before you view the license key, you must switch to the required region.

    2. If you need to test the compilation results or you cannot obtain the license key, add --dev to your code to enable Dev Mode. In this mode, you do not need to specify the license key. The compilation results in Dev Mode are degraded. Do not use Dev Mode in a production environment.

    3. If you want to add additional parameters to the command for subsequent compilation operations, use a delimiter (--) after the options and then add the parameters in the original format.

    4. The first time you compile the Go binary file, the agent is downloaded to the /opt directory by default. In Windows, the agent is downloaded to the C:\ProgramData directory by default. If you do not have permissions on the directory, you can use --cacheDirg flag to specify a cache directory or run the sudo -E command to compile the Go binary file. In Windows, only the administrator can run the compilation command.

    Linux/Darwin

    ./instgo build --mse --licenseKey="{licenseKey}" -- {arg1} {arg2} ...

    Windows

    .\instgo.exe build --mse --licenseKey="{licenseKey}" -- {arg1} {arg2} ...

    If you want to perform compilation operations that involve cross-compilation, such as the compilation of Linux executable binary files in macOS, you must declare the following built-in environment variables of the SDK for Go before you run the command for the complication of the binary file:

    ## Compile Linux executable programs in the macOS (Darwin) operating system.
    #amd
    CGO_ENABLED=0 GOOS=linux GOARCH=amd64 ./instgo build --mse --licenseKey="{licenseKey}"
    #arm
    CGO_ENABLED=0 GOOS=linux GOARCH=arm64 ./instgo build --mse --licenseKey="{licenseKey}"
    
    ## Compile the Windows executable program in the macOS (Darwin) operating system.
    CGO_ENABLED=0 GOOS=windows GOARCH=amd64 ./instgo build --mse --licenseKey="{licenseKey}"
    
    ## Compile macOS (Darwin) executable programs in the Linux operating system
    #amd
    CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 ./instgo build --mse --licenseKey="{licenseKey}"
    #arm
    CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 ./instgo build --mse --licenseKey="{licenseKey}"
    
    ## Compile the Windows executable program in the Linux operating system.
    CGO_ENABLED=0 GOOS=windows GOARCH=amd64 ./instgo build --mse --licenseKey="{licenseKey}"
    
    ## Compile Linux executable programs in the Windows operating system.
    #amd
    SET CGO_ENABLED=0
    SET GOOS=linux
    SET GOARCH=amd64
    .\instgo.exe build --mse --licenseKey="{licenseKey}"
    #arm
    SET CGO_ENABLED=0
    SET GOOS=linux
    SET GOARCH=arm64
    .\instgo.exe build --mse --licenseKey="{licenseKey}"
    
    ## Compile macOS (Darwin) executable programs in the Windows operating system.
    #amd
    SET CGO_ENABLED=0
    SET GOOS=darwin
    SET GOARCH=amd64
    .\instgo.exe build --mse --licenseKey="{licenseKey}"
    #arm
    SET CGO_ENABLED=0
    SET GOOS=darwin
    SET GOARCH=arm64
    .\instgo.exe build --mse --licenseKey="{licenseKey}"

    The following table describes the common Instgo commands.

    Command

    Required

    flag

    Parameter type

    Description

    build (compilation)

    Yes

    --mse

    -

    Enables the MSE Microservices Governance feature for the specified agent.

    Yes (not required for Dev Mode)

    --licenseKey, -l

    string

    Specifies the license key of MSE Microservices Governance.

    No

    --dev

    -

    Specifies Dev Mode as the development mode. In this mode, you can compile data to test functionality without the need to specify the license key.

    Important

    Some features are degraded. Do not use Dev Mode in a production environment.

    No

    --agentVersion

    string

    Specifies the version of the agent.

    No

    --agentPath

    string

    Specifies the on-premises path of the agent.

    No

    --cacheDir

    string

    Specifies the cache directory of the agent.

    No

    --regionId, -r

    string

    The ID of the region where the OSS bucket of the agent dependencies resides. Default value: cn-hangzhou.

    No

    --timeout, -t

    int

    The timeout period for downloading the dependencies of the agent. Unit: seconds. Default value: 180.

    No

    --verbose, -v

    -

    Specifies whether to print detailed compilation logs.

    No

    --vpc

    -

    Specifies whether to download the dependencies of the agent over a virtual private cloud (VPC).

    update (update)

    Yes

    --licenseKey, -l

    string

    Specifies the license key of MSE Microservices Governance.

    No

    --cacheDir

    string

    Specifies the cache directory of the agent.

    No

    --regionId, -r

    string

    The ID of the region where the OSS bucket of the agent dependencies resides. Default value: cn-hangzhou.

    No

    --timeout, -t

    int

    The timeout period for downloading the dependencies of the agent. Unit: seconds. Default value: 180.

    No

    --vpc

    Specifies whether to download the dependencies of the agent over a VPC.

    clean (cleanup)

    -

    -

    -

    You can manually clear the compilation residual and restore the code of the file that is modified by the agent.

    version (version)

    -

    -

    -

    -

Step 4: Enable MSE Microservices Governance for the Go application

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters. On the Clusters page, find the cluster that you want to manage and click Applications in the Actions column.

  2. In the left-side navigation pane of the page that appears, choose Workloads > Deployments. On the Deployments page, switch to the namespace where the application resides, find the application that you want to manage, and then click the application name to go to the application details page.

  3. In the upper-right corner of the application details page, click View in YAML. In the Edit YAML dialog box, add the following labels to the spec.template.metadata.labels level, and click Update.

    labels:
      # The golang value indicates that this application is a Go application. This value is required for Go applications.
      aliyun.com/app-language: golang
      # The on value indicates that Microservices Governance is enabled. The on value must be enclosed in double quotation marks (").
      msePilotAutoEnable: "on" 
      # The Microservices Governance namespace where the application resides. If the namespace that you specify does not exist, a namespace that has the specified name is automatically created.
      mseNamespace: "<your-mse-governance-namespace>" 
      # The actual name of the application for which Microservices Governance is enabled. The name must be enclosed in double quotation marks (").
      armsPilotCreateAppName: "<your-application-name>"   

Verify the result

After you perform the preceding steps in Procedure and restart the application, MSE Microservices Governance is enabled for the Go application that is deployed in the ACK cluster.

  1. Log on to the MSE console, and select a region in the top navigation bar.

  2. In the left-side navigation pane, choose Microservices Governance > Application Governance.

  3. On the Application list page, select a microservice namespace and check whether the application is displayed. If the application is displayed, Microservices Governance is enabled for the application.