Build a VM Host with Sunbeam on Openstack Ubuntu

Sunbeam is a package that makes the deployment of an OpenStack virtualization cluster much simpler, essentially allowing you to create your own private cloud. Sunbeam uses microK8s and is very powerful.

Note: Minimum system requirements (4-core CPU, 16 GB RAM)

Step 1 – Update Ubuntu and Install Snap, Core 22 and OpenStack

This is all the software needed to make your Ubuntu Server a Hypervisor

First, run apt update -y

Bash
apt update -y

Now install Snap

Bash
apt install snapd

Now install core22

Bash
snap install core22

Now Install Openstack

Bash
snap install openstack

Step 2 – Install Sunbeam Dependencies

First, create a user called Sunbeam, give it a password, then switch the user to it.

Note: Ive set the password to “password” – Make sure you change this value

Bash
sudo useradd -m -s /bin/bash -p "$(openssl passwd -1 'password')" sunbeam && sudo usermod -aG sudo sunbeam && su - sunbeam

Now install Sunbeam dependencies

Bash
sudo sunbeam prepare-node-script | bash -x && newgrp snap_daemon

You should see output like this:

Note that you will be prompted for your password

Bash
sunbeam@KVM:~$ sudo sunbeam prepare-node-script | bash -x && newgrp snap_daemon
[sudo] password for sunbeam: 
++ lsb_release -sc
+ '[' jammy '!=' jammy ']'
++ whoami
+ USER=sunbeam
++ id -u
+ '[' 1000 -eq 0 -o sunbeam = root ']'
+ SUDO_ASKPASS=/bin/false
+ sudo -A whoami
+ sudo grep -r sunbeam /etc/sudoers /etc/sudoers.d
+ grep NOPASSWD:ALL
+ echo 'sunbeam ALL=(ALL) NOPASSWD:ALL'
+ sudo install -m 440 /tmp/90-sunbeam-sudo-access /etc/sudoers.d/90-sunbeam-sudo-access
+ rm -f /tmp/90-sunbeam-sudo-access
+ dpkg -s openssh-server
+ echo 'fs.inotify.max_user_instances = 1024'
+ sudo tee /etc/sysctl.d/80-sunbeam.conf
fs.inotify.max_user_instances = 1024
+ sudo sysctl -q -p /etc/sysctl.d/80-sunbeam.conf
+ sudo snap connect openstack:ssh-keys
+ sudo addgroup sunbeam snap_daemon
Adding user `sunbeam' to group `snap_daemon' ...
Adding user sunbeam to group snap_daemon
Done.
+ newgrp snap_daemon
Generating public/private rsa key pair.
Created directory '/home/sunbeam/.ssh'.
Your identification has been saved in /home/sunbeam/.ssh/id_rsa
Your public key has been saved in /home/sunbeam/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:DIifIICOG+zDRC50gLbTrPN8+5dFjGR5QOHR14HxqEY sunbeam@KVM
The key's randomart image is:
+---[RSA 4096]----+
|+..     .==  .+..|
|++ o .  .+.o oo. |
|X B . . o.+E.. . |
|+O = . o ..o.    |
|=oo o   S .o     |
|.*        ..     |
|  =       o      |
|   o .   o       |
|    ..o..        |
+----[SHA256]-----+
# 89.107.60.210:22 SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6
# 89.107.60.210:22 SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6
# 89.107.60.210:22 SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6
# 89.107.60.210:22 SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6
# 89.107.60.210:22 SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6
juju (3.2/stable) 3.2.4 from Canonicalโœ“ installed

Step 3 – Bootstrap Sunbeam

Now, you need to bootstrap Sunbeam to the cloud.

Note: This step takes quite a while to complete.

First, run this command

Bash
chmod 644 ~/.ssh/authorized_keys

Bash
sunbeam cluster bootstrap

You should see this:

During this process you will be asked numerous questions:

Bash
Management Networks shared by hosts (CIDRs, seperated by comma) (YOUR_IP_CIDR):   

[PRESS ENTER TO ACCEPT DEFAULT]

MetalLB address allocation range (supports multiple ranges, comma separated) 

Upon completion you will see this output:

Bash
โ ง Bootstrapping Juju onto machine ... 
โ  Bootstrapping Juju onto machine ... 
Node has been bootstrapped with roles: control, compute

Next, configure Sunbeam – this will put it into demo mode. You can find out more advanced installations by following the official documentation.

Bash
 sunbeam configure --accept-defaults --openrc demo-openrc

You will see this output on completion.

Bash
Writing openrc to demo-openrc ... done

Step 4 – Launch a VM (Virtual Machine)

To launch a virtual machine (VM) with Sunbeam, you’ll use the openstack command-line tool. Here’s how you can do it:

  • Source the OpenRC file: This will load the necessary environment variables for OpenStack interaction.Bashsource demo-openrc Use code with caution.content_copy
  • Create a Keypair (optional): This allows you to securely access your VM later.
Bash
openstack keypair create mykey > mykey.pem chmod 600 mykey.pem 
  • Launch the VM:
Bash
openstack server create --flavor m1.small --image ubuntu-22.04 \ --network private --key-name mykey myvm 
  • Check VM Status:
Bash
openstack server list 
  • Look for your VM in the list. Its status should change from “BUILD” to “ACTIVE.”
  • Get VM IP Address:
Bash
openstack server show myvm | grep -i addresses
  • This will show the private IP address of your VM on the private network.
  • Replace m1.small with the desired flavor (VM size).
  • Replace ubuntu-22.04 with the image name you want to use (you can find available images with openstack image list).
  • Replace mykey with the name of your keypair (if you created one).
  • Replace myvm with your desired VM name.

Step 5 – Accessing Your VM

  • SSH Access (if you created a keypair):
Bash
ssh -i mykey.pem ubuntu@<your_vm_ip_address>  <your_vm_ip_address> 
  • with the actual IP address you got in the previous step.
  • Horizon Dashboard: Sunbeam also installs a web-based dashboard called Horizon. Access it by opening a web browser and going to http://<your_host_ip_address>/horizon. Use the same credentials you created for the sunbeam user.

Important Notes:

  • Networking: The example above launches the VM on the private Network. If you want to access your VMs from outside your private network, you might need to configure floating IPs.
  • Custom Configuration: Sunbeam provides many configuration options. Refer to the official documentation for advanced setups.
  • Security: Always ensure proper security practices when deploying OpenStack, especially if it’s exposed to the internet.

Elsewhere On TurboGeek:  DevOps Guide to Important Terraform Concepts

Richard.Bailey

Richard Bailey, a seasoned tech enthusiast, combines a passion for innovation with a knack for simplifying complex concepts. With over a decade in the industry, he's pioneered transformative solutions, blending creativity with technical prowess. An avid writer, Richard's articles resonate with readers, offering insightful perspectives that bridge the gap between technology and everyday life. His commitment to excellence and tireless pursuit of knowledge continues to inspire and shape the tech landscape.

You may also like...

Leave a Reply

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

Translate ยป