Transcription

Application Orchestration ServiceBest PracticesIssue01Date2020-08-05HUAWEI TECHNOLOGIES CO., LTD.

Copyright Huawei Technologies Co., Ltd. 2020. All rights reserved.No part of this document may be reproduced or transmitted in any form or by any means without priorwritten consent of Huawei Technologies Co., Ltd.Trademarks and Permissionsand other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd.All other trademarks and trade names mentioned in this document are the property of their respectiveholders.NoticeThe purchased products, services and features are stipulated by the contract made between Huawei andthe customer. All or part of the products, services and features described in this document may not bewithin the purchase scope or the usage scope. Unless otherwise specified in the contract, all statements,information, and recommendations in this document are provided "AS IS" without warranties, guaranteesor representations of any kind, either express or implied.The information in this document is subject to change without notice. Every effort has been made in thepreparation of this document to ensure accuracy of the contents, but all statements, information, andrecommendations in this document do not constitute a warranty of any kind, express or implied.Issue 01 (2020-08-05)Copyright Huawei Technologies Co., Ltd.i

Application Orchestration ServiceBest PracticesContentsContents1 Using AOS and Container Technologies to Quickly Deploy the Magento Ecommerce Platform. 1Issue 01 (2020-08-05)Copyright Huawei Technologies Co., Ltd.ii

Application Orchestration ServiceBest Practices1 Using AOS and Container Technologies to QuicklyDeploy the Magento E-commerce Platform1Using AOS and Container Technologiesto Quickly Deploy the Magento E-commercePlatformBy using the Magento E-commerce Application template, you can quickly deploya containerized application of the Magento e-commerce platform. The Magentoe-commerce website consists of a frontend component and a MySQL database.This section walks you through the steps of quickly deploying the platform bycreating a stack from a modified public template Magento E-commerceApplication. The modified template allows you to specify different request andlimit usage of CPU and memory for containers every time you create stacks fromthis template.In this section, you will complete the following operations:1.Understanding Basic Concepts: Before deployment, you are advised tounderstand the basic concepts of the elements that are involved.2.Modifying a Public Template: Modify the public template Magento Ecommerce Application. Specifically, add the CPU and memory request andlimit parameters for the Magento frontend application.3.Creating a Magento E-Commerce Application Stack: Use the modifiedtemplate to create a containerized application. Then, deploy the createdapplication on a cluster.4.Deleting Resources: You are advised to delete unnecessary stack resources toavoid unwanted charges.PrerequisitesYou have a HUAWEI CLOUD account. Before deploying a container, ensure that atleast one cluster and one node with 2 vCPUs and 4 GB of memory are available.The node is in the Available state and bound to an elastic IP address. To query thenode status, log in to the CCE console and choose Resource Management Nodes. Then, obtain an elastic IP address.Issue 01 (2020-08-05)Copyright Huawei Technologies Co., Ltd.1

Application Orchestration ServiceBest Practices1 Using AOS and Container Technologies to QuicklyDeploy the Magento E-commerce PlatformFigure 1-1 Checking whether a node is availableUnderstanding Basic ConceptsBefore modifying a template, understand the basic composition of the MagentoE-commerce Application template.# Application template informationtosca definitions version: huaweicloud tosca version 1 0# Definitions of input parametersinputs:app-name:default: magentodescription: 'Application name'label: magentomagento-EIP:description: 'External access address of the Magento service'label: magentomagento-EPORT:default: 32080description: 'External listening port of the Magento service'label: magentotype: integer.# Definition of the mapping tablemappings:region map: # Defines the mapping between images and specifications of different regions.cn-east-2:magento-image: sql-image: '10.125.17.64:20202/aos-samples/mysql:latest'. .# Definition of the application topologynode templates:magento: #Element namemetadata:Designer:id: e66e332a-3466-4638-9896-f7d2e93a1ae3properties: #Element propertiesk8sManifest:apiVersion: apps/v1kind: Deploymentmetadata:labels:app:get input: app-namename:get input: app-name.requirements: #Element dependencies- dependency:node: mysql-service- dependency:node: mysql-conf- dependency:node: magento-configtype: HuaweiCloud.CCE.Deployment #Element typeIssue 01 (2020-08-05)Copyright Huawei Technologies Co., Ltd.2

