Managing Apache CloudStack Instances

Managing Apache CloudStack Instances

Instances are virtual machines that have reservation of resources (cores, RAM, (root and data) volumes, network offering, storage offering, service offering).

Contents

Creating an Instance

CloudStack instances are virtual machines (VMs) from an OS template (disk image) or ISO (virtual CD). Each instance is a new standalone server with allocated cpu cores, memory, networking and disk space. 

By clicking Add Instance in the Apache CloudStack panel, you enter the instance creation wizard to configure the server step by step.


  1. From the left menu in the CloudStack panel choose Compute > Instances, click Add Instance
  2. The Zone is already pre-filled based on the location of the CloudStack platform.

    69960000

  3. Choose a Template or ISO. Templates are images containing an OS used to boot up the server, or boot from an ISO a virtual DVD/ CD that can be uploaded separately.

    69959995

  4. Choose a Compute Offering for your Instance, which determines how many cpu cores and memory is allocated to the server.

    Information

    Info

    In the left menu go to Service Offerings, click on Compute Offerings to add a compute offering.

    69959996

  5. Choose a Data Disk offering to add an additional volume to your server. 

    Information

    Info

    In the left menu go to Service Offerings, click on Disk Offerings to add a disk offering.

    69959997

  6. Choose a Network in which the server will be deployed.

    Information

    Info

    A Network can be Isolated (add belong to a VPC) or Shared, which attaches a virtual NIC to the server providing a unique MAC address to assign an IPv4 and/ or IPv6 address.

    69959998

  7. Choose to associate an SSH key pair to the server. If you created SSH key pairs under the Account section they will show up here.

    69959999

  8. Select additional options under Advanced Mode, like boot type, add user data and/ or select an Affinity Group to place the virtual machine in. These options are not required but can help with setting up the virtual machine in a more specific state.
  9. Enter a name and click Launch Virtual Machine.
  10. After the server is deployed, you will see the password show up in the panel if password set has been configured in the chosen Template. In any other case start the web console from the top right when on the Instance details page to enter the server.

VirtIO drivers for Windows OS installation

Information

Elastic Compute platforms contain some standard Windows OS ISO’s having Virtio drivers embedded. To create a Windows VM, just use an ISO image with the desired version from the “Add instance” wizard.

Elastic Compute platforms contain some standard Windows OS ISO’s having Virtio drivers embedded. To create a Windows VM, select an ISO image with the desired version from the “Add instance” wizard. If you are going to install Windows from your own uploaded ISO, you might need to use VirtIO drivers ISO during the installation. By using VirtIO, paravirtualized drivers for KVM, the overall performance of the OS is much better.


  1. Start the Windows installation from your selected ISO.
  2. During the installation it can’t find the disks due to missing drivers.
  3. Go to the Instance overview, from the top right options detach the Windows ISO and attach the VirtIO ISO.
    69959994
  4. Load the missing drivers from the VirtIO ISO from the viostor\\amd64 folder.
  5. Swap back to the Windows ISO and continue the installation.

Rebooting an Instance

To apply changes or updates often a reboot of the servers is needed. You can reboot using an SSH connection and terminal or in the CloudStack panel.

  1. From the left menu choose Compute > Instance, click and server that you like to reboot.
  2. In the top right options, click Reboot Instance.
    69959992
  3. Confirm the reboot by clicking OK.

Destroying an Instance

To entirely remove an instance and free up the allocated resources, you must destroy and expunge the instance.

Information

