Sample Template-based Practice

This topic introduces how to use the sample template ZStack.System.v1.VPC to quickly deploy the VPC network.

  1. Prepare a stack template.
    In the navigation pane of the ZStack Private Cloud UI, choose Platform O&M > CloudFormation > Sample Template. On the Sample Template page, select the sample template ZStack.System.v1.VPC and expand its details page. You can get the details of the sample template as below.
    {     "ZStackTemplateFormatVersion": "2018-06-18",     "Description": "Creates VPC network. This template creates a VPC network. Make sure that the public network and management network are working as expected. Note that the VXLAN VTEP CIDR is required.",     "Parameters": {         "VrouterImageUrl": {             "Type": "String",             "Label":"vRouter image",             "Description":"vRouter image URL",             "DefaultValue": "http://cdn.zstack.io/product_downloads/vrouter/2.3/zstack-vrouter-2.3.2.qcow2"         },         "VmImageUrl": {             "Type": "String",             "Label": "VM image url",             "Description":"VM image url",             "DefaultValue": "http://cdn.zstack.io/zstack_repo/latest/zstack-image-1.4.qcow2"         },         "BackupStorage":{             "Type": "CommaDelimitedList",             "Label": "BackupStorage UUID",             "Description":"BackStorage UUID"         },         "ManagementNetworkUuid":{             "Type": "String",             "Label": "Management network",             "Description":"You can use public network as management network"         },         "PublicNetworkUuid":{             "Type": "String",             "Label": "Public network",             "Description":"Public network UUID"         },         "ZoneUuid":{             "Type": "String",             "Label": "Zone",             "Description":"Zone UUID"         },         "ClusterUuid":{             "Type": "String",             "Label": "Cluster",             "Description":"Cluster UUID"         },         "Cidr":{             "Type": "String",             "Description":"VTEP CIDR. Use the correct CIDR",             "DefaultValue":"{10.0.0.0/8}"         },         "Vni":{             "Type": "Number",             "DefaultValue":222         },         "StartVni":{             "Type": "Number",             "DefaultValue":100         },         "EndVni":{             "Type": "Number",             "DefaultValue":300         },         "StartIp":{             "Type": "String",             "DefaultValue":"192.168.20.2"         },         "EndIp":{             "Type": "String",             "DefaultValue":"192.168.20.200"         },         "Netmask":{             "Type": "String",             "DefaultValue":"255.255.255.0"         },         "Gateway":{             "Type": "String",             "DefaultValue":"192.168.20.1"         }     },     "Resources": {         "VrouterImage": {             "Type": "ZStack::Resource::Image",             "Properties": {                 "name": {"Fn::Join":["-",[{"Ref":"ZStack::StackName"}, {"Ref":"ZStack::StackUuid"},{"Ref":"ZStack::AccountUuid"},{"Ref":"ZStack::AccountName"},"Vrouter-Image"]]},                 "url": {"Ref":"VrouterImageUrl"},                 "system": true,                 "format": "qcow2",                 "backupStorageUuids":{"Ref":"BackupStorage"}             }         },         "VMImage": {             "Type": "ZStack::Resource::Image",             "Properties": {                 "name": {"Fn::Join":["-",[{"Ref":"ZStack::StackName"}, "VmImage"]]},                 "url": {"Ref":"VmImageUrl"},                 "format": "qcow2",                 "backupStorageUuids":{"Ref":"BackupStorage"}             }         },         "VirtualRouterOffering":{             "Type":"ZStack::Resource::VirtualRouterOffering",             "Properties":{                 "name": {"Fn::Join":["-",[{"Ref":"ZStack::StackName"}, "Vrouter-Offering"]]},                 "zoneUuid":{"Ref":"ZoneUuid"},                 "managementNetworkUuid":{"Ref":"ManagementNetworkUuid"},                 "publicNetworkUuid":{"Ref":"PublicNetworkUuid"},                 "imageUuid":{"Fn::GetAtt":["VrouterImage", "uuid"]},                 "cpuNum":2,                 "memorySize":2147483648             }         },         "VpcVRouter":{             "Type":"ZStack::Resource::VpcVRouter",             "Properties":{                 "name": {"Fn::Join":["-",[{"Ref":"ZStack::StackName"}, "VPC-Router"]]},                 "virtualRouterOfferingUuid":{"Fn::GetAtt":["VirtualRouterOffering","uuid"]}             }         },         "L2VxlanNetworkPool":{             "Type":"ZStack::Resource::L2VxlanNetworkPool",             "Properties":{                 "name": {"Fn::Join":["-",[{"Ref":"ZStack::StackName"}, "L2VxlanNetworkPool"]]},                 "zoneUuid":{"Ref":"ZoneUuid"}             }         },         "VniRange":{             "Type":"ZStack::Resource::VniRange",             "Properties":{                 "name": {"Fn::Join":["-",[{"Ref":"ZStack::StackName"}, "VniRange"]]},                 "startVni":{"Ref":"StartVni"},                 "endVni":{"Ref":"EndVni"},                 "l2NetworkUuid":{"Fn::GetAtt":["L2VxlanNetworkPool","uuid"]}             }         },         "L2VxlanNetwork":{             "Type":"ZStack::Resource::L2VxlanNetwork",             "Properties":{                 "name": {"Fn::Join":["-",[{"Ref":"ZStack::StackName"}, "L2VxlanNetwork"]]},                 "poolUuid":{"Fn::GetAtt":["L2VxlanNetworkPool","uuid"]},                 "zoneUuid":{"Ref":"ZoneUuid"},                 "vni":{"Ref":"Vni"}             }         },         "VpcL3Network":{             "Type":"ZStack::Resource::L3Network",             "Properties":{                 "name": {"Fn::Join":["-",[{"Ref":"ZStack::StackName"}, "VPC-Network"]]},                 "l2NetworkUuid":{"Fn::GetAtt":["L2VxlanNetwork","uuid"]},                 "category":"Private",                 "type":"L3VpcNetwork",                 "systemTags":["networkservices::VRouter"]             }         },         "InstanceOffering":{             "Type":"ZStack::Resource::InstanceOffering",             "Properties":{                 "name": {"Fn::Join":["-",[{"Ref":"ZStack::StackName"}, "1cpu","4G"]]},                 "cpuNum": 1,                 "memorySize" : 4294967296             }         },          "AttachL3ToVm":{             "Type":"ZStack::Action::AttachL3NetworkToVm",             "Properties":{                 "vmInstanceUuid": {"Fn::GetAtt":["VpcVRouter","uuid"]},                 "l3NetworkUuid":{"Fn::GetAtt":["VpcL3Network","uuid"]}             },             "DependsOn":[{"Ref":"AddIpRange"}]         },         "AddIpRange" :{             "Type":"ZStack::Action::AddIpRange",             "Properties":{                 "name": {"Fn::Join":["-",[{"Ref":"ZStack::StackName"}, "iprange"]]},                 "l3NetworkUuid":{"Fn::GetAtt":["VpcL3Network","uuid"]},                 "startIp":{"Ref":"StartIp"},                 "endIp":{"Ref":"EndIp"},                 "netmask":{"Ref":"Netmask"},                 "gateway":{"Ref":"Gateway"}             }         },         "AttachL2NetworkToCluster":{             "Type":"ZStack::Action::AttachL2NetworkToCluster",             "Properties":{                 "l2NetworkUuid":{"Fn::GetAtt":["L2VxlanNetworkPool","uuid"]},                 "clusterUuid":{"Ref":"ClusterUuid"},                 "systemTags":[{"Fn::Join":["::",["l2NetworkUuid",{"Fn::GetAtt":["L2VxlanNetwork","uuid"]},"clusterUuid",{"Ref":"ClusterUuid"},"cidr",{"Ref":"Cidr"}]]}]             }         },         "TestVm":{             "Type":"ZStack::Resource::VmInstance",             "Properties":{                 "name": {"Fn::Join":["-",[{"Ref":"ZStack::StackName"}, "TestVm"]]},                 "instanceOfferingUuid": {"Fn::GetAtt":["InstanceOffering","uuid"]},                 "l3NetworkUuids": [{"Fn::GetAtt":["VpcL3Network","uuid"]}],                 "imageUuid": {"Fn::GetAtt":["VMImage", "uuid"]}             },             "DependsOn":[{"Ref":"AttachL3ToVm"}]         }     },     "Outputs": {         "vpc": {             "Value": {                 "Ref": "VpcL3Network"             }         }     } }
    The template above includes the following five top-level fields:
    • "ZStackTemplateFormatVersion": "2018-06-18"

      It declares the version of the template.

    • "Description": "Creates VPC network. This template creates a VPC network. Make sure that the public network and management network are working as expected. Note that the VXLAN VTEP CIDR is required."

      It declares the description of the template.

    • "Parameters": { }

      It declares a list of parameters in the template.

      In this example, it declares the following parameters:
      • VrouterImageUrl
      • VmImageUrl
      • BackupStorage
      • ManagementNetworkUuid
      • PublicNetworkUuid
      • ZoneUuid
      • ClusterUuid
      • Cidr
      • Vni
      • StartVni
      • EndVni
      • StartIp
      • EndIp
      • Netmask
      • Gateway
    • "Resources": { }

      It declares the resources to be created by the template.

      In this example, it declares the following resources to be created:
      • Add a vRouter image.
      • Add a VM image.
      • Create a vRouter offering.
      • Create a VPC vRouter.
      • Create a VXLAN pool.
      • Create a L2 VXLAN network.
      • Create a VPC network.
      • Create an instance offering.
      • Attach the VPC network to the VM instance.
      • Specify the IP range of the VPC network.
      • Attach the L2 VXLAN network to the cluster.
      • Create a VM instance.
      The properties of the resources declared in "Resources": { } can reference the parameters declared in "Parameters": { }.
    • "Outputs": { }

      After the declared resources complete their creations, it provides useful information such as resource properties.

    For more information about the template syntax, see the Stack Template Syntax topic.

  2. Create a resource stack by using a sample template.
    On the Sample Template page, select the sample template ZStack.System.v1.VPC and click Actions > Generate Resource Stack. Then, the Generate Resource Stack page is displayed.
    1. Configure the following parameters:
      • Zone: The current zone is automatically displayed.
      • Name: Enter a name for the resource stack.
      • Description: Optional. Enter a description for the resource stack.
      • Timeout: Specify the timeout during the resource stack creation. If the timeout period expires before the resource stack creation completes, CloudFormation marks the resource stack as failed. The timeout is 60 minutes by default.
      • Rollback on failure: Specify whether to roll back the resource stack if the creation fails. The checkbox is selected by default.
      • Choose a stack template: The selected template is automatically displayed.
      As shown in Figure 1. Click Next.
      Figure 1. Create resource stack 1


    2. Specify each parameter according to the needed stack resource. Different parameters are specified according to different types of resource stacks.
      • vRouter Image URL: Add a vRouter image for VPC vRouter creation
      • VM Image URL: Add an image for VM instance creation
      • Backup Storage: Select a backup storage.
      • Management IP: Select an existing management network.
        Note: We recommend that you deploy a separate management network that is isolated from public network for better security and stability.
      • Public IP: Select an existing public network.
      • Zone: The current zone is automatically displayed.
      • Cluster: Optional. You can select the cluster loaded by the VXLAN pool.
      • VTEP CIDR: Set the CIDR corresponding to VTEP.
      • Vni: Optional. You can select a specified Vni from the VXLAN pool. If this field is blank, the system will automatically allocate a Vni.
      • Start Vni: Set the start Vni in the VXLAN pool.
      • End Vni: Set the end Vni in the VXLAN pool.
      • Start IP: Set the start IP address of the VPC network.
      • End IP: Set the end IP address of the VPC network.
      • Netmask: Set the netmask of the VPC network.
      • Gateway: Set the gateway of the VPC network.
      As shown in Figure 2. Click OK. Then, the resource stack creation starts.
      Figure 2. Create resource stack 2




      Note:
      • Before the resource stack creation starts, you can click Preview to check the resource list to be created.
      • It will take some time to create a resource stack. Please wait for the completion.
  3. Manage the resource stack.
    After a resource stack is successfully created, you can click the stack name on the Resource Stack page to view the stack status and details.
    • Basic attributes: Displays the current status, name, description, and UUID of the resource stack. The name and description can be modified.
    • Resource stack content: Includes the details of the template and the parameters configuration.
      • Template: Displays the details of the template used by the resource stack.
      • Parameters: Displays the details of the parameters specified for resource stack creation.
    • Resource: Displays the details of all resources in the resource stack.
    • Event: Displays each event in the resource stack lifecycle.
    • Audit: Checks related operations about the resource stack.

    You can delete the resource stack if you no longer need it.