Application Orchestration ServiceBest Practices1 Using AOS and Container Technologies to QuicklyDeploy the Magento E-commerce Platform.# Definitions of output parametersoutputs:ingress-admin password:description: Password of super user.value: magentorocks1magento-addr:description: Access URL for magento service.value:concat:- 'http://'- get input: magento-EIP- ':'- get input: magento-EPORTmagento-admin username:description: Super user name.value: adminDescription of template properties: inputsThis section is optional and is used to define the variables of a stack createdbased on a template. A maximum of 60 input parameters can be defined in atemplate. Each input parameter must have a unique name so that the valuecan be obtained by using the built-in get input function. If an inputparameter is defined more than once, the latest definition will overwrite theprevious ones.Function scope: node templates and outputs sections. That is, inputparameters can be transferred in the properties of node templates andvalues of outputs.Format of the inputs section: Input parameter name :type: Type default: Default value constraints: Constraints description: Description label: Label invisible: Whether command outputs are visible mappingsThis section is optional and is used to define a mapping table. When creatinga stack based on a template, you can use the get in map function to extractthe content corresponding to a specific input variable. A maximum of 10mappings can be defined in a template.Format of the mappings section: Mapping name : Mapping object name : Mapping object property name : Mapping object property value Mapping object property name : Mapping object property value . node templatesThis section is mandatory and is used to define the set of element objectsorchestrated in the template. All objects are elements. An element can be anapplication or a cloud service resource.Format of the node templates section: Element name :type: Element type Issue 01 (2020-08-05)Copyright Huawei Technologies Co., Ltd.3

Application Orchestration ServiceBest Practices1 Using AOS and Container Technologies to QuicklyDeploy the Magento E-commerce Platformproperties: Element properties requirements: Element dependency condition: Condition name –Element name: Each element name must be unique and contains 1 to 48characters. Only lowercase letters, digits, and hyphens (-) are allowed.–type: used to specify the type of an orchestration object. The type mustbe included in the element type list.–properties: Attribute information is expanded based on element types.Each element type has its corresponding properties. The variable of aproperty can be obtained from the inputs section or from the runtimeinformation displayed after you run the get attribute command. If anelement does not require a special property, you do not need to defineproperties.–requirements: Optional. If there is no relationship between elements, youdo not need to define this parameter. The dependency between elementsis based on the defined element type. Related dependencies can bedefined for specific types.–condition: Optional. This field determines whether to create elements inthe node templates. For details, see the description of conditions.outputsThis section is optional and is used to define the output parameters duringthe runtime of the stack generated using a template. Each output parametermust have a unique name.Format of the outputs section: Output parameter name :description: Description value: Value tosca definitions versionThis section is mandatory and is used to specify the version of a template.For more information about templates, see Templates (Cloud-based AutomationScripts).Modifying a Public TemplateTo save container running resources and prevent container overload, you canapply for and limit the CPU and memory used by a container. This sectiondescribes how to add the CPU and memory request and limit parameters for theMagento frontend application and MySQL database application by modifying apublic template. Request: indicates the minimum amount of resources required for running acontainer. Limit: indicates the maximum amount of resources for running a container.You can set the limit to prevent system faults caused by application overload.Step 1 Log in to the AOS console. Then, in the navigation tree, choose Template Market Public Templates.Step 2 In the Industry Templates area, click Magento E-commerce Application to viewdetails.Issue 01 (2020-08-05)Copyright Huawei Technologies Co., Ltd.4

