基础设施虚拟机¶
Kayobe 可以将基础设施虚拟机部署到 seed-hypervisor。这些虚拟机可用于提供补充服务,这些服务不适合在容器化环境中运行,或者控制平面的依赖项。
配置¶
要部署基础设施虚拟机,请在 inventory 中将新的主机添加到 infra-vms 组
$KAYOBE_CONFIG_PATH/inventory/infra-vms¶ [infra-vms]
an-example-vm
虚拟机的配置应使用 host_vars 进行。这些会覆盖为 infra-vms 组定义的 group_vars。大多数变量都有合理的默认值,但有一些变量必须设置。
必选变量¶
所有网络都必须定义一个接口,如 每主机网络配置 中所述。默认情况下,虚拟机连接到 admin overcloud 网络。例如,如果 admin_oc_net_name 设置为 example_net,则需要定义 example_net_interface。可以通过修改 infra_vm_network_interfaces 来更改虚拟机连接的网络列表。可以通过设置 infra_vm_network_interfaces_extra 添加额外的接口。
Kayobe 应用的必需 docker_container 变量的默认值列表。这些变量都可以通过 host_var 覆盖。
---
###############################################################################
# Infrastructure VM configuration.
# Name of the infra VM.
infra_vm_name: "{{ inventory_hostname }}"
# Memory in MB.
infra_vm_memory_mb: "{{ 16 * 1024 }}"
# Number of vCPUs.
infra_vm_vcpus: 4
# List of volumes.
infra_vm_volumes:
- "{{ infra_vm_root_volume }}"
- "{{ infra_vm_data_volume }}"
# Root volume.
infra_vm_root_volume:
name: "{{ infra_vm_name }}-root"
pool: "{{ infra_vm_pool }}"
capacity: "{{ infra_vm_root_capacity }}"
format: "{{ infra_vm_root_format }}"
image: "{{ infra_vm_root_image }}"
# Data volume.
infra_vm_data_volume:
name: "{{ infra_vm_name }}-data"
pool: "{{ infra_vm_pool }}"
capacity: "{{ infra_vm_data_capacity }}"
format: "{{ infra_vm_data_format }}"
# Name of the storage pool for the infra VM volumes.
infra_vm_pool: default
# Capacity of the infra VM root volume.
infra_vm_root_capacity: 50G
# Format of the infra VM root volume.
infra_vm_root_format: qcow2
# Base image for the infra VM root volume. Default is
# "https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
# when os_distribution is "ubuntu",
# "https://dl.rockylinux.org/pub/2025.2/10/images/x86_64/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2"
# when os_distribution is "rocky", or
# "https://cloud.centos.org/centos/10-stream/x86_64/images/CentOS-Stream-GenericCloud-x86_64-10-latest.x86_64.qcow2"
# otherwise.
infra_vm_root_image: >-
{%- if os_distribution == 'ubuntu' %}
https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img
{%- elif os_distribution == 'rocky' %}
https://dl.rockylinux.org/pub/2025.2/10/images/x86_64/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2
{%- else -%}
https://cloud.centos.org/centos/10-stream/x86_64/images/CentOS-Stream-GenericCloud-x86_64-10-latest.x86_64.qcow2
{%- endif %}
# Capacity of the infra VM data volume.
infra_vm_data_capacity: 100G
# Format of the infra VM data volume.
infra_vm_data_format: qcow2
# List of network interfaces to attach to the infra VM.
infra_vm_interfaces: "{{ network_interfaces | sort | map('net_libvirt_vm_network') | list }}"
# Hypervisor that the VM runs on.
infra_vm_hypervisor: "{{ groups['seed-hypervisor'] | first }}"
# Customise ansible_ssh_extra_args for the test that checks SSH connectivity
# after provisioning. Defaults to disabling ssh host key checking.
infra_vm_wait_connection_ssh_extra_args: '-o StrictHostKeyChecking=no'
# OS family. Needed for config drive generation.
infra_vm_os_family: "{{ 'RedHat' if os_distribution in ['centos', 'rocky'] else 'Debian' }}"
# Boot firmware. Possible values are 'bios' or 'efi'. Default is 'efi'.
infra_vm_boot_firmware: "efi"
# Machine type. Libvirt default configuration is used.
infra_vm_machine:
###############################################################################
# Infrastructure VM node configuration.
# User with which to access the infrastructure vm via SSH during bootstrap, in
# order to setup the Kayobe user account. Default is 'cloud-user' if
# os_distribution is set to centos, otherwise 'os_distribution'.
infra_vm_bootstrap_user: "{{ 'cloud-user' if os_distribution == 'centos' else os_distribution }}"
###############################################################################
# Infrastructure VM network interface configuration.
# List of networks to which infrastructure vm nodes are attached.
infra_vm_network_interfaces: >
{{ (infra_vm_default_network_interfaces +
infra_vm_extra_network_interfaces) | select | unique | list }}
# List of default networks to which infrastructure vm nodes are attached.
infra_vm_default_network_interfaces: >
{{ [admin_oc_net_name] | select | unique | list }}
# List of extra networks to which infrastructure vm nodes are attached.
infra_vm_extra_network_interfaces: []
###############################################################################
# Infrastructure VM node software RAID configuration.
# List of software RAID arrays. See mrlesmithjr.mdadm role for format.
infra_vm_mdadm_arrays: []
###############################################################################
# Infrastructure VM node encryption configuration.
# List of block devices to encrypt. See stackhpc.luks role for format.
infra_vm_luks_devices: []
###############################################################################
# Infrastructure VM node LVM configuration.
# List of infrastructure vm volume groups. See mrlesmithjr.manage_lvm role for
# format.
infra_vm_lvm_groups: "{{ infra_vm_lvm_groups_default + infra_vm_lvm_groups_extra }}"
# Default list of infrastructure vm volume groups. See mrlesmithjr.manage_lvm
# role for format.
infra_vm_lvm_groups_default: "{{ [infra_vm_lvm_group_data] if infra_vm_lvm_group_data_enabled | bool else [] }}"
# Additional list of infrastructure vm volume groups. See mrlesmithjr.manage_lvm
# role for format.
infra_vm_lvm_groups_extra: []
# Whether a 'data' LVM volume group should exist on the infrastructure vm. By
# default this contains a 'docker-volumes' logical volume for Docker volume
# storage. Default is false.
infra_vm_lvm_group_data_enabled: false
# Infrastructure VM LVM volume group for data. See mrlesmithjr.manage_lvm role
# for format.
infra_vm_lvm_group_data:
vgname: data
disks: "{{ infra_vm_lvm_group_data_disks }}"
create: True
lvnames: "{{ infra_vm_lvm_group_data_lvs }}"
# List of disks for use by infrastructure vm LVM data volume group. Default to
# an invalid value to require configuration.
infra_vm_lvm_group_data_disks:
- changeme
# List of LVM logical volumes for the data volume group when using docker.
infra_vm_lvm_group_data_docker_lvs:
- "{{ infra_vm_lvm_group_data_lv_docker_volumes }}"
# List of LVM logical volumes for the data volume group when using podman.
infra_vm_lvm_group_data_podman_lvs:
- "{{ infra_vm_lvm_group_data_lv_podman_volumes }}"
# List of LVM logical volumes for the data volume group.
infra_vm_lvm_group_data_lvs: "{{ infra_vm_lvm_group_data_podman_lvs if container_engine == 'podman' else infra_vm_lvm_group_data_docker_lvs }}"
# Docker volumes LVM backing volume.
infra_vm_lvm_group_data_lv_docker_volumes:
lvname: docker-volumes
size: "{{ infra_vm_lvm_group_data_lv_docker_volumes_size }}"
create: True
filesystem: "{{ infra_vm_lvm_group_data_lv_docker_volumes_fs }}"
mount: True
mntp: "{{ docker_volumes_path }}"
infra_vm_lvm_group_data_lv_podman_volumes:
lvname: podman-volumes
size: "{{ infra_vm_lvm_group_data_lv_podman_volumes_size }}"
create: True
filesystem: "{{ infra_vm_lvm_group_data_lv_podman_volumes_fs }}"
mount: True
mntp: "{{ podman_volumes_path }}"
# Size of docker volumes LVM backing volume.
infra_vm_lvm_group_data_lv_docker_volumes_size: 75%VG
# Filesystem for docker volumes LVM backing volume. ext4 allows for shrinking.
infra_vm_lvm_group_data_lv_docker_volumes_fs: ext4
# Size of podman volumes LVM backing volume.
infra_vm_lvm_group_data_lv_podman_volumes_size: 75%VG
# Filesystem for podman volumes LVM backing volume. ext4 allows for shrinking.
infra_vm_lvm_group_data_lv_podman_volumes_fs: ext4
###############################################################################
# Infrastructure VM node sysctl configuration.
# Dict of sysctl parameters to set.
infra_vm_sysctl_parameters: {}
###############################################################################
# Infrastructure VM node tuned configuration.
# Builtin tuned profile to use. Format is same as that used by giovtorres.tuned
# role. Default is virtual-guest.
infra_vm_tuned_active_builtin_profile: "virtual-guest"
###############################################################################
# Infrastructure VM node user configuration.
# List of users to create. This should be in a format accepted by the
# singleplatform-eng.users role.
infra_vm_users: "{{ users_default }}"
###############################################################################
# Infrastructure VM node firewalld configuration.
# Whether to install and enable firewalld.
infra_vm_firewalld_enabled: false
# A list of zones to create. Each item is a dict containing a 'zone' item.
infra_vm_firewalld_zones: []
# A firewalld zone to set as the default. Default is unset, in which case the
# default zone will not be changed.
infra_vm_firewalld_default_zone:
# A list of firewall rules to apply. Each item is a dict containing arguments
# to pass to the firewalld module. Arguments are omitted if not provided, with
# the following exceptions:
# - offline: true
# - permanent: true
# - state: enabled
infra_vm_firewalld_rules: []
###############################################################################
# Infrastructure VM node swap configuration.
# List of swap devices. Each item is a dict containing a 'device' item.
infra_vm_swap: []
定制¶
以下显示了一些常见的定制示例。
默认情况下,Ansible inventory 名称用作虚拟机的名称。这可以通过 infra_vm_name 覆盖
$KAYOBE_CONFIG_PATH/inventory/host_vars/an-example-vm¶ # Name of the infra VM.
infra_vm_name: "the-special-one"
默认情况下,虚拟机具有 16G 内存。这可以通过 infra_vm_memory_mb 更改
$KAYOBE_CONFIG_PATH/inventory/host_vars/an-example-vm¶ # Memory in MB. Defaults to 16GB.
infra_vm_memory_mb: "{{ 8 * 1024 }}"
默认网络配置将基础设施虚拟机连接到 admin 网络。如果这不合适,请修改 infra_vm_network_interfaces。至少应定义网络的网络接口名称。
$KAYOBE_CONFIG_PATH/inventory/host_vars/an-example-vm¶ # Network interfaces that the VM is attached to.
infra_vm_network_interfaces:
- aio
# Mandatory: All networks must have an interface defined.
aio_interface: eth0
# By default kayobe will connect to a host via ``admin_oc_net``.
# As we have not attached this VM to this network, we must override
# ansible_host.
ansible_host: "{{ 'aio' | net_ip }}"
可以使用在 $KAYOBE_CONFIG_PATH/infra-vms.yml 中定义的 extra_vars 来设置所有虚拟机的配置。请注意,正常的 Ansible 优先级规则适用,并且变量将覆盖任何 host_vars。如果您需要覆盖默认值,但仍保留每主机设置,请使用 group_vars 代替。
部署虚拟机¶
完成初始配置后,请按照 基础设施虚拟机 中的步骤操作。