Once you destroy an instance, it is set to Destroyed State and will be retained for 3 days(72 hours) keeping the allocated resources in use. You can revive the instance within this time by performing a ‘restore‘ action. After 3 days, the instance is automatically expunged. The expunge process wipes the disk and reallocates the reserved resources for this instance.
If you are sure you want to get rid of an instance straight away you can opt for expunging it at destruction by selecting this option on destroy. 

  1. From the left menu choose Compute > Instance, select the instance that you like to destroy.
  2. In the top right options, click Destroy Instance.
    69959986
  3. A Confirmation dialog box displays. If immediate removal is necessary select the expunge checkbox.
    NB!: if you select expunge you will NOT be able to recover the instance or its data. (Leaseweb cannot restore an expunged instance either! So think twice)
    69959993
  4. Confirm the delete action by clicking OK.
    The status of the instance is changed to Destroyed

    Information

    Destroyed instances are shown in the instances overview with state Destroyed.

    To recover a destroyed instance, click on the name of the instance and then click on Recover VM from the top right options.

    The instance is recovered in Stopped state, so make sure to Start the instance after it is recovered.

Attaching an ISO

You can attach an ISO to an instance, for example to perform various rescue operations on the server. An attached ISO can be accessed by starting the web console of the instance in the CloudStack panel.


  1. From the left menu choose Compute > Instance, click on the instance that you like to attach an ISO too.
  2. In the top right options, click Attach ISO.
    69959990
  3. Select the ISO from the drop down menu and click OK.
  4. Access the ISO data by starting the web console from the top right options in the Instance overview.
    N.B. If the ISO is not loaded, restart the instance and try the web console again.

Resetting Password for an Instance

Default templates provided by Leaseweb contain a set password script and have the password option enabled. For instances with these parameters available you can reset the password through the CloudStack panel.

Warning

To reset the root password for an instance, you must stop the instance. The template of your instance must have the cloud-set-guest-password script file, and the Password Enabled check box must be selected during creation of the template. The default templates that Leaseweb provides include this script file and are prepared for reset password functionality.

If you are configuring the template yourself, you can find information on downloading the cloud-set-guest-password script file from the CloudStack Admin Guide


  1. From the left menu choose Compute > Instance, click on the instance that you want to reset the password for.
  2. In the top right options, click Reset Password and confirm by clicking OK.
    69959991
  3. A new password is generated and shown in a pop-up dialog.

    Information

    You need this password to gain access to the instance either through SSH or by logging in to the Console. It is recommended to save the password. It will not be displayed again. If you forget the password, you need to reset it again.

Changing Instance resources (Compute Offering)

CloudStack instances get their computing resources from a template called Compute Offering. By changing the Compute Offering of an instance, the amount of cpu cores and memory allocated for the instance can be changed.

Warning

Make sure the instance is in Stopped state before changing the compute offering.


  1. From the left menu choose Compute > Instance, click on the instance that you want to change the cpu and memory resources.
  2. In the top right options, click Scale VM.
    69959988
  3. Choose the new resources by selecting a Compute Offering and click OK.
    N.B. make sure to Start your instance after changing the Compute Offering.

Assigning an Instance to another Account

User accounts can have instances assigned to them that are not visible to other accounts. The Domain Admin account is able to see all instances and move instances between accounts.

Information

Info

Make sure the instance is in Stopped state before assigning it to another account.


  1. From the left menu choose Compute > Instance, click on the instance that you want to move to another account.
  2. In the top right options, click Assign Instance to Another Account.
    69959989
  3. Choose the Account to move the instance too, click Submit.

Viewing the Console

The console in the CloudStack panel enables connecting to the server directly when the public IP address is not available, firewall rule or network configuration permit accessing the server over ssh or to access an ISO that has been attached to the instance.


Perform the following steps to to view/access the Console:

  1. From the left menu choose Compute > Instance, click on the instance that you want open the console for.
  2. In the top right options, click the console icon.
    69959987
  3. In a new tab the console is started.
  4. Hit enter to activate the screen and enter credentials to gain access to the Console.

    Information

    The menu bar of the Console contains extra keys, clipboard and full screen mode.

    Ctrl-Alt-Del Linux: It will reboot the instance. Windows: It will display the login screen.
    Clipboard To copy text from host to guest instances.
    Ctrl-Esc Functional only for Windows.
    Keyboard Functional only for Windows. It changes the keyboard layout.

