Deploying an Application on ECS
Adding a Target Host to the Project
Before deploying applications to ECSs, add target hosts as basic resources for the project.
- Go to the Phoenix Mall project, and choose Settings > General > Basic Resources.
- Click Create Host Cluster, configure the following information, and click Save.
Table 1 Creating a host cluster Parameter
Example
Description
Cluster Name
phoenix-hostgroup
The name of the host cluster to create. Enter 3 to 128 characters. Only letters, digits, hyphens (-), underscores (_), and periods (.) are supported.
OS
Linux
The OS of the hosts to add to this cluster. Select Linux or Windows.
Host Connection Mode
Direct Connection
The way your target hosts will connect to CodeArts Deploy. Select Direct Connection or Proxy.
Execution Resource Pool
Official
A resource pool (or agent pool) is a collection of physical environments where software packages are deployed using commands.
Choose the official agent pool or a self-hosted agent pool that contains your own servers.
- Click Add Host on the Target Hosts tab.
- Select Importing ECS, and click Import in the Operation column of the phoenix-ecs host.
- Configure the following information and click OK.
Table 2 Adding a host Parameter
Example
Description
Authorization
Select Password.
The authentication mode for connecting to the ECS. Select Password or Key.
Username
Enter root.
The username for logging in to the ECS. By default, it is root for a Linux ECS.
Password
Enter the password set when buying the ECS.
The password for logging in to the ECS.
SSH Port
Enter 22.
The default port is 22. You can also use another one.
- Check the new record in the target host list. If the Verification Result column displays
, the host is added successfully.
If the host fails to be added, rectify the fault based on the failure details. For details, see Host Management FAQs.
Installing Dependency Tools on ECS
The sample program depends on Docker and Docker-Compose, which must be installed on the target ECS.
- Go to the Phoenix Mall project, and choose CICD > Deploy from the navigation pane.
- In the Operation column of the phoenix-sample-predeploy application, click
and choose Edit.
- Click the Environment Management tab and configure the host environment.
- Click Create Environment, configure the following information, and click Save.
Table 3 Creating an environment Parameter
Example
Description
Environment
phoenix-env
The name of the environment to create. Enter 3 to 128 characters. Only letters, digits, hyphens (-), underscores (_), and periods (.) are supported.
Resource Type
Host
The resource type in the environment. The default value is Host.
OS
Linux
The OS of the hosts to add to this environment. Select Linux or Windows.
- Click Import Host on the Resources tab. In the displayed dialog box, select the configured host cluster and host and click Import.
- Check the new host in the resource list.
Close the window. The new environment is displayed in the list.
- Click Create Environment, configure the following information, and click Save.
- On the Deployment Actions tab page, edit the actions of the application.
- In action Install Docker, select phoenix-env from the Environment drop-down list. If a dialog box is displayed, asking you to confirm whether you want to change the environment to phoenix-env for the subsequent actions, click OK.
- Select Run Shell Commands, and add the following two command lines to the Shell Commands box:
docker -v docker-compose -v
- Click Save & Deploy to start the deployment task.
If a message is displayed indicating successful deployment, the task is successfully executed.
If the deployment fails, rectify the fault based on the failure step and the error message in logs. For details, see CodeArts Deploy FAQs.
- View the logs. If the log content is similar to the following figure, Docker and Docker-Compose are successfully installed.
Figure 1 Viewing deployment logs
Configuring and Executing an Application
- Go to the Phoenix Mall project, and choose CICD > Deploy from the navigation pane.
- In the Operation column of the phoenix-sample-standalone application, click
and choose Edit.
- Click the Environment Management tab and configure the host environment.
- Click Create Environment, configure the following information, and click Save.
Table 4 Creating an environment Parameter
Example
Description
Environment
phoenix-env
The name of the environment to create. Enter 3 to 128 characters. Only letters, digits, hyphens (-), underscores (_), and periods (.) are supported.
Resource Type
Host
The resource type in the environment. The default value is Host.
OS
Linux
The OS of the hosts to add to this environment. Select Linux or Windows.
- Click Import Host on the Resources tab. In the displayed dialog box, select the configured host cluster and host and click Import.
- Check the new host in the resource list.
Close the window. The new environment is displayed in the list.
- Click Create Environment, configure the following information, and click Save.
- On the Deployment Actions tab page, edit the actions of the application.
- Add the action Select a Deployment Source, and configure the following parameters.
Table 5 Configuring the deployment source Parameter
Example
Description
Source
Build task
The source of the software package to deploy. Select Artifact or Build task.
Environment
phoenix-env
If a dialog box is displayed, asking you to confirm whether you want to change the environment to phoenix-env for the subsequent actions, click OK.
The target deployment environment. Select the one added on the Environment Management tab.
Build Task
phoenix-sample-ci
Available only when Source is set to Build task.
- Add the action Select a Deployment Source, and configure the following parameters.
- Click the Parameters tab page and set parameters.
Table 6 Parameters Name
Default Value
docker_server
Enter the SWR server address obtained from the SWR login command.
docker_username
Enter the username obtained from the SWR login command.
docker_username
Enter the password obtained from the SWR login command.
Obtain the SWR login command from the console. For details, see Obtaining a Long-Term Login or Image Push/Pull Command.
- Click Save & Deploy. In the displayed dialog box, click OK to start the deployment.
If a success message shows up, the deployment is successful.
If the deployment fails, rectify the fault based on the failure step and the error message in logs. For details, see CodeArts Deploy FAQs.
- Verify the deployment result.
- Open a browser, enter http://IP:5000 in the address box, and press Enter. IP indicates the EIP of the ECS. The Phoenix Mall homepage is displayed.
Figure 2 Phoenix Mall homepage
- Enter http://IP:5001 and press Enter. IP indicates the EIP of the ECS. The Phoenix Mall dashboard is displayed.
Figure 3 Phoenix Mall dashboard
- Open a browser, enter http://IP:5000 in the address box, and press Enter. IP indicates the EIP of the ECS. The Phoenix Mall homepage is displayed.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot