Create CentOS|Ubuntu|Debian VM Templates on OpenNebula

Posted on 323 views

How can I create Ubuntu / CentOS / Debian and any other Linux distribution VM Template in OpenNebula?. In OpenNebula, Virtual Machines cannot be created without defined VM Templates. The VM Template Pool allows OpenNebula administrators and users to register Virtual Machine definitions in the system, to be instantiated later as Virtual Machine instances.

The VM Templates can be instantiated several times, and also shared with other users in OpenNebula cloud platform. The Templates are stored in the system and they’re easy to browse and instantiate VMs from them. We will show one example of defining VM templates on OpenNebula and the same process can be applied for any other template.

Before you proceed, an OS image is required in OpenNebula, refer to guide below for how-to:

Create CentOS|Ubuntu|Debian VM Templates on OpenNebula

A Virtual Machine created on OpenNebula system will consist of:

  • A capacity in terms of memory and CPU
  • A set of NICs attached to one or more virtual networks
  • A set of disk images
  • Optional attributes like VNC graphics, the booting order, context information, etc.

Step 1: Initiate VM Template Creation

Login to OpenNebula Sunstone Web console and navigate to “Templates” > “VMs

Create-VM-Template-OpenNebula-01-1024x279

Hit the “+” button and choose “Create

Step 2: Fill the required information for Template creation

Under the “General” section input:

  • Template Name
  • Template Description
  • Choose Hypervisor
  • Template Logo
  • Memory and CPU details

Create-VM-Template-OpenNebula-2-1024x607

Under the “Storage” section input:

  • Choose VM image added previously

Create-VM-Template-OpenNebula-03-1024x569

Under the “Network” section input:

  • Default network for the VM template
  • Any other network option that applies for your template

Create-VM-Template-OpenNebula-04-1024x507

Under “OS & CPU” set options you want to use.

  • Boot
  • Kernel
  • Ramdisk
  • Features
  • CPU Model

I’ve added below two options which disables IPv6 and change naming of network interfaces:

 net.ifnames=0 ipv6.disable=1

See below screenshot.

Create-VM-Template-OpenNebula-05-1024x649

Under “Input/Output” you can set Graphics and PCI options

Create-VM-Template-OpenNebula-06-1024x643

A default SSH key can be added under “Context” > “Configuration” section. Same for text of script to be executed when the machine starts up.

Create-VM-Template-OpenNebula-07-1024x669

You can play with other settings in the “Scheduling” and “Hybrid” sections. When done hit the “Create” button.

The template should appear in the list of available OpenNebula VM Templates.

Create-VM-Template-OpenNebula-09-1024x299

Clicking on the name displays more information about the template:

Create-VM-Template-OpenNebula-10-1024x480

Step 3: Test by Creating VM from the Template

We can test our template by provisioning a VM instance from it. This is done from “Instances” > “VMs” > “+ > “Create

Create-VM-Template-OpenNebula-11-1024x353

Choose VM template to create a VM from.

Create-VM-Template-OpenNebula-13-2048x568

Give the VM a name, instance count to create, and customize resources allocation if need be.

Create-VM-Template-OpenNebula-12-2048x1245

And all other parameters that you want to set.

Create-VM-Template-OpenNebula-14-1024x454

Once you choose “Create” the VM will be in Pending state.

Create-VM-Template-OpenNebula-15-2048x674

Once ready for use it will be in “RUNNING” state.

Create-VM-Template-OpenNebula-16-2048x731

You can get VM details such as IP Address by clicking the instance name.

Create-VM-Template-OpenNebula-17-2048x1235

Test connectivity by pinging the IP Address:

$ ping -c 1 172.20.20.100
PING 172.20.20.100 (172.20.20.100) 56(84) bytes of data.
64 bytes from 172.20.20.100: icmp_seq=1 ttl=64 time=0.611 ms

--- 172.20.20.100 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.611/0.611/0.611/0.000 ms

Do the same for SSH

$ ssh  [email protected]
The authenticity of host '172.20.20.100 (172.20.20.100)' can't be established.
ECDSA key fingerprint is SHA256:/k4pJX5pZiQHPMgnkPLAjtwqbBmNbuY6QP+5BiTEmHA.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.20.20.100' (ECDSA) to the list of known hosts.
Enter passphrase for key '/home/josphat/.ssh/id_rsa':
Activate the web console with: systemctl enable --now cockpit.socket

[[email protected] ~]$

Confirm interface naming changed as configured through kernel parameters:

$ ip ad
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 02:00:ac:14:14:64 brd ff:ff:ff:ff:ff:ff
    inet 172.20.20.100/24 brd 172.20.20.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::acff:fe14:1464/64 scope link
       valid_lft forever preferred_lft forever

We’ve confirmed the VM was created successfully from the template. We were also able to ssh into the instance.

References:

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.