第9章 Provisioning Virtual Machines on KVM (libvirt)

Kernel-based Virtual Machines (KVMs) use an open source virtualization daemon and API called libvirt running on Red Hat Enterprise Linux. Red Hat Satellite can connect to the libvirt API on a KVM server, provision hosts on the hypervisor, and control certain virtualization functions.

You can use KVM provisioning to create hosts over a network connection or from an existing image.

Prerequisites

  • Synchronized content repositories for Red Hat Enterprise Linux. For more information, see Synchronizing Red Hat Repositories in the Content Management Guide.
  • An activation key for host registration. For more information, see Creating An Activation Key in the Content Management guide.
  • A Capsule Server managing a network on the KVM server. Ensure no other DHCP services run on this network to avoid conflicts with the Capsule Server. For more information about network service configuration for Capsule Servers, see 3章Configuring Networking.
  • A Red Hat Enterprise Linux server running KVM virtualization tools (libvirt daemon). For more information, see the Red Hat Enterprise Linux 7 Virtualization Getting Started Guide.
  • An existing virtual machine image if you want to use image-based provisioning. Ensure that this image exists in a storage pool on the KVM host. The default storage pool is usually located in /var/lib/libvirt/images. Only directory pool storage types can be managed through Satellite.
  • Optional: The examples in these procedures use the root user for KVM. If you want to use a non-root user on the KVM server, you must add the user to the libvirt group on the KVM server:

    useradd -a -G libvirt non_root_user
  • A Satellite user account with the following roles:

  • A custom role in Satellite with the following permissions:

    • view_compute_resources
    • destroy_compute_resources_vms
    • power_compute_resources_vms
    • create_compute_resources_vms
    • view_compute_resources_vms
    • view_locations
    • view_subnets

      For more information about creating roles, see Creating a Role in the Administering Red Hat Satellite guide. For more information about adding permissions to a role, see Adding Permissions to a Role in the Administering Red Hat Satellite guide.

9.1. Configuring Satellite Server for KVM Connections

Before adding the KVM connection, create an SSH key pair for the foreman user to ensure a secure connection between Satellite Server and KVM.

Procedure

  1. On Satellite Server, switch to the foreman user:

    # su foreman -s /bin/bash
  2. Generate the key pair:

    $ ssh-keygen
  3. Copy the public key to the KVM server:

    $ ssh-copy-id root@kvm.example.com
  4. Exit the bash shell for the foreman user:

    $ exit
  5. Install the libvirt-client package:

    # satellite-maintain packages install libvirt-client
  6. Use the following command to test the connection to the KVM server:

    # su foreman -s /bin/bash -c 'virsh -c qemu+ssh://root@kvm.example.com/system list'