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
apt update -y
Now install Snap
apt install snapd
Now install core22
snap install core22
Now Install Openstack
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
sudo useradd -m -s /bin/bash -p "$(openssl passwd -1 'password')" sunbeam && sudo usermod -aG sudo sunbeam && su - sunbeam
Now install Sunbeam dependencies
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
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
chmod 644 ~/.ssh/authorized_keys
sunbeam cluster bootstrap
You should see this:
During this process you will be asked numerous questions:
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:
⠧ 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.
sunbeam configure --accept-defaults --openrc demo-openrc
You will see this output on completion.
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.Bash
source demo-openrc
Use code with caution.content_copy - Create a Keypair (optional): This allows you to securely access your VM later.
openstack keypair create mykey > mykey.pem chmod 600 mykey.pem
- Launch the VM:
openstack server create --flavor m1.small --image ubuntu-22.04 \ --network private --key-name mykey myvm
- Check VM Status:
openstack server list
- Look for your VM in the list. Its status should change from “BUILD” to “ACTIVE.”
- Get VM IP Address:
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 withopenstack 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):
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 thesunbeam
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.
Recent Comments