Application Orchestration ServiceBest Practices1 Using AOS and Container Technologies to QuicklyDeploy the Magento E-commerce PlatformFigure 1-2 Selecting a public templateThe template details contain brief information and diagram of the template. AMagento application group contains a Magento frontend application and aMySQL database application. In addition, the Magento application depends on theMySQL application because the former needs to save data to the later.Step 3 Click Copy Template to copy the template to My Templates.Figure 1-3 Copying the templateStep 4 Change the template name to my-business-app and click Yes. The my-businessapp template details page is displayed.Issue 01 (2020-08-05)Copyright Huawei Technologies Co., Ltd.5

Application Orchestration ServiceBest Practices1 Using AOS and Container Technologies to QuicklyDeploy the Magento E-commerce PlatformFigure 1-4 Changing the template nameStep 5 Click Download in the Operation column and modify the template informationbased on service requirements. The following describes how to add the CPU andmemory request and limit parameters for the Magento frontend application.name: magento-containerresources:requests:cpu:get input: requestMagentoCPUmemory:get input: requestMagentoMemorylimits:cpu:get input: limitMagentoCPUmemory:get input: limitMagentoMemoryports:- containerPort: 80protocol: TCPDescription of the properties: resources: indicates container resource specifications. requests: indicates the quotas of resources allocated to a container. limits: indicates the maximum amount of resources available for a container. cpu: indicates the number of CPU cores used by a container. memory: indicates the memory amount required by a container. get input: used to obtain the values of input parameters defined in theinputs section of the templateIn the inputs section, add description and labels to the input parameters.inputs:app-name:default: magentodescription: application namelabel: magentomysql-service-name:default: magento-mysqldescription: name of the MySQL servicelabel: mysqlrequestMagentoCPU:description: CPU request of the Magento serviceIssue 01 (2020-08-05)Copyright Huawei Technologies Co., Ltd.6

Application Orchestration ServiceBest Practices1 Using AOS and Container Technologies to QuicklyDeploy the Magento E-commerce Platformlabel: magentorequestMagentoMemory:description: memory request of the Magento servicelabel: magentolimitMagentoCPU:description: CPU limit of the Magento servicelabel: magentolimitMagentoMemory:description: memory limit of the Magento servicelabel: magentomagento-EIP:description: external access address of the Magento servicelabel: magentoDescription of the properties: inputs: defines the variables of a stack created based on a template. requestMagentoCPU: defines the CPU request in the input parameters of theMagento application. requestMagentoMemory: defines the memory request in the inputparameters of the Magento application. limitMagentoCPU: defines the CPU limit in the input parameters of theMagento application. limitMagentoMemory: defines the memory limit in the input parameters ofthe Magento application. description: indicates the parameter description information. label: indicates the label of a parameter. The label defined here can bedisplayed by category during stack creation.Step 6 Save the template file.Step 7 On the template details page of my-business-app, click Add Version to uploadthe modified template file and set the version number to 2.0.----EndCreating a Magento E-Commerce Application StackThe modified template allows you to set resource limits when creating a stack.You can apply for and limit the CPU and memory of the Magento frontendapplication and MySQL database application respectively. CPU quotas:Table 1-1 Description of CPU quotasIssue 01 (2020-08-05)ParameterDescriptionCPUrequestMinimum number of CPU cores required by a container.Resources are scheduled for the container based on this value.However, the requested value does not limit the maximumnumber of CPU cores available for the container.CPU limitMaximum number of CPU cores available for a container.Copyright Huawei Technologies Co., Ltd.7