Adding Network to the Virtual Machine

CloudStack instances get network access through a virtual NIC acquired from a Network in CloudStack. It is possible to add multiple virtual NICs to an instance, by adding the instance to different Networks in CloudStack.


  1. From the left menu choose Compute > Instance, click on the instance name.
  2. Click on the NICs tab.
  3. Click Add Network to VM.
  4. Select the Network from the drop down menu and optionally provide an IPv4 address to be assigned.
  5. An additional NIC with MAC address will be attached to the instance, shown in the NICs tab overview. 
    69959985

    Information

    From the NICs tab, you can remove a network, or set a network as the default network of the instance.
    Note: The network that you set as default cannot be removed.

    Depending on your operating system, the network interface which is created upon adding a new network will be automatically detected or not. If the operating system does not support hot plugin, you may have to reboot and/or configure the network interface manually.

Converting virtual machine to use paravirtualized hardware (VirtIO)

Linux 

All the popular Linux distros have virtio drivers installed and embedded into initramfs, along with the filesystems mounted by UUIDs instead of hardcoded disk paths.
That means, nothing has to be changed in the OS settings to boot with VirtIO devices.

However, you can use the following commands to verify that your operating system has the necessary settings. 

Debian and Ubuntu

  1. Check if your initramfs has virtio_blk driver in it:

    lsinitramfs /boot/initrd.img-`uname -r` | grep virtio_blk
    # output should look like the following: lib/modules/4.9.0-8-amd64/kernel/drivers/block/virtio_blk.ko

    If the command didn’t produce any output, that means your initramfs doesn’t have virtio drivers in it. You should rebuild the initramfs with the virtio drivers.

  2. Check /etc/fstab. It should have UUIDs instead of absolute disk paths:

    # Example of proper fstab entries
    UUID=b17673c8-83e8-4557-8b29-741a83afddba    /    ext4    errors=remount-ro   0 1
    UUID=bb0760d8-9371-11e9-9a0a-066f820017f8    none swap    sw                  0 0
    
    # Example of absolute paths, they should be changed to use UUIDs
    /dev/sda1                                    /    ext4    errors=remount-ro   0 1
    /dev/sda2                                    none swap    sw                  0 0
  3. Check that the kernel cmdline uses uuid for the rootfs:

    cat /proc/cmdline
    # Example of cmdline with valid root= parameter value:
    BOOT_IMAGE=/vmlinuz-3.2.0-4-amd64 root=UUID=30c81d3d-ee9f-4a88-81c1-5f349b22ba1d ro debian-installer=en_US quiet
    
    # Example of cmdline with invalid root= parameter value:
    BOOT_IMAGE=/vmlinuz-3.2.0-4-amd64 root=/dev/sda ro debian-installer=en_US quiet
  4. Log in to the CloudStack panel.

  5. From the left menu choose Compute > Instances, click on the instance and stop it.

  6. In the instance overview, click on Edit Instance from the top right options.
    69959984

  7. From the OS Type-menu, find and select Linux/BSD 64-bit and confirm selection by clicking OK.
    69959983

  8. Now you can start up the instance again.

