Deploy a Python job template to SAE
You can use a Flow pipeline to implement continuous integration and deployment for job templates. This topic describes how to use Flow to deploy a Python job template to SAE as an image.
Prerequisites
You have an Alibaba Cloud account.
You have uploaded your application code to a code repository, and the code includes a Dockerfile for the application.
Background information
If this is your first time using Apsara DevOps, familiarize yourself with its deployment process and the deployment methods supported by SAE.
For more information, see Overview of deploying SAE applications and job templates by using Apsara DevOps 2020.
Step 1: Create a job template in SAE
If this is your first time hosting a job on SAE, you must first create a job template in the SAE console. SAE supports deployment from a code package or an image. The deployment method of the job template must be consistent with the pipeline configuration.
For more information, see Manage job templates.
Step 2: Create an enterprise in Apsara DevOps
If this is your first time using Flow, you need to create an enterprise. If you have already created one, you can skip this step.
Log on to Flow.
Set an enterprise name, select the size of your R&D organization, and then click Create Now.
Step 3: Create a pipeline in Flow
Log on to Flow.
In the upper-right corner of the Pipelines page, click New Pipeline.
In the Select a Pipeline Template dialog box, select Empty Template, and then click Create.
On the pipeline edit page, click Add pipeline source. In the Add pipeline source panel, select Code source in the left navigation pane. In the right pane, configure the code source information, and then click Add.
Parameter
Description
Select code source
Select the code source where your application code is located.
Note
The parameters vary based on the code source. Configure the parameters based on the UI.
Code repository
Select your code repository.
Default branch
Select a code branch.
Step 4: Deploy the job template to SAE
In the Stage 1 section, click Empty Task. In the Edit panel, customize the Task Name, and select a build cluster, Specify build node, Build environment, and Download pipeline source.
Click Add Step and select from the drop-down list. Configure the image information, and then click Save Only.
This topic uses a Personal Edition instance as an example. The following table describes the parameters.
Parameter
Description
Select service connection
Select a service connection to allow ACR to store the image.
Note
If you have not created a service connection, click Add service connection and complete the Alibaba Cloud RAM authorization before you proceed.
Region
Select the region where the application created in Step 1 is located.
Repository
Select the repository to push the built image to.
Tag
A custom tag for the image.
Dockerfile path
The path where the Dockerfile is located.
Context path
The context path for the docker build command. If left empty, this defaults to the path of the Dockerfile.
Do not use cache
If selected, the docker build command uses the
no-cache=trueparameter to build the image.Build arguments
Arguments for the build command, passed by using
--build-arg. Configure as needed.In the New Stage section, click New Task, and then select Update Serverless (SAE) job template.
In the Edit panel, configure the task information, and then click Save and Run.
Parameter
Description
Task name
A custom task name. The name can be up to 20 characters long.
Build cluster
You can select build clusters for the task.
Download pipeline source
If you enable this option, the source files from the configured pipeline source are downloaded to the corresponding working directory.
Select service connection
Select a service connection to authorize the task. This allows Flow to deploy the job template on SAE.
If you have not created a service connection, click Add service connection and complete the Alibaba Cloud RAM authorization before you proceed.
Region
Select the region where the job template created in Step 1: Create a job template in SAE is located.
Namespace
Select the namespace where the job template created in Step 1: Create a job template in SAE is located.
SAE job template
Select the job template created in Step 1: Create a job template in SAE.
Build artifact
Use ACR Enterprise Edition
This topic uses a Personal Edition instance as an example. No configuration is required.
Task plugins
You can configure task plugins to send pipeline notifications as needed.
DingTalk robot notification plugin: For more information, see Send group messages by using a DingTalk robot.
Email notification: Enter email addresses, separated by semicolons (;).
Webhook notification plugin: For more information, see Use the Webhook plug-in to send notifications.
WeCom group notification: For more information, see Send group messages by using a WeCom robot.
Lark group notification: For more information, see Send group messages by using a Lark robot.
In the Run Configuration dialog box, confirm the settings, and then click Run.
Verify the results
After the deployment starts, Flow displays the Recent Runs tab by default. You can view the pipeline execution results on this tab. If the execution fails, you can check the pipeline logs to troubleshoot the issue. Then, save and run the pipeline again to debug.
More information
After the application is deployed in SAE, you can perform the following operations.
Actions | References |
Manage the application lifecycle, such as updating, scaling, starting, stopping, and deleting the application. | |
Improve application performance with features like auto scaling, CLB binding, and batch start/stop. | |
Monitor the application status through log management, monitoring, application event viewing, and change history viewing. |