April 25, 2024 by CodeFlowerHorn

Setting Up a KVM Hypervisor Host in Apache CloudStack


The compute host refers to a physical server running the Kernel-based Virtual Machine (KVM) hypervisor, which allows it to host and manage multiple virtual machines (VMs). Creating virtual machines must be done using the management server.

Add the repository for Apache Cloudstack

The Apache CloudStack version we used is 4.19

                                    mkdir -p /etc/apt/keyrings
wget -O- http://packages.shapeblue.com/release.asc | gpg --dearmor | sudo tee /etc/apt/keyrings/cloudstack.gpg > /dev/null

echo deb [signed-by=/etc/apt/keyrings/cloudstack.gpg] http://packages.shapeblue.com/cloudstack/upstream/debian/4.19 / > /etc/apt/sources.list.d/cloudstack.list
apt update -y
apt install cloudstack-agent openssh-server bridge-utils net-tools -y
                                
Setup bridge and static ip using netplan

After you paste the code below run netplan apply

                                    network:
version: 2
renderer: NetworkManager
ethernets:
    enp0s3: {}
    enp0s8: {}
bridges:
    cloudbr0:
        addresses: [192.168.1.101/24]
        dhcp4: false
        routes:
            - to: default
            via: 192.168.1.1
        nameservers:
            addresses: [8.8.8.8, 8.8.4.4]
            search: []
        interfaces: [enp0s3]
        parameters:
            stp: true
    cloudbr1:
        dhcp4: false
        interfaces: [enp0s8]
        parameters:
            stp: true
                                
Enable VNC for console proxy
                                    sed -i -e 's/\#vnc_listen.*$/vnc_listen = "0.0.0.0"/g' /etc/libvirt/qemu.conf
                                
Enable libvirtd in listen mode
                                    echo LIBVIRTD_ARGS=\"--listen\" >> /etc/default/libvirtd
                                
Mask socket/listen based configuration
                                    systemctl mask libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket libvirtd-tls.socket libvirtd-tcp.socket
                                
Configure default libvirtd configuration
                                    echo 'listen_tls=0' >> /etc/libvirt/libvirtd.conf
echo 'listen_tcp=0' >> /etc/libvirt/libvirtd.conf
echo 'tls_port = "16514"' >> /etc/libvirt/libvirtd.conf
echo 'tcp_port = "16509"' >> /etc/libvirt/libvirtd.conf
echo 'mdns_adv = 0' >> /etc/libvirt/libvirtd.conf
echo 'auth_tcp = "none"' >> /etc/libvirt/libvirtd.conf
                                
Restart libvirtd
                                    systemctl restart libvirtd
                                
Disable apparmour on libvirtd
                                    ln -s /etc/apparmor.d/usr.sbin.libvirtd /etc/apparmor.d/disable/
ln -s /etc/apparmor.d/usr.lib.libvirt.virt-aa-helper /etc/apparmor.d/disable/
apparmor_parser -R /etc/apparmor.d/usr.sbin.libvirtd
apparmor_parser -R /etc/apparmor.d/usr.lib.libvirt.virt-aa-helper
                                
SSH Authorized key

ssh public key is located at /var/lib/cloudstack/management/.ssh/id_rsa.pub on your management server

nano ~/.ssh/authorized_keys

paste the code below into ~/.ssh/authorized_keys

                                    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC7BhkJlLiglLzgeOjPE+0FBy6q6ICOTFWvRODfqGuKnS4YbOebo5j0IdIVFnDuItAiEcTuEZxatr0osvZLD/zrG0HGLcNZgsV+EA8+xdGQgwQOS7LQa3diloAfTu/RGS2V3ZKRSK/mLKhBYyhJfKWAuo59MxfYm9XETja/cuN/1eCb0bFs65md6NwT/wL9JSM9x5WBJufB67gPBLRa06+alN13rHaqm2hB5P0/yd4lCmJMQLTe0FgejqG+mwjQt2fQTMtmBF2AyBvrQu8d5pbuPGwP+OfzMD3hQhrbrZZj5M4ctxHUhB9s57CVzB6CDFllRM8ASy2JVJMoE1AEEAVdgp8Dq/dmnvA3988lEEdRA4l8Tm4taLByAwbmH/WHwVlWv/mmGGiQ6UETYBw5Vx1SmPLxMFffgVxLdHVYYDLY/t+0oEFSC+gipD3nhhEkSIIFyjVirVaWe+zzhQpqt662F9xHzAWN72ln5TkCSL3qKZ4/MOg9hCyL7V0r6knYzos= cloud@ubuntu1