Automating VM creation: Difference between revisions

From Alliance Doc
Jump to navigation Jump to search
No edit summary
 
(65 intermediate revisions by 7 users not shown)
Line 1: Line 1:
''Parent page: [[OpenStack]]''
<languages/>
<translate>
<!--T:1-->
''Parent page: [[Cloud]]''


The below virtual machine (VM) setup files are intended to be used to quickly create VMs and clusters of VMs. The files come in two forms, [https://wiki.openstack.org/wiki/Heat Heat] templates, and [https://cloudinit.readthedocs.io/en/latest/ CloudInit] files; both use the [https://en.wikipedia.org/wiki/YAML YAML] file format. CloudInit files are used to initialize a particular VM and run within that VM. They can be used to update the operating system, install and configuring applications, create files, run commands, and create users and groups. Heat templates are even more powerful. They can create multiple VMs at once, configure security groups to access VMs from the outside world, create and configure networks, create and attach volumes to VMs, and pass information about other resources to CloudInit (e.g. floating IPs). They can also be used in conjunction with CloudInit files.
<!--T:2-->
To automate the creation of cloud VMs, volumes, etc. the [[OpenStack command line clients| OpenStack CLI]], [[#Using Heat Templates|Heat]], [[Terraform]], or the OpenStack python API can be used. Both the OpenStack CLI and Terraform are command line tools. While Heat is used through the OpenStack web dashboard, horizon. To install and configure settings and software within the VM, [[#Using cloud-init | cloud-init]] is used.


==Using CloudInit==
<!--T:19-->
The creation of CloudInit YAML files is not covered here, instead see the official CloudInit [https://cloudinit.readthedocs.io/en/latest/ documentation] . When you are creating a new VM a CloudInit file can be used to describe how the VM is to be configured after the selected image has been loaded. CloudInit files can be used with the Horizon dashboard (OpenStack's web GUI), the CLI, or the Python API. Here we describe how to use a CloudIinit file with Horizon.
In addition to these tools to create and provision your VMs, you can also gain access to the Compute Canada software stack (CVMFS) that is available on our general purpose computing clusters, within your VM. See the [[#Enabling CVMFS on your VM| Enabling CVMFS]] section below.


===Specifying a CloudInit File===
==Enabling CVMFS on your VM== <!--T:3-->
* Start as normal when launching an instance, by clicking [[File:Launch-Instance-Button-Kilo.png|125px]] under ''Project''->''Compute''->''Instances'' and specifying your VM's configuration as described in [[Cloud Quick Start#Launching a VM]].
CVMFS is a HTTP-based file system that provides a scalable, reliable, and low maintenance research software distribution service. At the client end, users just need to mount CVMFS and then use the software or libraries directly without worrying about compiling, building, or patching. All the software are pre-compiled for common OS flavors and even modularized so that users can simply load a software as a module.
* '''Before''' clicking ''Launch'', select the ''Post-Creation'' tab.
CVMFS has already been installed on Compute Canada cluster systems such as Cedar, Graham, and Beluga, while on cloud systems users need to enable it by hand, following these cloud instructions: [https://github.com/ComputeCanada/CVMFS/tree/main/cvmfs-cloud-scripts To enable CVMFS on CC Clouds].
* Specify your ''Customization Script Source'', in this case a CloudInit YAML file, by either coping and pasting into a text box (''Direct Input'' method) or uploading from a file from your desktop computer (''File'' method). Older versions of OpenStack, in particular IceHouse, only provide a text box to copy and past your CloudInit file into.
* Once the usual selections for your VM, as described in [[Cloud Quick Start#Launching a VM | Launching a VM]], have been made and the CloudInit YAML file is included, click ''Launch'' to create the VM.
* It may take some time for CloudInit to complete depending on what has been specified in the CloudInit YAML file.


===Checking CloudInit Progress===
<!--T:18-->
To see the progress of CloudInit on a VM, check the console log of the VM by:
For more information please see the [[Accessing_CVMFS|Compute Canada CVMFS documentation]] and [https://cvmfs.readthedocs.io/en/stable/ CERN CVMFS documentation]


* Selecting ''Project''->''Compute''->''Instances'' in the left hand menu.
==Using cloud-init== <!--T:4-->
* Click on the ''Instance Name'' of the VM. This will provide more information about the particular VM.
Cloud-init files are used to initialize a particular VM and run within that VM. They can be thought of as a way to automate tasks you would perform at the command line while logged into your VM. They can be used to perform tasks such as updating the operating system, installing and configuring applications, creating files, running commands, and create users and groups. Cloud-init can be used to setup other provisioning tools such as [https://docs.ansible.com/ ansible] or [https://puppet.com/ puppet] to continue with the software and VM configuration if desired.
* Select the ''Log'' tab and look for lines containing 'clout-init' for information about the various phases of CloudInit.
* When CloudInit has finished running the following line will appear near or at the end of the log:


  Cloud-init v. 0.7.5 finished at Wed, 22 Jun 2016 17:52:29 +0000. Datasource DataSourceOpenStack [net,ver=2]. Up 44.33 seconds
<!--T:20-->
Cloud-init configuration is specified using plain text in the [https://en.wikipedia.org/wiki/YAML YAML] format. To see how to create cloud-init files see the official cloud-init [https://cloudinit.readthedocs.io/en/latest/ documentation]. cloud-init files can be used with the Horizon dashboard (OpenStack's web GUI), Terraform, the CLI, or the Python API. Here we describe how to use a cloud-iinit file with Horizon.


==Using Heat Templates==
===Specifying a cloud-init File=== <!--T:5-->
As with CloudInit the creation of Heat Orchestration Template (HOT) files is not covered here, instead see the official [http://docs.openstack.org/developer/heat/template_guide/hot_guide.html documentation]. Heat allows automation of operations performed in Horizon as well as the ability to pass information into the embeded CloudInit files, such as an IP of another server. It also allows one to add wait conditions which signal to OpenStack when the creation of the stack is complete. These wait conditions can be triggered from within the running VMs once various setup steps have been completed. Finally Heat allows output to be created from the resulting stack, such as indicating the URL for a particular service created by the stack.
# Start as normal when launching an instance, by clicking [[File:Launch-Instance-Button-Kilo.png|125px]] under ''Project''->''Compute''->''Instances'' and specifying your VM's configuration as described in [[Cloud Quick Start#Launching a VM | Launching a VM]].
# '''Before''' clicking ''Launch'', select the ''Post-Creation'' tab and specify your ''Customization Script Source'', in this case a Cloud-init YAML file, by either copying and pasting into a text box (''Direct Input'' method) or uploading from a file from your desktop computer (''File'' method). Older versions of OpenStack, in particular IceHouse, only provide a text box to copy and past your CloudInit file into.
# Once the usual selections for your VM, as described in [[Cloud Quick Start#Launching a VM | Launching a VM]], have been made and the Cloud-init YAML file is included, click ''Launch'' to create the VM. It may take some time for CloudInit to complete depending on what has been specified in the Cloud-init YAML file.


To use a HOT file:
===Checking Cloud-init Progress=== <!--T:6-->
To see the progress of Cloud-init on a VM, check the console log of the VM by:


* Select ''Project''->''Ochestration''->''Stacks''
<!--T:7-->
* Click the ''Launch Stack'' button to start creating a new stack
# Selecting ''Project''->''Compute''->''Instances'' in the left hand menu.
* Provide a HOT file. This can be done using a URL, File, or Direct Input. To use a HOT file from the table below, select ''URL'' for ''Template Source'' and copy and paste the URL in the table into the ''Template URL'' box.
# Click on the ''Instance Name'' of the VM. This will provide more information about the particular VM.
* Click ''Next'' to begin setting your stack parameters. Stack parameters will very depending on the template, however all Stacks have the following parameters by default:
# Select the ''Log'' tab and look for lines containing 'clout-init' for information about the various phases of CloudInit.
** The ''Stack Name'' parameter which identifies a given stack, choose a name which is meaningful.
# When Cloud-init has finished running the following line will appear near or at the end of the log:
** The ''Creation Timeout'' parameter indicates how long after stack creation before OpenStack will give up trying to create the stack if it hasn't finished.
** The ''Password for user '' parameter sets the password required for later stack changes.
* Click ''Launch'' to begin creating your stack.


To graphically see the progress of you stack creation click on the ''Stack Name'' and select the ''Topology'' tab. Gray nodes indicate creation in progress, green nodes have finished being created, and red nodes indicate failures. Once the stack has completed successfully click the ''Overview'' tab to see any information that the stack may provide (e.g. url to access a service).
<!--T:8-->
Cloud-init v. 0.7.5 finished at Wed, 22 Jun 2016 17:52:29 +0000. Datasource DataSourceOpenStack [net,ver=2]Up 44.33 seconds


==Available Setups==
<!--T:9-->
The log must be refreshed manually by clicking the ''Go'' button


==Using Heat Templates== <!--T:10-->
Heat templates are even more powerful, they can be used to automate tasks performed in the OpenStack dashboard such as creating multiple VMs at once, configuring security groups, creating and configuring networks, and creating and attaching volumes to VMs. Heat templates can be used in conjunction with cloud-init files, once Heat has created the VM it can pass a cloud-init file to that VM to perform setup tasks and even include information about other resources dynamically in the cloud-init files (e.g. floating IPs of other VMs).


{| class="wikitable"
<!--T:21-->
|-
As with cloud-init the creation of [https://wiki.openstack.org/wiki/Heat Heat] Orchestration Template (HOT) files is not covered here, instead see the official [http://docs.openstack.org/developer/heat/template_guide/hot_guide.html documentation]. HOT files are also written in the [https://en.wikipedia.org/wiki/YAML YAML] format. Heat allows automation of operations performed in the OpenStack dashboard (Horizon) as well as the ability to pass information into the embedded CloudInit files, such as an IP of another server. Before using a Heat template there is usually no need to create any resources in advance. In fact it is often good practice to remove any resources you are not currently using before hand, as using a Heat template consumes resources towards your quota and will fail if it tries to exceed your quota.
! Setup !! Description !! Type !! Compatible Images !! Minimum Required OpenStack Version  !! Status !! URL
|-
| Hadoop+Spark || Creates a Hadoop cluster with Spark configured to run ontop of HDFS and submit jobs using YARN. || Heat Template || ubuntu-server-14.04-amd64 || Kilo || Has been used successfully with the c1-7.5gb-30 flavor at west-cloud. Needs further testing and streamlining. || https://raw.githubusercontent.com/cgeroux/heat-hadoop-spark/master/hadoop%2Bspark.yaml
|}
See [[CC-Cloud Resources]] for the OpenStack versions running on the CC clouds.


[[Category:CC-Cloud]]
<!--T:11-->
To create a stack using a HOT file:
 
<!--T:12-->
# Select ''Project''->''Orchestration''->''Stacks'' and click the ''Launch Stack'' button to start creating a new stack.
# Provide a HOT file by entering the URL, the File name, or by Direct Input. Here, we will use a HOT file from one of the links in section ''Available Setups'' below.
# In the ''Template Source'' box, select ''URL'' from the drop-down list.
# Paste the selected URL into the ''Template URL'' box.
# Click ''Next'' to begin setting stack parameters; these vary depending on the template, however all stacks have the following parameters by default:
#*''Stack Name''; choose a name which is meaningful.
#*''Creation Timeout''; indicates how long after stack creation before OpenStack will give up trying to create the stack if it hasn't finished; the default value is usually sufficient.
#*''Password for user ''; sets the password required for later stack changes. This is seldom used as many of the stacks mentioned in the next section are not designed to be updated.
# Click ''Launch'' to begin creating your stack.
 
<!--T:13-->
To graphically see the progress of your stack creation click on the ''Stack Name'' and select the ''Topology'' tab. Gray nodes indicate that creation is in progress, green nodes have finished being created, and red nodes indicate failures. Once the stack has completed successfully click the ''Overview'' tab to see any information that the stack may provide (e.g. a URL to access a service or website).
 
<!--T:16-->
[[Category:Cloud]]
</translate>

Latest revision as of 19:13, 15 July 2024

Other languages:

Parent page: Cloud

To automate the creation of cloud VMs, volumes, etc. the OpenStack CLI, Heat, Terraform, or the OpenStack python API can be used. Both the OpenStack CLI and Terraform are command line tools. While Heat is used through the OpenStack web dashboard, horizon. To install and configure settings and software within the VM, cloud-init is used.

In addition to these tools to create and provision your VMs, you can also gain access to the Compute Canada software stack (CVMFS) that is available on our general purpose computing clusters, within your VM. See the Enabling CVMFS section below.

Enabling CVMFS on your VM[edit]

CVMFS is a HTTP-based file system that provides a scalable, reliable, and low maintenance research software distribution service. At the client end, users just need to mount CVMFS and then use the software or libraries directly without worrying about compiling, building, or patching. All the software are pre-compiled for common OS flavors and even modularized so that users can simply load a software as a module. CVMFS has already been installed on Compute Canada cluster systems such as Cedar, Graham, and Beluga, while on cloud systems users need to enable it by hand, following these cloud instructions: To enable CVMFS on CC Clouds.

For more information please see the Compute Canada CVMFS documentation and CERN CVMFS documentation

Using cloud-init[edit]

Cloud-init files are used to initialize a particular VM and run within that VM. They can be thought of as a way to automate tasks you would perform at the command line while logged into your VM. They can be used to perform tasks such as updating the operating system, installing and configuring applications, creating files, running commands, and create users and groups. Cloud-init can be used to setup other provisioning tools such as ansible or puppet to continue with the software and VM configuration if desired.

Cloud-init configuration is specified using plain text in the YAML format. To see how to create cloud-init files see the official cloud-init documentation. cloud-init files can be used with the Horizon dashboard (OpenStack's web GUI), Terraform, the CLI, or the Python API. Here we describe how to use a cloud-iinit file with Horizon.

Specifying a cloud-init File[edit]

  1. Start as normal when launching an instance, by clicking Launch-Instance-Button-Kilo.png under Project->Compute->Instances and specifying your VM's configuration as described in Launching a VM.
  2. Before clicking Launch, select the Post-Creation tab and specify your Customization Script Source, in this case a Cloud-init YAML file, by either copying and pasting into a text box (Direct Input method) or uploading from a file from your desktop computer (File method). Older versions of OpenStack, in particular IceHouse, only provide a text box to copy and past your CloudInit file into.
  3. Once the usual selections for your VM, as described in Launching a VM, have been made and the Cloud-init YAML file is included, click Launch to create the VM. It may take some time for CloudInit to complete depending on what has been specified in the Cloud-init YAML file.

Checking Cloud-init Progress[edit]

To see the progress of Cloud-init on a VM, check the console log of the VM by:

  1. Selecting Project->Compute->Instances in the left hand menu.
  2. Click on the Instance Name of the VM. This will provide more information about the particular VM.
  3. Select the Log tab and look for lines containing 'clout-init' for information about the various phases of CloudInit.
  4. When Cloud-init has finished running the following line will appear near or at the end of the log:

Cloud-init v. 0.7.5 finished at Wed, 22 Jun 2016 17:52:29 +0000. Datasource DataSourceOpenStack [net,ver=2]. Up 44.33 seconds

The log must be refreshed manually by clicking the Go button

Using Heat Templates[edit]

Heat templates are even more powerful, they can be used to automate tasks performed in the OpenStack dashboard such as creating multiple VMs at once, configuring security groups, creating and configuring networks, and creating and attaching volumes to VMs. Heat templates can be used in conjunction with cloud-init files, once Heat has created the VM it can pass a cloud-init file to that VM to perform setup tasks and even include information about other resources dynamically in the cloud-init files (e.g. floating IPs of other VMs).

As with cloud-init the creation of Heat Orchestration Template (HOT) files is not covered here, instead see the official documentation. HOT files are also written in the YAML format. Heat allows automation of operations performed in the OpenStack dashboard (Horizon) as well as the ability to pass information into the embedded CloudInit files, such as an IP of another server. Before using a Heat template there is usually no need to create any resources in advance. In fact it is often good practice to remove any resources you are not currently using before hand, as using a Heat template consumes resources towards your quota and will fail if it tries to exceed your quota.

To create a stack using a HOT file:

  1. Select Project->Orchestration->Stacks and click the Launch Stack button to start creating a new stack.
  2. Provide a HOT file by entering the URL, the File name, or by Direct Input. Here, we will use a HOT file from one of the links in section Available Setups below.
  3. In the Template Source box, select URL from the drop-down list.
  4. Paste the selected URL into the Template URL box.
  5. Click Next to begin setting stack parameters; these vary depending on the template, however all stacks have the following parameters by default:
    • Stack Name; choose a name which is meaningful.
    • Creation Timeout; indicates how long after stack creation before OpenStack will give up trying to create the stack if it hasn't finished; the default value is usually sufficient.
    • Password for user ; sets the password required for later stack changes. This is seldom used as many of the stacks mentioned in the next section are not designed to be updated.
  6. Click Launch to begin creating your stack.

To graphically see the progress of your stack creation click on the Stack Name and select the Topology tab. Gray nodes indicate that creation is in progress, green nodes have finished being created, and red nodes indicate failures. Once the stack has completed successfully click the Overview tab to see any information that the stack may provide (e.g. a URL to access a service or website).