3 Setting Up the libvirt Provider

Set up an Oracle Linux host to create Kubernetes clusters using the libvirt provider.

Clusters can be created on the localhost, or on a remote system. Perform these steps on the system to be used to create the cluster, whether that's the localhost for local clusters, or on a remote host if you're creating clusters on a remote system.

By default, KVM is built into the Oracle Linux kernel. You can use the default KVM stack, which includes libvirt. We recommend you use the Oracle KVM stack which is available in Oracle Linux 8 or 9 with the Unbreakable Enterprise Kernel (UEK). For Oracle Linux 9, the latest UEK Release 7 (UEK R7) must be installed. For Oracle Linux 8, UEK R6 or UEK R7 must be installed.

Important:

Existing Virtual Machines created with one KVM stack might not be compatible, and might not start, after switching to another KVM stack.

For more information on installing and configuring KVM, see the Oracle Linux: KVM User's Guide.

  1. (Optional) Install the Oracle KVM stack.
    • Oracle Linux 9:

      If you have an existing installation of the default KVM stack, remove it:

      sudo dnf remove -y libvirt qemu-kvm edk2 

      Install the Oracle KVM stack:

      sudo dnf config-manager --enable ol9_kvm_utils
      sudo dnf group install -y "Virtualization Host"
      sudo dnf install -y virt-install virt-viewer

      Start the virtualization daemons.

      for drv in qemu network nodedev nwfilter secret storage interface proxy   
        do
         sudo systemctl enable virt${drv}d.service
         sudo systemctl enable virt${drv}d{,-ro,-admin}.socket
         sudo systemctl start virt${drv}d{,-ro,-admin}.socket 
        done
    • Oracle Linux 8:

      If you have an existing installation of the default KVM stack, remove it:

      sudo dnf module remove -y virt --all
      sudo dnf module reset virt 

      Install the Oracle KVM stack:

      sudo dnf config-manager --enable ol8_kvm_appstream
      sudo dnf module enable virt:kvm_utils3 
      sudo dnf module install -y virt:kvm_utils3 

      Enable and start the libvirtd.service:

      sudo systemctl enable --now libvirtd.service
  2. Validate the host.

    Validate the host is set up for hardware virtualization, and can be used as a KVM host:

    virt-host-validate qemu
  3. Configure the user.

    Configure the user to have privileged access to libvirt, add the user to the libvirt and qemu groups.

    sudo usermod -a -G libvirt,qemu $USER

    To enable the change to the user, log out, and log back into the host or terminal session.

  4. (Optional) Open a range of ports in the firewall.

    If you're installing libvirt on a remote host, open a series of firewall ports so you can access nodes in the cluster from the localhost. You don't need to do this if you're installing libvirt on the localhost. Use the format:

    sudo firewall-cmd --add-port 6443-endrange/tcp
    sudo firewall-cmd --add-port 6443-endrange/tcp --permanent

    Replace endrange with the highest port number you want to open. For example, to open 20 ports, use:

    sudo firewall-cmd --add-port 6443-6463/tcp
    sudo firewall-cmd --add-port 6443-6463/tcp --permanent

    Restart firewalld.service

    sudo systemctl restart firewalld.service