This topic uses a sample code repository from Apsara DevOps to demonstrate how to deploy an application as a Java Archive (JAR) or Web Application Archive (WAR) package to an Elastic Compute Service (ECS) cluster in Enterprise Distributed Application Service (EDAS).
Prerequisites
- Activate Apsara DevOps.
- Upload your application code to a code repository. For more information about the code repositories that Apsara DevOps supports, see Code sources.
Deployment procedure
- If your application is already deployed in EDAS, you do not need to create a new one. If you are deploying an application to EDAS for the first time, you must create an application in the EDAS console. This allows Apsara DevOps to push the application code to the application.
- After you create the application in EDAS, create an enterprise in Apsara DevOps and navigate to Flow.
- Configure the pipeline for continuous integration and deployment based on the EDAS application type.
- After you configure the pipeline, run it to deploy the EDAS application.
Step 1: Create an application in the EDAS console
If you have not created an application in EDAS, you must create one first. This topic uses the creation of a Spring Cloud application in an ECS cluster with a JAR package as an example. For more information, see Create and deploy an application in an ECS cluster.
Step 2: Create an enterprise in Apsara DevOps
If this is your first time using Apsara DevOps Flow, create an enterprise in Apsara DevOps.
Log on to Apsara DevOps Flow.
Enter the enterprise, organization, or team name, select a Usage Scale, and then click Create.
Step 3: Create a pipeline in Apsara DevOps
Log on to Apsara DevOps Flow.
In the left navigation pane, click My Pipelines, and then click New Pipeline in the upper-right corner.
- In the Select Pipeline Template dialog box, select Other · Empty Template, and then click Create.
After the pipeline is created, the Add Pipeline Source page appears.
Step 4: Configure the pipeline
- In the Stage 1 area of the pipeline, click Empty Task. In the Edit panel, configure the Task Name, Build Cluster, and Download Pipeline Source parameters, and then add task steps.
The following steps describe how to add task steps:
- In the Task Steps area, click Add Step. From the drop-down list, select and configure the step parameters.
Parameter Description Step Name Enter a custom name for the step. JDK Version Select the required Java version from the drop-down list. Maven Version Select the required Maven version from the drop-down list. Build Command Custom build command - Click Add Step. From the drop-down list, select and configure the step parameters.
Parameter Description Step Name Enter a custom name for the step. If you do not enter a name, the default name is used. Artifact Name Enter a custom name for the output, such as default. This name is used to distinguish different outputs from multiple builds and is used in the deployment task. Upload File Set the path where the project file is located.
- In the Task Steps area, click Add Step. From the drop-down list, select and configure the step parameters.
- In the New Stage area, click New Task. In the Select Task Group panel, click Deploy in the navigation pane on the left, and then select EDAS ECS Application Release.
- In the Edit panel, configure the task information.
The following table describes the task information.
Parameter Name Description Task Name A custom name for the task. Build Cluster Select a build cluster for the task. Download Pipeline Source Specify whether to download the pipeline source. If you enable this option, the source files that you configured for the pipeline are downloaded to the corresponding working directory. Select Service Connection Select the service to which the task connects. If no service connection is available, click Add Service Connection and add a connection as prompted. Select a service authorization for the task to allow Apsara DevOps to deploy applications on EDAS. Note If you have not granted authorization before, click Create next to the Service Authorization/Certificate field when you create a service connection. Complete the Alibaba Cloud Resource Access Management (RAM) authorization as prompted, and then continue with the configuration.Region Select the region where the application created in Step 1: Create an application in the EDAS console is located. Namespace Select the namespace where the application is located. Application Select the application that you created in Step 1: Create an application in the EDAS console. Package Select the name of the output that was created in the Upload Build Output (for EDAS/SAE) step in Step 1 of Step 4: Configure the pipeline. Release Batches Select the number of batches for a phased release. Wait Time Between Batches The waiting time between adjacent release batches. Batch Mode Select Manual Confirmation or Automatic Confirmation. For example, if you want to observe the release result after the first batch is complete before you decide on the next action, select Manual Confirmation. (Optional) Task Plugin Configure task plugins to send pipeline notifications as needed. - DingTalk Robot Notification Plugin
- webhook URL: The webhook URL of the DingTalk robot. For information about how to create a DingTalk robot, see DingTalk robot configuration.
- Runtime: Select when the task plugin sends notifications.
- Email Notification
- Email Address: The email address to which notifications are sent.
- Runtime: Select when the task plugin sends notifications.
- Webhook Notification Plugin
- webhook URL: The webhook URL to which notifications are sent. The address must be accessible over the Internet.
- Runtime: Select when the task plugin sends notifications.
- DingTalk Robot Notification Plugin
- After the configuration is complete, click Save Only or Save and Run in the upper-right corner.
Step 5: Deploy the application to EDAS in Apsara DevOps
- After you configure the pipeline, click Save and Run in the upper-right corner of the pipeline page. In the Run Configuration dialog box, select a code branch and click Run.
The application in this example has two instances. Because phased release and manual confirmation are configured in the pipeline, after the Build task runs successfully, you can perform the following operations in the release task of the New Stage:
- Click Release Details to go to the EDAS console and view the change details.
- Click Continue Release to continue the release of the next batch.
- Select to terminate the current pipeline run.
- Select to view the operational logs of the pipeline.
- Select to cancel the current task run.
- Click Continue Release and wait for the pipeline to finish running.
Result verification
After Apsara DevOps indicates that the deployment is successful, log on to the EDAS console and view the change records for the application. Find the Deploy Application change record that is related to Apsara DevOps. If the record exists and its status is Successful, the deployment is complete.
FAQ
- How do I use an image to deploy an application to EDAS in Apsara DevOps?
You can use Apsara DevOps to deploy an application from an image to an EDAS Kubernetes cluster. For more information, see Use Apsara DevOps 2020 to deploy a Java application to an ECS cluster.
- Can I deploy applications written in other programming languages to EDAS using Apsara DevOps? What deployment methods can I use?
For applications written in languages other than Java, you can use the Image deployment method in Apsara DevOps to deploy them to EDAS. This method requires that your application code contains a Dockerfile. For more information, see Deploy a Java application to an ECS cluster using Apsara DevOps 2020.
DingTalk group for ACK and Serverless Kubernetes clusters
If you have questions or suggestions about using Container Service for Kubernetes (ACK) and Serverless Kubernetes clusters in EDAS, you can join the DingTalk group by searching for the ID 23197114 in DingTalk.