Application Orchestration ServiceBest Practices1 Using AOS and Container Technologies to QuicklyDeploy the Magento E-commerce PlatformYou are advised to configure the CPU quotas as follows: Actual number ofCPU cores available for a node Sum of CPU limits for all containers of thecurrent instance Sum of CPU requests for all containers of the currentinstance. For details about the actual number of CPU cores available for anode, log in to the CCE console, choose Resource Management Nodes,and obtain Allocatable CPUs (Cores) of the corresponding node. Memory quotas:Table 1-2 Description of memory quotasParameterDescriptionMemoryrequestMinimum amount of memory required by a container.Resources are scheduled for the container based on thisvalue.MemorylimitMaximum amount of memory available for a container.When the memory usage exceeds the configured memorylimit, the instance may be restarted, which affects the normaluse of applications.You are advised to configure the memory quotas as follows: Actual amount ofmemory available for a node Sum of memory limits for all containers of thecurrent instance Sum of memory requests for all containers of the currentinstance. For details about the actual amount of memory available for a node,log in to the CCE console, choose Resource Management Nodes, andobtain Allocatable Memory (GiB) of the corresponding node.Step 1 In the navigation pane, choose My Templates. You can view the my-business-apptemplate in the template list.Click Create Stack next to the my-business-app template to create a stack.Step 2 Set the stack information. Stack Name: Enter a stack name, for example, my-magento. Description: You can leave it blank. Cluster: Select a created cluster. Namespace: Retain the default value. On the magento tab page, set inputs parameters for the Magentoapplication, as shown in Figure 1-5. The parameters in the red box in thefollowing figure are added in the Modifying a Public Template part.Issue 01 (2020-08-05)Copyright Huawei Technologies Co., Ltd.8

Application Orchestration ServiceBest Practices1 Using AOS and Container Technologies to QuicklyDeploy the Magento E-commerce PlatformFigure 1-5 Input parameters of the Magento applicationTable 1-3 Setting input parameters of the Magento applicationIssue 01 PUCPU limit of theMagentoapplication. Thisparameter isadded to theinput parametersby modifying thepublic template.Set this parameter based on actualconditions. The default unit is G anddoes not need to be added after thevalue. For example, 1.limitMagentoMemoryMemory limit ofthe Magentoapplication. Thisparameter isadded to theinput parametersby modifying thepublic template.Set this parameter based on actualconditions. The default unit is M andneeds to be added after the value.For example, 2048M.magento-EIPElastic IP addressof a node.Obtain the elastic IP address fromPrerequisites, for example, 10.0.0.0.magento-EPORTPort number of anode.Enter an integer ranging from 30000to 32767. Ensure that the value isunique in the cluster. You can retainthe default value 32080.Copyright Huawei Technologies Co., Ltd.9

Application Orchestration ServiceBest Practices1 Using AOS and Container Technologies to QuicklyDeploy the Magento E-commerce CPU request ofthe Magentoapplication. Thisparameter isadded to theinput parametersby modifying thepublic template.Set this parameter based on actualconditions. The default unit is G anddoes not need to be added after thevalue. For example, 0.5.requestMagentoMemoryMemory requestof the Magentoapplication. Thisparameter isadded to theinput parametersby modifying thepublic template.Set this parameter based on actualconditions. The default unit is M andneeds to be added after the value.For example, 1024M.Step 3 Click Next and check the stack information. If the stack information is correct,click Create Stack.It takes 5 minutes to create the stack.Step 4 After the stack is created, click Stack Details. You can view that the stack status isNormal and six cloud services exist in Elements.Figure 1-6 Stack created successfullyStep 5 On the Outputs tab page, view output parameters.Issue 01 (2020-08-05)Copyright Huawei Technologies Co., Ltd.10

Application Orchestration ServiceBest Practices1 Using AOS and Container Technologies to QuicklyDeploy the Magento E-commerce PlatformFigure 1-7 Output parametersStep 6 In the address box of the browser, enter the value of magento-addr obtainedfrom the output parameters, for example, http://10.0.0.0:32080. Then you canaccess the Magento application.Figure 1-8 Accessing the Magento application----EndDeleting ResourcesYou are advised to delete unnecessary stack resources to avoid unwanted charges.Step 1 Log in to the AOS console.Step 2 In the navigation pane, click My Stacks.Step 3 Select the created stack, and click Delete to delete the stack as prompted.----EndIssue 01 (2020-08-05)Copyright Huawei Technologies Co., Ltd.11

the customer. All or part of the products, services and features described in this document may not be . Creating a Magento E-Commerce Application Stack: Use the modified template to create a containerized application. Then, deploy the created application on a cluster. 4. Deleting Resources: You are advised to delete unnecessary stack .