Help Center> > Best Practices> Deploying an ECS

Deploying an ECS

Updated at: Jun 19, 2019 10:38

This section describes how to use the Application Orchestration Service (AOS) designer to quickly create an Elastic Cloud Server (ECS), including a Virtual Private Cloud (VPC) and subnet. After the orchestration is completed, a template can be generated. Based on this template, you can easily create multiple ECSs.

ECS is a cloud server that allows on-demand allocation and elastic computing capability scaling. It helps you build a reliable, secure, flexible, and efficient application environment to ensure that your services can run stably and continuously, improving O&M efficiency.

In this section, you will complete the following operations:

  1. Understanding Basic Concepts: Before deployment, you are advised to understand the basic concepts of the elements that are involved.
  2. Creating a Key Pair: Create a key pair for identity authentication during remote login to the ECS. If a key pair is already available, skip this operation.
  3. Adding and Connecting Elements: When you open the AOS designer for the first time, the template is blank. In this example, drag VPC.VPC, VPC.Subnet, and ECS.CloudServer to the canvas and establish relationships between them.
  4. Setting Template Parameters: After establishing the relationships, use the integrated editor to add parameters so that you can specify input values when creating a stack.
  5. Creating an ECS: After you use the template to create an ECS, a VPC and subnet are automatically created.
  6. Deleting Resources: You are advised to delete unnecessary stack resources to avoid unwanted charges.

Understanding Basic Concepts

  • The following table describes the basic concepts of AOS elements involved during ECS creation.
    Table 1 Basic concepts of elements

    Element

    Service

    Description

    VPC.VPC

    VPC

    A VPC enables you to build logically isolated, configurable, and manageable virtual networks. It enhances cloud resource security and simplifies network deployment.

    VPC.Subnet

    Subnet

    A subnet is a part of a VPC. It is a segment within the IP address range of the VPC and can house isolated resource groups.

    ECS.CloudServer

    ECS

    An ECS is a computing cloud server that consists of CPUs, memory, images, and Elastic Volume Service (EVS) disks and allows on-demand allocation and elastic scaling.

  • The following figure shows the relationships among VPCs, subnets, and ECSs.
    Figure 1 Relationships among VPCs, subnets, and ECSs
  • Concepts of input and output parameters:

    After configuring the properties of each element, you need to set the input and output parameters.

    • Input: During template compilation, some properties need to be frequently modified. For example, if the specifications of an ECS are written in the template, it is inconvenient to modify the template each time a property value is modified. You can define the properties that need to be frequently modified in get_input. In this way, you can directly modify the properties on the UI when deploying a stack, with no need to modify the template.
    • Output: This section is used to define the output parameters during stack runtime. For example, when creating an ECS, you need to obtain its elastic IP address to log in to it. Such a parameter needs to be set as an output parameter.

Creating a Key Pair

Before creating a resource using AOS, create a key pair for identity authentication during remote login to a node.

NOTE:

If a key pair is available, skip this operation.

  1. Log in to management console.
  2. Choose Service List > Computing > Elastic Cloud Server.
  3. In the navigation pane, choose Key Pairs. On the page that is displayed, click Create Key Pair.
  4. Enter a key pair name and click OK.
  5. In the dialog box that is displayed, click OK.

    View and save the key pair. For security purposes, a key pair can be downloaded only once. Keep it secure to ensure successful login.

Adding and Connecting Elements

  1. Log in to management console.
  2. Choose Service List > Application > Application Orchestration Service. The AOS console is displayed.
  3. In the navigation pane, click Designer. You can add and connect elements according to Figure 2.

    Figure 2 Adding and connecting elements