Designer-based Practice

You can use the designer of CloudFormation to create multiple networks and deploy different services in the networks.

This topic describes how to use the designer to create three virtual private cloud (VPC) networks and separately deploy frontend services, backend services, and database services in the networks. This separation ensures network security for your services.

The Figure 1 figure shows the multi-layer deployment of services.
Figure 1. Multi-layer Service Deployment Diagram


Deployment process:
  1. Drag resources from the Resource Pool pane and drop the resources on the canvas.
  2. Edit the properties of the resources.
  3. Drag connections between resources to establish relationships.
  4. Generate a resource stack.
  5. Check whether the three VM instances are connected.
The following tables show the information of the VPC vRouter and VM instances that are used in this topic. You can configure the devices based on your business requirements.
  1. VPC vRouter
    Table 1. VPC vRouter Configuration
    Name L2 Network VPC Network IP Range
    VPC vRouter L2Network-1 Frontend Network 192.168.0.0/24
    Backend Network 192.168.100.0/24
    Database Network 192.168.200.0/24
  2. VM instance
    Table 2. VM Instance Configuration
    Name Network IP Address
    Frontend VM Instance Frontend Network 192.168.0.100
    Backend VM Instance Backend Network 192.168.100.100
    Database VM Instance Database Network 192.168.200.100
  1. Drag resources from the Resource Pool pane and drop the resources on the canvas.

    In the navigation pane of the ZStackPrivate Cloud UI, choose Platform O&M > CloudFormation > Designer. On the Designer page, drag an L2 network, three VPC networks, a VPC vRouter, and three VM instances from the Resource Pool pane and drop the resources on the canvas.

    The Figure 2 figure shows the resources on the canvas.
    Figure 2. Resources on the Canvas


  2. Edit the properties of the resources.

    Click the icon of a resource. In the Edit Property pane, edit the properties of the resource based on the information listed in the preceding tables.

    The Figure 3 figure shows the properties of a VPC vRouter.
    Figure 3. Edit Property


  3. Drag connections between resources to establish relationships.
    Click the icon of a resource. Four dots appear in the border lines of the resource icon. Select a dot and drag a line from the dot to establish a relationship with another resource.
    Note: After you drag a line from a dot to establish a relationship with another resource, four dots appear in the border lines of the resource.
    The Figure 4 figure shows how resources are connected.
    Figure 4. Drag Connections Between Resources


  4. Generate a resource stack.
    Click the Generate Resource Stack button. On the Create Resource Stack page, configure the following parameters:
    • Zone: The zone to which the resource stack belongs. The value is defaulted to the name of current zone. You do not need to set this parameter.
    • Name: The name of the resource stack.
    • Description: Optional. The description of the resource stack.
    • Timeout: The length of time before a resource stack creation times out. Default value: 60. Unit: minutes.
    • Rollback on failure: Specifies whether to delete created resources in case of a creation failure of a resource stack. This checkbox is selected by default.
    • Create a template: The script that the designer generates based on your resource configuration.
    Click Next(1/2) > OK.
    The Figure 5 figure shows the parameters of a resource stack.
    Figure 5. Create Resource Stack


  5. Check whether the three VM instances are connected.

    Use the ping command to check whether the three VM instances are connected.

    Expected results: The three VM instances can connect to each other and can access the Internet.

    Actual results: The three VM instances are connected, as shown in the Figure 6 figures.
    Figure 6. Check Connection of VM Instances






