Why and how to setup your own Cloud on Bare-Metal

Why and how to setup your own Cloud on Bare-Metal

In this article I will be explaining the various benefits that coming with deploying your own cloud, which software to use, and how to proceed with setting everything up.

The benefits of building your own cloud includes control over hardware, better performance, and is also much more cost effective. Renting bare-metal hardware from providers is a very efficient approach of consuming compute resources as these providers offer hardware at a lower performance to cost ratio than traditional cloud providers who maintain an additional layer of management on Computing resources.

Consuming Bare-Metal resources is quite the challenge, as each server has lots of power to spare — running services directly on Bare-Metal would waste resources, especially if the machines contain modern performance rates. It is more efficient to run multiple services in multiple Virtual Machines, you can utilize software such as OpenNebula in order to run these Virtual Machines with ease.

A cloud also allows you to maintain everything under one center area of control, allowing easier management of IT Resources especially as the cloud grows.

In this article I will explain how you can proceed with deploying your own OpenNebua Cloud, in this guide we will be using Packet.net’s Bare-Metal Service, but you can use any Dedicated Server provider available in the market.

Introduction

OpenNebula is an Open Source Cloud Management Platform that allows you to build Private Clouds with ease.

OpenNebula is an alternative to OpenStack, and covers the majority of functionality available by OpenStack. OpenNebula is a mature platform and describes itself as “Enterprise Ready” with a wide user-base and proven stability/scale-ability.

Preparation

This guide shows how to deploy and install OpenNebula in a one-node configuration. Additional hosts can easily be prepared and added in a future stage by following the “Installing OpenNebula KVM Node” section in the bottom of this article.

While OpenNebula is very lightweight and can be used on a t1.small($.07/hr) device with no issues, we will use a c1.small server ($.40/hr) with Ubuntu 16.04 in this guide. The single machine will host OpenNebula’s Management Interface as well as the KVM Hypervisor to run Virtual Machines in the same node.

When deploying your server you should select a /29 IPv4 subnet (4 Usable IP’s), which will be used to assign VM’s. This saves you the trouble of requesting additional IP’s post deployment using Packet’s Elastic IPv4 feature.

Selecting a subnet size

Let’s go ahead and deploy this node:

It should take about 10 minutes for your server to deploy and install. Once the server is provisioned you can SSH into the device by using authorized SSH keys.

Install OpenNebula

First, add OpenNebula to the apt-get repository –

# wget -q -O- https://downloads.opennebula.org/repo/repo.key | apt-key add -
​
OK
​
# apt-get install apt-transport-https
# echo "deb https://downloads.opennebula.org/repo/5.4/Ubuntu/16.04 stable opennebula" > /etc/apt/sources.list.d/opennebula.list

Then install OpenNebula and dependencies (OpenNebula Management Interface)

# apt-get update
​
# apt-get install -y opennebula opennebula-sunstone opennebula-gate opennebula-flow
# /usr/share/one/install_gems
​
PRESS [ENTER] To continue

Utilize MySQL Database instead of SQLite (optional but recommended for production workloads).

# apt-get install -y mysql-server
​
While not mandatory, it is highly recommended that you set a password for the MySQL administrative "root" user.

After MySQL is installed you need to add privileges to oneadmin.

# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. [...]
​
mysql> GRANT ALL PRIVILEGES ON opennebula.* TO 'oneadmin' IDENTIFIED BY 'THEPASSWORD';
​
Query OK, 0 rows affected (0.00 sec)
​
mysql> SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
​
mysql> exit

The final step in enabling MySQL includes modifying the oned.conf (ONE Daemon Configuration) file.

# nano /etc/one/oned.conf
​
Navigate down to DB Section, and comment out DB = [ backend = “sqlite” ] 
​
Uncomment the MySQL Section and enter the password you set via GRANT ALL PRIVILEGES.

Starting OpenNebula

# systemctl start opennebula
# systemctl start opennebula-sunstone

Test if OpenNebula is running properly:

# oneuser show
USER 0 INFORMATION
ID              : 0
NAME            : oneadmin
GROUP           : oneadmin
PASSWORD        : 3bc15c8aae3e4124dd409035f32ea2fd6835efc9
AUTH_DRIVER     : core
ENABLED         : Yes
​
The above text means that OpenNebula is operating normally, and no additional changes need to be made.

Log into OpenNebula Sunstone Interface

This will output your OpenNebula Username:Password which can be used to Manage your deployment.

# cat /var/lib/one/.one/one_auth
​
oneadmin:Vu29Sk39zMn9

Now navigate to http://147.75.x.x:9869 to find the user interface.

Install OpenNebula KVM Node

You can repeat these steps in additional nodes to add additional nodes to your cluster.

# sudo apt-get install -y opennebula-node
​
Country of origin for the keyboard: 29 (US = 29)
​
# sudo service libvirt-bin restart

Passwordless SSH

# sudo su oneadmin
​
$ cd ~/.ssh
​
We need to ensure that the front-end can login to each node without any input, when adding additional nodes you need to sync the front-end .ssh folder with each node. 
​
$ cp id_rsa.pub authorized_keys                                                                                                                         This step should log you into the same user account using SSH without any input other than adding the host to your known_hosts file.
​
$ ssh <hostname>
​
Are you sure you want to continue connecting (yes/no)? Yes 
Welcome to Ubuntu 16.04.3 LTS 
​
$ exit
​
Connection to <hostname> closed.
​
$ exit
​
Now we are back to our root account.

Create a Network Bridge

You can follow this guide to create a network bridge for KVM on Bonded Networks with Packet.net.

https://help.packet.net/technical/networking/kvm-qemu-bridging-on-a-bonded-network

Adding KVM Node to Sunstone

Navigate to Infrastructure -> Hosts -> +

Type in your hostname:

Press refresh after a few seconds pass.

Adding a Network Subnet

Navigate to Network -> Virtual Networks -> +

Type your bridge name in Conf Tab.

Add your /29 subnet to Addresses Range:

Setup the context with the correct variables:

Adding Virtual Machine Images

Navigate to Storage -> Apps -> Search “KVM”

These are the images found in the default OpenNebula Marketplace.

Let’s select Ubuntu 16.04 and add it to our Image Datastore.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.