Setting Template Parameters

  1. Click a VPC element in the canvas. The properties of this element are displayed.

    NOTE:
    • To facilitate parameter setting and modification, you are advised to set parameters whose values need to be frequently changed as input parameters. get_input indicates input parameters. You can define the values behind get_input.
    • When the parameter settings are incorrect, is displayed before the incorrectly set parameter in the property area. Modify the property configuration and do not leave the current page. Otherwise, the parameter settings will be lost.
    {
        "node_templates": {
            "myvpc": {
                "type": "HuaweiCloud.VPC.VPC",
                "properties": {
                    "cidr": {
                        "get_input": "vpc-cidr"
                    },
                    "name": {
                        "get_input": "vpc-name"
                    }
                }
            }
        }
    }

    The following describes the properties:

    • cidr: range of available subnets on a VPC. To facilitate modification, set this property as an input parameter.
    • name: name of a VPC, which can be customized. To facilitate modification, set this property as an input parameter.

  2. Click the mysubnet element in the canvas. The properties of this element are displayed.

    Configure the subnet name and set the AZ as an input parameter. Set the following parameters in bold and retain the default values for other parameters.

    {
        "node_templates": {
            "mysubnet": {
                "type": "HuaweiCloud.VPC.Subnet",
                "properties": {
                    "availabilityZone": {
                        "get_input": "az"
                    },
                    "cidr": {
                        "get_input": "subnet-cidr"
                    },
                    "dnsList": [
                        "114.114.114.115",
                        "114.114.114.114"
                    ],
                    "gateway": {
                        "get_input": "subnet-gateway"
                    },
                    "name": {
                        "get_input": "subnet-name"
                    },
                    "vpcId": {
                        "get_reference": "myvpc"
                    },
                    "dhcpEnable": true
                }
            }
        }
    }

    The following describes the properties:

    • availabilityZone: region where a subnet is located. You can directly set the value for the property or set this property as an input parameter. To facilitate modification, you are advised to set this property as an input parameter.
    • cidr: subnet segment, which must be within the subnet address range of VPC. Set this property as an input parameter.
    • dnsList: optional; set of addresses of DNS servers in the subnet. Use this field if you want to use more than two DNS servers.
    • gateway: subnet gateway. Set this property as an input parameter.
    • name: name of a custom subnet. Set this property as an input parameter.
    • vpcId: Retain the default value. get_reference indicates that the VPC information of the subnet is dynamically obtained.
    • dhcpEnable: determines whether to enable the DHCP function. If the value is true, this function is enabled. Retain the default value. When the DHCP service is enabled, the IP address of the ECS server is automatically obtained using the DHCP protocol after the ECS server using the VPC is started.

  3. Click the CloudServer element in the canvas. The properties of this element are displayed.

    Set the following parameters in bold and retain the default values for other parameters.

    {
        "node_templates": {
            "myecs": {
                "type": "HuaweiCloud.ECS.CloudServer",
                "properties": {
                    "availabilityZone": {
                        "get_input": "az"
                    },
                    "flavor": {
                        "get_input": "flavor"
                    },
                    "imageId": {
                        "get_input": "image"
                    },
                    "name": {
                        "get_input": "vm-name"
                    },
                    "nics": [
                        {
                            "subnetId": {
                                "get_reference": "mysubnet"
                            }
                        }
                    ],
                    "publicIP": {
                        "eip": {
                            "bandwidth": {
                                "shareType": "PER",
                                "size": 1
                            },
                            "ipType": "5_bgp"
                        }
                    },
                    "sshKeyName": {
                        "get_input": "sshKey-name"
                    },
                    "vpcId": {
                        "get_reference": "myvpc"
                    },
                    "instances": 1,
                    "rootVolume": {
                        "volumeType": "SATA",
                        "size": 40
                    }
                }
            }
        }
    }
    • availabilityZone: region where a subnet is located. You can directly set the value for the property or set this property as an input parameter. To facilitate modification, you are advised to set this property as an input parameter.
    • flavor: ECS specifications. You are advised to set this property as an input parameter.
    • imageId: type of the operating system (OS) for creating an ECS. You are advised to set this property as an input parameter.
    • name: name of an ECS, which can be customized. You are advised to set this property as an input parameter.
    • nics: NIC of a VM. A VM may have multiple NICs. Set this parameter manually. get_reference indicates that the value of this parameter can be dynamically obtained from the subnet information.
    • publicIP: This property is mandatory if the cloud service needs to be bound to an elastic IP address and to access the Internet.
    • vpcId: Retain the default value. get_reference indicates that the VPC information of the subnet is dynamically obtained.
    • instances: number of ECSs to be created. Set the value to 1, indicating that one ECS is created.
    • rootVolume: disk specifications of the ECS. Retain the default value.
    • sshKeyName: key name. The key must be created in advance. The password function will be enabled in future. Currently, this property is mandatory.

  4. Click the blank area in the canvas and set input parameters in the inputs section. The input parameters are obtained from the values of get_input in previous steps.

    {
        "inputs": {
            "az": {
                "default": "cn-north-1a",
                "description": "AZ where the cloud service is located."
            },
            "flavor": {
                "default": "s2.large.2",
                "description": "ECS specifications"
            },
            "image": {
                "default": "1189efbf-d48b-46ad-a823-94b942e2a000",
                "description": "ID of the image used by the ECS"
            },
            "sshKey-name": {
                "description": "SSH key pair"
            },
            "subnet-cidr": {
                "default": "192.168.1.0/24",
                "description": "subnet CIDR"
            },
            "subnet-gateway": {
                "default": "192.168.1.1",
                "description": "gateway address of the subnet"
            },
            "subnet-name": {
                "default": "my-ecs-subnet2",
                "description": "subnet name"
            },
            "vm-name": {
                "default": "my-cloudserver",
                "description": "ECS name"
            },
            "vpc-cidr": {
                "default": "192.168.0.0/16",
                "description": "VPC CIDR"
            },
            "vpc-name": {
                "default": "my-ecs-vpkvc2",
                "description": "VPC name"
            }
        }
    }

  5. Click the blank area in the canvas and set output parameters in the outputs section. Output parameters refer to those to be obtained.

    To create an ECS, the following parameters are required:

    NOTE:
    • Parameters in the outputs section, for example, ecs-eip and ecs-id, can be customized.
    • get_attribute indicates that the corresponding value can be automatically obtained from an element. The parameter behind get_attribute, for example, myecs, must be the same as the defined element name. The values behind myecs, for example, floatingIpId and refID, must match the output parameters of the current element and cannot be customized.
    • ecs-eip: Use the get_attribute function to automatically obtain the elastic IP address of the ECS from the myecs element.
    • ecs-id: Use the get_attribute function to automatically obtain the ECS ID from the myecs element.
    {
        "outputs": {
            "ecs-eip": {
                "value": {
                    "get_attribute": [
                        "myecs",
                        "floatingIpId"
                    ]
                }
            },
            "ecs-id": {
                "value": {
                    "get_attribute": [
                        "myecs",
                        "refID"
                        ]
                }
            }
        }
    }

  6. Click on the top of the designer page, click the My Templates tab, set the following parameters, and click Save.

    Before saving the template, you can click to verify it. If the template is correct, a message is displayed in Operation Log, indicating that the template is verified successfully.
    • Name: name of a template, which can be customized but must be globally unique. For example, set this parameter to myecs.
    • Version: 1.0. Retain the default value.

