This topic describes how to use Enterprise Distributed Application Service (EDAS) SDK for Java to create a multilingual application in a Kubernetes cluster by calling an API operation.


Before you call the API operation to create a multilingual application, make sure that the following prerequisites are met:
  • A microservice namespace is created. For example, a microservice namespace with the ID of cn-hangzhou:doc is created. For more information, see Create a namespace.

    If a microservice namespace already exists, you can call the ListUserDefineRegion operation to query custom microservice namespace and obtain the value of the RegionId parameter for the microservice namespace that you want to use. For example, the value is cn-hangzhou:doc.

  • The cluster in which you want to create an application is imported to the microservice namespace. For example, the ID of the cluster is da60f685-558a-4e00-b549-15e9143d****. For more information, see Import a Kubernetes cluster.

    If a cluster has been imported to the microservice namespace, you can call the ListCluster operation to query clusters and obtain the ID of the cluster in which you want to create an application.

  • A multilingual application image is stored in the image repository that you want to use. For example, the ID of the image repository is image-demo-project, and the address of the image is

Create a multilingual application

The following code provides an example on how to create a multilingual application in a Kubernetes cluster in EDAS. For more information about advanced parameters, such as parameters that are related to scheduling rules, startup commands, and environment variables, see InsertK8sApplication.
Note In this example, an application named Productpage is created. To create another multilingual application, modify the application name and image address in the code and rerun the code.
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.edas.model.v20170801.InsertK8sApplicationRequest;
import com.aliyuncs.edas.model.v20170801.InsertK8sApplicationResponse;

public class InsertK8sApplication {

    public static void main(String[] args)  {
        // The AccessKey ID of your Alibaba Cloud account or a RAM user within the Alibaba Cloud account. 
        String aliyun_user_ak = "<yourAccessKeyId>";
        // The AccessKey secret of your Alibaba Cloud account or a RAM user within the Alibaba Cloud account. 
        String aliyun_user_sk = "<yourAccessKeySecret>";
        // The ID of the region in which you want to create an application. 
        String region_id = "cn-hangzhou";

        DefaultProfile defaultProfile = DefaultProfile.getProfile(region_id, aliyun_user_ak, aliyun_user_sk);
        DefaultAcsClient client = new DefaultAcsClient(defaultProfile);

        // Create an API request and set the parameters. 
        InsertK8sApplicationRequest request = new InsertK8sApplicationRequest();
        // The name of the application. The name must start with a letter and can contain digits, letters, and hyphens (-). The name must be 1 to 36 characters in length. 
        // In this example, the application name is set to Productpage. The application name must be unique within the microservice namespace. 
        // The ID of the cluster. 
        // The number of instances for the application. 
        // The CPU quota and memory quota for application instances. A value of 0 indicates that no quotas are set. 
        // The ID of the EDAS microservice namespace. Set this parameter if you do not want to use the default microservice namespace. 
        // The ID of the image repository and the address of the image. 

        try {
            InsertK8sApplicationResponse response = client.getAcsResponse(request);
            System.out.println("AppId=" + response.getApplicationInfo().getAppId() + "\nAppName=" + response.getApplicationInfo().getAppName());
        } catch (ServerException e) {
        } catch (ClientException e) {
Sample response:

Verify the result

After you create the application, you can call the GetChangeOrderInfo operation to view the change details and obtain the change status of the application. For more information about the API operation, see GetChangeOrderInfo.

Sample response that is returned after you call the GetChangeOrderInfo operation:
    "Message": "success",
    "RequestId": "C26DBA1C-9A38-442D-A4D5-587515C5E522",
    "Code": 200,
    "changeOrderInfo": {
        "Status": 3,
        "Desc": "Version: 20210423:1442 | Package Name: sc-provider-D-0.0.1-SNAPSHOT.jar",
        "PipelineInfoList": {
            "PipelineInfo": [
                "TaskMessage": "Apply success. <br>application is ready at desired state, version: 1"
                                // The sample response is incomplete and is only for reference. 
You can view the value of the changeOrderInfo.Status parameter to check whether the application is created. Valid values of the changeOrderInfo.Status parameter:
  • 0: ready
  • 1: in progress
  • 2: successful
  • 3: failed
  • 6: terminated
  • 8: wait for manual confirmation to trigger the next phase during a manual phased release
  • 9: wait to trigger the next phase during an automatic phased release
  • 10: failed due to a system exception
Note If a value of 3 is returned for the changeOrderInfo.Status parameter, the application fails to be created. To find the cause of the failure, check the value of the TaskMessage parameter. After the issue is fixed, create the application again.