In this topic, you learned how to use the designer of CloudFormation to deploy different services in different VPC networks.

Back to Top

Download

Already filled the basic info?Click here.

Enter at least 2 characters.
Invalid mobile number.
Enter at least 4 characters.
Invalid email address.
Wrong code. Try again. Send Code Resend Code (60s)

An email with a verification code will be sent to you. Make sure the address you provided is valid and correct.

Download

Not filled the basic info yet? Click here.

Invalid email address or mobile number.

Email Us

contact@zstack.io
ZStack Training and Certification
Enter at least 2 characters.
Invalid mobile number.
Enter at least 4 characters.
Invalid email address.
Wrong code. Try again. Send Code Resend Code (60s)

Email Us

contact@zstack.io
Request Trial
Enter at least 2 characters.
Invalid mobile number.
Enter at least 4 characters.
Invalid email address.
Wrong code. Try again. Send Code Resend Code (60s)

Email Us

contact@zstack.io

The download link is sent to your email address.

If you don't see it, check your spam folder, subscription folder, or AD folder. After receiving the email, click the URL to download the documentation.

The download link is sent to your email address.

If you don't see it, check your spam folder, subscription folder, or AD folder.
Or click on the URL below. (For Internet Explorer, right-click the URL and save it.)

Thank you for using ZStack products and services.

Submit successfully.

We'll connect soon.

Thank you for using ZStack products and services.