Help Center> Cloud Container Instance> Best Practices> Workload Creation> Using the CCI Console to Create Workloads
Updated on 2024-01-16 GMT+08:00

Using the CCI Console to Create Workloads

Using docker run Commands to Run Containers describes how you can run the WordPress workload by running the docker run commands. However, it is not convenient to use a container engine in many scenarios, such as auto scaling and rolling upgrade.

CCI provides a serverless container engine that frees you from managing clusters or servers. CCI delivers agility and high performance with only three steps. It enables you to create stateless workloads (Deployments) and stateful workloads (StatefulSets). It also 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

  1. Log in to the CCI console. In the navigation pane, choose Namespaces.
  2. Click Create for the target namespace type.
  3. Enter a namespace name.
  4. Configure a VPC.

    Select an existing VPC or create one. Recommended CIDR blocks for the new VPC are 10.0.0.0/8-24, 172.16.0.0/12-24, and 192.168.0.0/16-24.

  5. Configure a subnet.

    Ensure that there are sufficient available IP addresses in the subnet. If IP addresses are insufficient, workload creation will fail.

  6. Click Create.

Creating a MySQL Workload

  1. Log in to the CCI console. In the navigation pane, choose Workloads > Deployments. On the page displayed, click Create from Image.
  2. 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 GiB of memory.

    • Container Settings
      1. On the Open Source Images tab, search for the mysql image and click Use Image.

      2. Set image parameters. Specifically, set the image version to 5.7, CPU to 0.50, and memory to 1.000.

      3. 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.

  3. Click Next: Configure Access Settings. 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.

  4. 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

  1. Log in to the CCI console. In the navigation pane, choose Workloads > Deployments. On the page displayed, click Create from Image.
  2. 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 GiB of memory.

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

      2. Set image parameters. Specifically, set the image version to php7.1, CPU to 0.50, and memory to 1.000.

      3. 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.

  3. Click Next: Configure Access Settings.

    Set Access Type to Internet access and Service Name to wordpress, and select a load balancer. If no load balancers are available, click Create Share Load Balancer. 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 in the WordPress image). In the HTTP Route Settings area, set Mapping Path to / (so http://Load balancer IP address:Port can be used to access the WordPress) and Workload Access Port to 8080.

  4. 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 (Load balancer IP address:Port).