Using the CCI Console to Create Workloads
Running the Docker run Command to Run Containers describes how to run the WordPress workload by running the docker run command. However, it is not convenient to use a container engine in many scenarios, such as auto scaling and rolling upgrade scenarios.
Cloud Container Instance (CCI) provides a serverless container engine, eliminating the need to manage clusters or servers. CCI delivers container agility and high performance with only three steps. CCI enables you to create stateless workloads (Deployments) and stateful workloads (StatefulSets). It enhances container security isolation and supports fast workload deployment, elastic load balancing, auto scaling, and blue-green deployment based on the Kubernetes workload model.
Creating a Namespace
- Log in to the CCI console. In the navigation pane, choose Namespaces.
- Click Create for the target namespace type.
- Enter a namespace name.
- Set a VPC.
Select an existing VPC or create one. You must specify a CIDR block for the new VPC. The recommended CIDR blocks are 10.0.0.0/8-24, 172.16.0.0/12-24, and 192.168.0.0/16-24.
- Configure a subnet CIDR block.
Ensure that there are sufficient available IP addresses. If IP addresses are insufficient, workload creation will fail.
- Click Create.
Creating a MySQL Workload
- Log in to the CCI console. In the navigation pane, choose Workloads > Deployments. On the page displayed on the right, click Create Deployment.
- Specify basic information.
- Workload Name: mysql
- Namespace: Select the namespace created in Creating a Namespace.
- Pods: Change the value to 1 in this example.
- Pod Specifications: Select the general-computing pod with 0.5-core CPU and 1 GB memory.

- Configure Container
- On the Open Source Images tab page, search for the mysql image and click Use Image.

- Set image parameters. Specifically, set the image version to 5.7, CPU to 0.500 cores, and memory to 1.000 GB.

- In the advanced settings, enter the environment variable MYSQL_ROOT_PASSWORD and its value. The value is the password of the MySQL database. You need to set the password by yourself.

- On the Open Source Images tab page, search for the mysql image and click Use Image.
- Click Next and configure the workload information. Set Access Type to Intranet access. In this case, the workload can be accessed by other workloads in CCI by using Service name:Port. In addition, set Service Name to mysql, and map workload access port 3306 to container port 3306 (default access port of the MySQL image).
In this way, other workloads in CCI can access the MySQL workload by using mysql:3306.

- After the configuration is complete, click Next. On the page that is displayed, check the configurations and then click Submit.
In the workload list, if the workload is in the Running state, the workload is successfully created.
Creating a WordPress Workload
- Log in to the CCI console. In the navigation pane, choose Workloads > Deployments. On the page displayed on the right, click Create Deployment.
- Specify basic information.
- Workload Name: wordpress
- Namespace: Select the namespace created in Creating a Namespace.
- Pods: Change the value to 2 in this example.
- Pod Specifications: Select the general-computing pod with 0.5-core CPU and 1 GB memory.

- Configure Container
- On the Open Source Images tab page, search for the wordpress image and click Use Image.

- Set image parameters. Specifically, set the image version to php7.1, CPU to 0.500 cores, and memory to 1.000 GB.

- In the Advanced Settings area, expand Environment Variables and add environment variables to enable the wordpress application to access the MySQL database.

Table 1 Description of environment variables Variable Name
Variable Value/Variable Reference
WORDPRESS_DB_HOST
Address for accessing the MySQL database.
Example: 10.***.***.***:3306
WORDPRESS_DB_PASSWORD
Password for accessing the MySQL database. The password must be the same as the MySQL password set in Creating a MySQL Workload.
- On the Open Source Images tab page, search for the wordpress image and click Use Image.
- Click Next and configure the workload information.
Set Access Type to Internet access and Service Name to wordpress, and select a load balancer. If no load balancers are available, click Create an enhanced load balancer to create one. Then, set ELB Protocol to HTTP and ELB Port to 9012. In the Workload Port Settings area, set a mapping between workload access port 8080 and container port 80 (default access port of the WordPress image). In the HTTP Route Settings area, set Mapping Path to / (that is, use http://Load balancer IP address:External port to access the WordPress) and Workload Access Port to 8080.

- After the configuration is complete, click Next. On the page that is displayed, check the configurations and then click Submit.
In the workload list, if the workload is in the Running state, the workload is successfully created. In this case, you can click the workload to go to its details page.
In the Access Settings area, click Internet Access and view the access address, that is, Load balancer IP address:port.

Last Article: Running the Docker run Command to Run Containers
Next Article: Calling APIs to Create Workloads
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.