Publishing Applications¶
This tutorial will guide you through the EnOS Enterprise Container Platform to quickly build and deploy an application, publish it to a specified cluster, and test using the application.
Scenario¶
Publish the application named uic to the alpha cluster via EnOS ECP and use the service to query personal information.
Description¶
In the application development project, complete the container configuration of the application uic, pipeline creation and publish. Create the deployment configuration, service configuration and route configuration, then create a pipeline for it, add the three tasks of build, code scan and deployment, click Run to start the pipeline, complete the above tasks, and use the service to query personal information.
Based on the above requirements, the flow of quick application publish is shown in the following diagram.
Prerequisites¶
The application development project has been created in EnOS ECP and the application named uic has been created and the application code has been saved to the Git repository.
The user is a member of the application development project and has the application uic development privileges. For detailed steps, refer to Managing Project and Application。
Step 1:Creating deployment configuration¶
This step creates the deployment configuration for the application uic and completes the details of the resources needed to deploy the application.
Log in to the ECP (you can contact EnOS Support for the URL) service.
In the left navigation bar, select Container > Deployments.
Click New Deployment and select the Create by Form method to provide the following deployment configuration.
Application Name: uic
Environment:alpha
Cluster:alpha-k8s-cn4
Replicas:1
CPU Request:0.1Cores;CPU Limit:0.8Cores
Memory Request: 0.1G;Memory Limit:0.5G
Readinesss Probe: Added
Timeout:120
Period:2
Retry Times:3
Initial Delay:20
Handler:tcpSocket;TCP Port:8080
Minimum Ready Seconds:30s
Description:Apply uic’s alpha environment deployment configuration
Click the OK button to save the deployment configuration.
Step 2: Creating a configuration map and update the deployment configuration¶
This step creates a configuration map for the application uic and updates the existing deployment configuration information.
In the left navigation bar, select Container > Config Maps。
Click New Config Map to provide the following configuration map information.
Name:Enter the Config Map name
Application:uic
Environment:alpha
Cluster:alpha-k8s-cn4
Data:Manually Enter,Key: application.properties;Value: for the contents of the application.properties file
Description:Apply the configuration map of uic’s alpha environment
Click OK to save the configuration map information.
Click on Deployments in the navigation bar, select the deployment configuration created in Step 1, and click on the Edit button.
Can edit the Config Map in the deployment configuration.
Step 3: Creating Service configuration and Route configuration¶
This step creates the Service configuration and Route configuration for the application uic to support the uic application to expose web services to the outside of the cluster.
The Service configuration steps are as follows.
In the left navigation bar, select Container > Services。
Click New Service to provide the following Service configuration information.
Application:uic
Environment:alpha
Cluster:alpha-k8s-cn4
Type:ClusterIP
Port:8080,8080,TCP
Description:Apply uic’s alpha environment Service configuration
Click the OK button to complete the Service configuration.
The detailed steps for Route Configuration are as follows.
In the left navigation bar, select Container > Routes。
Click New Route to provide the following Route configuration information.
Application:uic
Environment:alpha
Cluster:alpha-k8s-cn4
Host:uic
Route:/api/user
Service:uic
Port:8080
Description:Apply uic’s alpha environment Route configuration
Click the OK button to complete the Route configuration.
Step 4: Creating pipeline¶
This step creates a pipeline for the application uic. A pipeline consists of basic information, views and tasks, and the following steps are required to create a pipeline.
Configuring Basic Information¶
In the left navigation bar, select Development > Pipeline.
Click New Pipeline to provide the following basic information.
App/Product: uic
Pipeline Name: uic-pipeline-dev
Language/version: java_1.8.0
Tools: maven_3.3.9
Git Repository:
Trigger Mode: manual trigger
Configuring Stage¶
Select Build and provide the following information.
Job Name:Build
Docker File Path:Dockerfile
Docker Registry:harbor.eniot.io
Select SCAN and provide the following information.
Job Name:Code Scan
Source Code:src/main/java
Note
For a detailed description of the build and code scan rules, refer to New Pipeline。
Select DEPLOY and provide the following information.
Environment: alpha
Job name: Deployment
Cluster: alpha-k8s-cn4
Resource type: Deployment
Resource name: uic-deployment-dev
Click the New Pipeline button to save the pipeline configuration.
Step 5: Running the pipeline and viewing the results¶
This procedure runs the configured pipeline and views the results of the pipeline run.
In the list of created pipelines, click the created pipeline uic-pipeline-dev to open the pipeline details page.
Click the Run button, select the code repository branch, and click Run.
View the results of the pipeline run.
Click BUILD to view the results of the build task run, including the build log and the image address.
Click SCAN to view the results of the code scan task run, including the scan log and the scan result address.
Click DEPLOY to see the results of the deployment task
Step 6: Testing the published application¶
After the application is successfully deployed, test the application to ensure that the application can function properly according to the configured service information.