 OK. Good afternoon. Welcome, everyone, to join our session. We are very glad to be here to share the best practice about heat template. So at first, let me introduce our team. Myself, I am a software engineer at IBM. My work currently is focused on the OpenStack application deployment. This is our team member, Yi Sen Lin. Yi Sen is a software engineer at IBM. Actually, he is very active in OpenStack heat community. He is a core reviewer member of the OpenStack heat community. And this is Huang Tianhua. She is a software engineer at Huawei. And she is another core reviewer member of the OpenStack heat community. So let's get started. Our title of this session is the best practice for heat resource models and the patterns. Let's look at the agenda at first. At first, I will invite our team member, Yi Sen Lin, to give you an introduction about OpenStack heat. And then he will introduce the software deployment because we will use the software deployment in the other practice. And then we will hand out first. And you will have the opportunity to practice the software deployment by heat template. And I will introduce the heat resource and some deployment patterns for you. And I will make a demo to show you how to use the heat resource and the deployment pattern. And then we will have another hands-on practice to let you try the heat resource module. At last, we will talk about the best practice about OpenStack heat. We will have a Q&A time. You can raise your question. We can try our best to answer your questions. OK, this is a workshop session. So we sent an email to all of you before the class. So we suggest you have your OpenStack to set up your OpenStack before the class. And we will prepare the template for you. And you can try the template on your OpenStack. At the same time, we set up the OpenStack for testing purpose. But that OpenStack is not enough for everyone to try. So we need to break all of you to different groups. And each group, you can try the template on our OpenStack. But if you have your own OpenStack, you can try that on your OpenStack. OK, so let's break the group. Hello. OK, since we sent you a mail to help you to set up your own DevStack environment, so it's because our environment provided to you is limited. So if you do not set up the environment, you can use our environment provided to you. But since our environment is limited, so I would like you to form several groups, like two or three people a group to share one to work together. Because, hi. OK, OK, since if I show you the email here and you won't set up the environment because it may take some time, so you can use our environment. OK. So, yeah. So my colleagues will help you to form some groups to work together. OK, OK, OK, OK, just wait a minute. Let's find my colleague because it is on all my computers. Hi, Longquan. Could you show the email that you sent to them and they want the guide, want the instruction? Yeah. I will. Yeah, I will help you. We are not going to set up now. They want the institution to set up later, yeah. After it's possible to show the mail. Just let it. OK, we can show it. So if you have never received my email and you can record your email, you can tell our team member your email address. We will send the instruction again. OK, OK. OK, I will handle it. OK, now we, sorry for the delay. Now we'll go on. If you have your environment, you can use your environment. If you don't, you can use ours. OK, so later after this workshop, I will show the instruction mail to you if you want to set up later by yourself. OK, so our environment information I will later show you. So don't worry. OK, so the first is heat introduction. In case you don't know what he is, I will give you a brief introduction of heat. OK, as you might know, heat is an orchestration engine and the input of heat is a heat template. It describes what kind of resources that you want and the relationship between them and the output of it is the real object in the open stack, like a NOVA instance or the sender volume or the neutron or the sending cluster. And this is a template that looks like the right one. The right part is a simple template to create a single NOVA instance. As you can see, there are four sessions in here. The first one is the heat template version. It is a day stream here. We are using the 2013-05-23. So it is stand for the ice house. In each release, we have a day stream for this template version. And the difference between the template version is that the intrinsic functions are not completely the same, like some functions in the ice house, but they will be removed in the mitaka, and some functions will be added to the mitaka. So if you want to check what functions supported by each template version, you can check the link at the bottom. I'm not sure if you can see it. So I will open it for you. How to scroll down. And you can see that this template version has this set of functions. And this is the Juneau release. And the set of functions is a little different, as you can see here. But the resources are all supported by all the versions. So I will switch back to the PowerPoint. Okay, the second section of the heat template is the parameters. Parameters define some parameters. You can pass to the resource property, and you can change them when you create a stack or update a stack. And there is a resources function. You define what kind of resources you want, like NOAA server or something else. And there is an output function session in the heat template. And output session is used to show the users some information of this stack. Like if you create a NOAA server, then you can use the output session to show the IP of it. Later, this template is put in the hands-on environment. Later, I will show the IP to you so you can check and try this template. So that is the brief introduction of heat. And I will introduce the software deployment to you because it is used everywhere in the GPO project. By using the software configuration or deployment resources, you can run some custom script to set up your software or install your software. So there are two ways to use the software configuration script in the VM instances. So the first way is that using the cloud init and the second way is to use the software deployment resources. So I will go into the details of cloud init. Cloud init is a tool that is installed in your image. By now, most of cloud init images have the cloud init in it. And it can help you to set up the hostname and password and resize your file system according to the flavor and run some custom script to help you to set up your software. But there are some disadvantages if you're using the cloud init. Cloud init will only run once after the instance is booted and it will not be executed when you restart the instance. And the result of the cloud init will not notify the heat server. So heat doesn't know if these resources, if these scripts are executed or not, are all success or not. So there is another resource in heat, it's the software deployment. So if you want to use software deployment, you need to install some additional tools in your image. So later I will show how to build these tools into an image. So with these tools, that software deployment resources have the ability to talk with heat. So heat can know the result of the script and heat can control the sequence of the script if you have multiple scripts. Like you set up two virtual machines and one virtual machine will use a script to set up the database and then another one to set up your software. You can control only after the database is ready, then you will run the script to install your software. So that's how software resources work. And this is an example template to use the cloud unit. As you can see, we only have one resource here, the OS normal server, and it will set up the virtual machine and then run the script you want to run. There are two properties you might need to notice. The one is that the user data format is set to row IW, which means that you will run your script through a cloud unit tool, and then the user data will put your script in it. Here I only echo a hello world to a template, to a temp file. So the right part is how they work together. When you create a stack through this template, then it will talk to NOVA, to tell NOVA to create a virtual machine. When the virtual machine is booted, the cloud unit in this virtual machine will start and then the cloud unit will talk to the NOVA metadata to pull the script you are passing to the heat. So the cloud unit will not directly talk to the heat, and heat doesn't know the result of it, and heat will think when your virtual machine is active, it's started, then he will think the stack is ready, whether your script is executed or not. So that's the template of cloud unit. And here is a template of the software deployment. As you can see, there are two more resources here. One is the heat software config, and one is the software deployment. The software config, we have two properties here. One property is the group, which we set to script here, because the script we want to run is a show script, and you can change it to puppet or shell, if you want to run some shell for a puppy script. And the config, we put the content of the show script there. So that's the two properties of the software config. And there is a software deployment resource, and there are three properties here. The config we can link to the software config resource, and we use a function, getResource, here. And the server property we use, we link to the NOVA server resource. And the signal transport is important property that tells this resource to talk with heat. So here we will set it to the heat signal. There are many ways that the results can talk with heat. Heat signal is one way. Later I will introduce another way. So the properties in the server is a little different. The user data format here, we need to set to the software config, which means we are using the software config tools to run your script. As I mentioned before, if we are using the cloud init, we will set to roll, okay. And another property is the software config transport. Here we set to pull server heat. So that is an example of software deployment, and the right part is how they communicate with each other. Then the heat will talk to NOVA and to create a server, and then later the server started, and the software deployment tools will communicate with heat and pull your script down. And execute it. By using the software deployment resource, you have several advantages, because the script you can run can be executed by stack create or stack update. Like you can use stack create to set up your software environment to install your software, and then you can use a stack update to update your software, update your software version or your file system, and the result will send back to heat. So that's the example of the software deployment. And this is the instrument to build an image that contains the software deployment tools into your cloud image. So you need to, we are using the tool, is the disk image builder, and then you need to check out the gpo image element and the heat template. Then you export an environment name element path to include the report that you check out, and then use the command disk image build VM, you are going to build a virtual machine image, and then based on Fedora, and then you are going to install the OS, Cloud Conf, OS Refresh Conf, and OS Apply Conf, and the heat config script, and then output to Fedora software config. And if you want to see more details, you can check the link, check the doc at the OpenSack document. So I think that is not the part that you are concerned because the instrument I send you will help you to download an image that already installed these tools. And as I mentioned before, there are three ways that the software deployment tools can talk to heat. The first way is the heat signal that the software deployment tools in your virtual machine will directly talk to heat endpoint. And the second way is to use the Zaka message queue services. And if you want to use the Zaka message queue services, you need to change two properties in your template. The first one is the signal transport in the software deployment resource. You need to change it to the Zaka signal. And another one is the property that software config transport in the NOAA server resource. You need to change to the Zaka message. If you're using the Zaka messaging services to communicate with the heat, then the virtual machine will not know the heat or the heat endpoint. And he will only get a message queue that which message queue he will send the result to. And you can also use the Swift object storage services by using the Swift, the heat will create a Swift object. And then the software deployment tools will write the result into the object. Then heat will know the result. So that is how to use the software deployment. And I will provide you the hands-on environment. I'm not sure if you can see it. So you have an IP of 159.122.194.139. And you can SSH it using the name demo and using the password past zero RD 216. Yeah. So you can log in and there is a hands-on folder at your home. And the templates I show you will put into the software config folder. You can check that. And later I will demo to you how to use them. So are you all logging into the environment? Past zero RD 2016. 216. Only one, only one. Oh, there is a typo here. Sorry. Sorry, sorry. Only one. 2016. Only one. There is a typo here. So I would like you to share this environment as a group. Because this environment cannot support too many virtual machines to create on it. Or it will be too slow for you. But you can all log in to check the templates. So if you are ready, please raise your hand so I can know. Zero RD, yeah. Zero RD 2016. Okay. So if you have any problems, you can reach my colleagues or raise your hands. So there is a hands-on folder in your home. And you can CD into it and then CD to the software config folder. And my template, I show you are all putting the software config folder and you can check. Okay. So are you all logging into it? No one answer me. Good, good. Thank you. Okay. So if you have problems to log into it, you can reach my colleagues or raise your hands. I will show you how to create a software config stack. So I will I will put PowerPoint to the background. I will use. Okay. I need to connect to the network. I need to connect to the network. Just wait a minute. Since my laptop didn't connect to the public network. Yeah, you can go through the templates and need. Okay, now you can see my screen. Can you see the screen? Is it the phone size fit for you? Yeah. So I'm already logging in and you can see a hands-on workshop here. And we can CD to the hands-on and oh, okay. So this seems not the environment. Okay, we have hands-on folder and CD, so we config. And you can see an example cloud init template file. Yeah. So it will equal string to the time folder. A very simple script for the demo. And the output will show the IP address of this virtual machine. So you can use the key to create the name. It's your group name. Okay. It's your group name here. I will choose the group host or speaker. Yeah. And with slash f minus f and the example cloud init demo. Yeah. You will need to use this command to create a stack. Just change the speaker to your group name. Yeah. Okay. Can you see it? I will try to this one. Can you see it? Yeah. You need to source the open RC demo at your home first and then try this command. It might be take some time to let the virtual machine up and then run the script. Oh. I already saw some group creating the stack here. Okay. So if you have any problems or or any questions, just let me know. I will go down to you and I will help you. Okay. You are professional. No questions. You are good. So after you create the stack you can log in the horizon. So here and the login password and the username is all the admin. You can log in the horizon to check the result. As I'm showing you Oh. Oh, seems there are too many virtual machines are running. It's a little slow here. Let's see the stacks I create before this speak. Yeah. I see some Oh, I see someone is not using the global name to create the stack. Never mind. So I will show the result. The demo is the stack I created before before this workshop. So I can show you the result is how does the result looks like. Now you can see this is a stack and if you click on the resources you can see the resources in the stack. Oh, a little slow. And then and then click the link here. You will go into the Okay. Oh, this environment is a little slow. Okay, you can check the log here and you will see the result. A little slow here. Yeah. Yeah, this is the log that I'll put from the virtual machine and you can see there is a harrow word in the log. And then this harrow word will also pull into the file if you log into your virtual machine to check it. So you can check by yourself and I will handle the next part to my colleagues to show how to use advanced functions in the heat template. Okay. Thank you, Yixing. Very good introduction about heat and software deployment. Okay. Next topic I will talk about the resource module and the deployment patterns. Let's look at the heat template at first. The left picture is a heat template example and when you want to create a virtual machine or a stack you may need to create a template like this and you need to create a secure group and you need to create the neutral part and here and the normal server. As you can see you need to create four resources and each resource has many properties. You need to set up the properties correctly so it's not very easy for any user to create a template like this. So we can see the heat resource sometimes there's the sometimes you may need, you may have the pin point during you use the heat template because the heat resource is based on the open stack components and not rather than the business concept so you need to know much open stack technology and sometimes you need to know the very detail and low level open stack knowledge before you create the template and as you know there are so many projects in open stack such as NOVA, Glance, Cinder and Kstone you need when you create a template you need to master and understand all of the project and sometimes the components so it's very difficult for any user the end users often spend too much time to learn the resource before they create a template so although heat provide create us a tool to create a template and to deploy an application open stack but it's difficult to deploy a large scale application in production so we prepare a resource module and the resource module is based on the regular heat resource but it is abstracted from the business concept and rather than the open stack components the resource module is easy to understand and the user don't have to know underlying technologies about the open stack and the resource module are extracted from the deployment experience in production and it's very easy to adopt deployment patterns for type code scenarios so for any user it's very easy to create a template and to deploy a large scale application on open stack and I put some resource module examples in this link so you can access this link to check that okay in this page this is the resource module list I will introduce here the first resource module I want to show you is the Okami network when you create an open stack when you want to create a network you you often need to create a network and then create a router to work to the router and set a gateway for the router for any user sometimes it's very difficult for them to understand the resource and their complicated relationship so if you use the paid resource you may need to create a template like the left picture but if you use the resource module you just need to create a template like the right picture you can say by using the resource module you and the user just need to understand only one resource and the resource has only two properties so it's very easy for any user to deploy application or open stack okay the next resource module I want to show you is Okami manager this resource module is used in a deployment pattern for deploy application or open stack for a large scale application you often need several nodes and you need to set up a manager node and set up some several clusters for example if you want to create a web service web service you may need to create a cluster for the front end front end server and you may need to create a cluster and cluster for the database so you need to create three clusters and every virtual machine on each cluster may need load balance so in this deployment pattern you need to set up the manager node and the manager node can keep the topology information about the whole stack and you can put the deployment script on the manager node and when the manager node is set up the manager node will help deploy deploy some application on the cluster in this deployment model you can use some deployment tools open source there are many open source deployment tools such as sort, Ansible so you can use that to deploy the cluster in the later I will make a demo to show you how to use the sort to deploy the cluster next resource model I will show you how to create a cluster on the cluster we have three kinds of clusters the first is a regular other screens group in this cluster I remember in the cluster it's independent it has no load balance and the second is LB group and LB member it will use the neutral load balance and the third one is HA group I will introduce one by one the first is an alchemy group it's a regular it's a regular group and member node in the group has no load balance the group will create an auto-skilling group and in the group it will create a NOAA server and deploy something on the NOAA server the second one is LB group the LB group will use the neutral load balance pool and in this group all members in this group will have load balance and it has VIP and you can expose the VIP to any user and the client will access the VIP and a neutral load balancer will help distribute the request to different members for load balance the third one is the HA group sometimes you want to have more control on the load balance rather than use the neutral load balance so you can use the HA group HA group will have two nodes and on each node it will need to install the KIPLAVD and HA proxy in this model you can create two groups and at the front end you can use the HA group and in the back end you can use the regular group KIPLAVD on the primary node will manage the VIP and the HA proxy will proxy the request to the back end groups next I will make a demo on my open stack environment to show you how to use that groups in this demo I will set up the manager to set up the manager node and I will create the HA group this is the cluster actually this is the web server cluster and the cluster will have the VIP the client will access the VIP and neutral load balance to distribute the request to different web servers so let me show you let's do that sorry the stack is created but it's created in progress I can go through the template this is the template you can say we create a manager node and create a group that group is I use that group to deploy a web server cluster this is the cluster you can say this is the cluster we create the group and scale up, scale down and neutral health monitor it has neutral pool and load balancer so the member node in the group will have load balance let me check if the stack is complete okay okay the manager node is created the cluster is created in progress let me check the progress okay the stack is created let me check the output output the private key and the manager node and the member list of the cluster also provides the scale up scale up and scale down link you can send the HTTP request to that link it will trigger the heat to scale up the cluster let's check the VIP of the web cluster in this stack I associate floating IP to the VIP so we just check that floating IP okay let me check that floating IP okay the web server works well let me add and scale up the cluster currently the cluster has only one member there is only one web server in this cluster next I will scale up the cluster and add another web server in this cluster let me show okay let me check the cluster status okay you can see there is a new member node in the cluster is created but it's created in progress let's check that member list it has two members now the first is the first IP and this is the first member the second member the second node second member is created completed okay the second member is created okay let me check the VIP again okay this is the first member okay that's the second member you can see the request is distributed to different members in the cluster let's go back okay you can say you can say in my demo I will show you how to use the resource module next let's have the hands on just as the email I sent to you I suggest you to set up the open stack and try the template but if you haven't open stack environment you can try that resource module on our open stack this is our open stack environment IP address and username password you can log on that this is another this is a different environment from the last hands on actually we set up the two open stack environment the first is for the first hands on and the second for the second hands on so you need to log in this open stack environment and the template are available on this open stack so you just need to log on this server and in the server you can source openrc.demo and create create that stack if you are in any trouble open stack environment just stress your hand our team member will provide help password password is same p-a-s-s-w-0 r-d and 2016 after you log on that server you can go to slash home slash demo slash hands on slash hit there is hands on steps under the directory so you can follow the steps to create a stack the first step you need to create a stack by this once the stack created you can check the stack status by the hit resource list okay let me log on that server so you can go to the hands on and go to the hit you can source the openrc and then you can use the hit event okay someone someone created the stack once you create the stack you can check the status by the hit resource list in the hands on stack it just create load balance load balance group that is the cluster it has load balance and every member node in the cluster actually is the web server there is hands on step file you can check this file to know the detailed steps you can also use the novel console log to check the member node okay since this is test open stack so it's not very fast to boot virtual machine there is a stack created completed so let me show you how to check when your stack is created complete when you stack create completed you can check your this is output list you can check you can we can check the member list okay only one member the scale of link oh sorry this is the scale of link let me check the VIP you can verify your web server okay because currently the cluster has only one web server you can also if you want to log on the web server we you can get the priority key at first this is the priority key of the web server you can there is a script can help you output the key output the key to and log on that web server okay you can say in the web server there is application named web app running in the member node you can also use the neutral command to check the load balance configuration we can say there are load balance members in neutral this is the load balance VIP let me check okay there are two groups one is completed complete you can you can check your stack and test your web server group 8 is completed group 25 is completed very good let me check group 8 there is only one member let me check it's VIP check web server web servers work well okay another group G20 G22 is completed you can check your web server it's very great okay if you have not complete the hands on it doesn't matter you can continue that after the class so next I will let our team member Huang Lihua to talk about some tips about heat okay if you have any questions about the hands on just raise your hand I can answer your question okay okay I'm sorry the friend I will give you some tips of heat and first as we create the resource group status we can now check the status on stack level so we check the group by heat resource list because the group is the latest stack in heat and second if you if the department software department is expected too long you're going to use the 10 out to set the time out you may miss you can use temporary variant to check your temporary with parameters or you can also use the stack preview and to preview while the stack can be created because since the stack update is a little complex maybe you're not sure what will happen so you can use dry run the parameters to one call the stack update and to see what will be changed and next all the options in heat is limit with project scope we only provide in stack list API and provide parameters global turn it just this one you can get the stacks from all projects and other options just within the project scope and the environment in heat is powerful you can set parameters or parameters group or you can set some resource mapping so if you if needed please use the environment the last one sometimes the parameters will change if you don't replace your resource such as normal server you should set the parameters to immutable this is some of the tips of heat I think that's all please here you can reach me and I will copy it to you or send the email to you ok if you have any questions just answer just raise your question and we will try to answer your questions this environment will keep this week so you can use it after after the the days in this week and after that we will delete the environment