CentOS

  1. Check if your initramfs has virtio driver in it:

    lsinitrd /boot/initramfs-`uname -r`.img | grep virtio_blk
    # output should look like the following: -rwxr--r--   1 root     root        21272 Mar  7  2012 lib/modules/2.6.32-220.7.1.el6.x86_64/kernel/drivers/block/virtio_blk.ko

    If the command didn’t produce any output, that means your initramfs doesn’t have virtio drivers in it. You should rebuild the initramfs with the virtio drivers using the following command:

    mkinitrd -f --with=virtio_blk --with=virtio_pci --with=virtio --with=virtio_net /boot/initrd-`uname -r`.img `uname -r`
  2. Check /etc/fstab. It should have UUIDs instead of absolute disk paths:

    # Example of proper fstab entries
    UUID=d1d89510-3cb6-4d74-900c-8fff7227fe6a /boot                   ext2    defaults        1 2
    UUID=e4c93dc8-c243-46f9-bb33-92f2b6ac7242 /                       ext4    defaults        1 2
    
    
    # Example of absolute paths, they should be changed to use UUIDs
    /dev/sda1                                 /boot                   ext2    defaults        1 2
    /dev/sda2                                 /                       ext4    defaults        1 2
  3. Check that the kernel cmdline uses uuid for the rootfs:

    # Example of cmdline with valid root= parameter value:
    ro root=UUID=30c81d3d-ee9f-4a88-81c1-5f349b22ba1d LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=129M@0M rhgb quiet
    
    
    # Example of cmdline with invalid root= parameter value:
    ro root=/dev/sda1 LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=129M@0M rhgb quiet
  4. Log in to the CloudStack panel.

  5. From the left menu choose Compute > Instances, click on the instance and stop it.

  6. In the instance overview, click on Edit Instance from the top right options.
    69959984

  7. From the OS Type-menu, find and select Linux/BSD 64-bit and confirm selection by clicking OK.
    69959983

  8. Now you can start up the instance again.

FreeBSD

You need to make some preparations before switching to VirtIO:

  1. Add the following line to your /boot/loader.conf:

    virtio_blk_load="YES"
  2. Edit your /etc/fstab to use new drive names. Virtio drives have “vtbd” prefixes, so:
    /dev/ada0s1a becomes /dev/vtbd0s1a
    /dev/da1s2c becomes /dev/vtbd1s2c
    etc.

  3. Edit your network configuration in /etc/rc.conf. Virtio network cards have “vtnet” names, so:
    em0 becomes vtnet0
    em1 becomes vtnet1
    etc.

  4. Log in to the CloudStack panel.

  5. From the left menu choose Compute > Instances, click on the instance and stop it.

  6. In the instance overview, click on Edit Instance from the top right options.
    69959984

  7. From the OS Type-menu, find and select Linux/BSD 64-bit and confirm selection by clicking OK.
    69959983

  8. Now you can start up the instance again.

Windows

Warning

After migrating to Virtio, your virtual machine’s network interfaces would be detected as new ones, so please verify that you have console access to the virtual machine from the CloudStack web-interface.

To make your Windows VM be able to boot from Virtio, you need to install Virtio drivers first, and create a Virtio volume:

  1. On the VM: download the ISO with stable Virtio drivers:
    https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso
  2. Extract the ISO file to some directory (you can use https://www.7-zip.org program for that):
    5537814
  3. Navigate to the directory \NetKVM\\amd64.
  4. Right-click on the file netkvm.inf and select Install:
    5537813
  5. Navigate to the directory \viostor\\amd64.
  6. Right-click on the file viostor.inf and select Instal (the same as with NetKVM driver installation step).
  7. Login to the CloudStack panel.

  8. From the left menu choose Storage > Volumes, click Add Volume.

  9. Create a volume with the smallest disk size available:
    69959982

  10. Attach this newly created volume to the virtual machine.

  11. In the virtual machine, open the Server Manager program, then navigate to Tools -> Computer Management menu:
    5537809

  12. In the Computer Management window appeared, navigate to Storage -> Disk management menu entry. Right-click on the new disk and select Online if there is such an option:
    5537808

  13. Right click on the disk again and select Initialise Disk. In the pop-up window just press OK.

  14. Right click on the unallocated space and select New simple volume:
    5537807

  15. In the volume creation wizard pop-up window just leave everything by default by keep pressing Next.

  16. After the volume is created and appeared in Windows Explorer disks list, shut down the virtual machine.

  17. In CloudStack interface click on your virtual machine instance to open its properties.

  18. Click on Edit button. In the OS Type drop-down list, select Windows.

  19. Save the settings and start the virtual machine.
  20. The additional volume you’ve created can be detached and expunged after the successful boot.