Creating an ECS

  1. Click in the upper right corner of the designer page to enter the homepage of the AOS console.
  2. In the navigation pane, choose My Templates. You can view the saved template myecs in the template list.
  3. Click Deploy next to the myecs template to deploy a stack.
  4. Set stack information.

    • Stack Name: Enter a stack name, for example, myecs. Ensure that the value is unique.
    • Description: You can keep it blank.
    • Set input parameters, as shown in Table 2.
      Table 2 Setting input parameters

      Parameter

      Description

      az

      AZ where the ECS is located.

      Example: az1.dc1.

      flavor

      ECS specifications.

      image

      Image used by the ECS.

      sshKey-name

      Key pair. Select a created key pair.

      subnet-cidr

      Subnet segment. Retain the default value.

      subnet-gateway

      Subnet gateway. Retain the default value.

      subnet-name

      Subnet name, which must be unique.

      Example: mysubnet-test.

      vm-name

      ECS name, which must be unique.

      Example: myecs-test.

      vpc-cidr

      Range of available subnets in the VPC.

      Retain the default value.

      vpc-name

      VPC name, which must be unique.

      Example: myvpc-test.

  5. Click Next and check the stack information. If the stack information is correct, click Create Stack.

    The stack details page is displayed, showing that the stack is being created. The VPC, subnet, and ECS are being created. The creation will take about 5 minutes.

  6. Check the stack status. When the status becomes Normal, you can view that three cloud services already exist in the stack element, indicating that the VPC, subnet, and ECS have been created successfully.

    Figure 3 Stack successfully created

  7. View the created cloud services.

    1. Log in to management console.
    2. Choose Service List > Computing > Elastic Cloud Server from the main menu. You can view the created ECS.
    3. Choose Service List > Network > Virtual Private Cloud. You can view the created VPC.
    4. Click the VPC name to enter the details page. You can view the created subnet.

Deleting Resources

You are advised to delete unnecessary stack resources to avoid unwanted charges.

  1. Log in to the AOS console.
  2. In the navigation pane, click My Stacks.
  3. In the stack list, select the myecs stack and click Delete to delete it.

    Delete the stack as prompted.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel