More

Preparing the Provider Template

Requirements for templates and step-by-step preparation process.

Virtual machine templates for all providers (VMware vSphere, oVirt, OpenStack, Basis Dynamix, vCloud Director, Yandex Cloud) are prepared in one way. The process does not depend on the type of provider: you create a VM, prepare it with the stc utility, convert it to a template and load it into the provider instance.

When creating a VM from a template, the Shturval platform independently installs Kubernetes of the selected version and the necessary configurations.

How this relates to deploying the entire cluster (Cluster API, steps before registering nodes), see Creating nodes when deploying a client cluster.


What the template contains

The template stores:

  • Operating system and its version. This is usually a system from the list of supported operating systems. You can also prepare a template on another Linux operating system: stc template reports in its output that this system is not in the supported list and continues. See Operating systems outside the tested list.
  • Disk size limitation - created VMs cannot be smaller than the disk capacity of the original VM.

The template does not store information about the resources (CPU, RAM) of the source VM.


Requirements for the VM before creating the template

On the virtual machine from which the template is generated:

RequirementDescription
Time SynchronizationNTP on all nodes. Time discrepancies can cause crashes
Mirror ResolveThe host with the mirror (registry) must resolve using the current FQDN
SELinuxDisabled or permissive
RepositoriesInaccessible repositories disabled or removed (distribution native repositories)
Packagesiptables and gnupg set
Network and DHCPOn Debian/Ubuntu (where /etc/network/interfaces is used), configure the eth0 interface to obtain an IP address via DHCP. Do not set a static IP in the image; when creating the base VM, connect it to a network with working DHCP. If DHCP is configured for a previous interface name (not eth0), nodes will not receive IP addresses. On Debian 12 (bookworm), after stc template, correct the interface name manually — before powering off the VM
VM ResourcesAt least 4 vCPU and 8 GB RAM. If stc fails to prepare the template with a node check failure due to insufficient resources, add VM resources and rerun the command
User namespaces for rootless PodmanEnabled kernel.unprivileged_userns_clone permission to create unprivileged user namespaces. Execute sysctl kernel.unprivileged_userns_clone. If the value is 0, set 1 (enable the option) to /etc/sysctl.conf and execute sysctl -p. If the command returns the error cannot stat /proc/sys/kernel/unprivileged_userns_clone: No such file or directory, the parameter may not be configured

When using a mirror, specify the registry name in the same way as when deploying the platform.

ProviderDescription
VK CloudWhen creating images, set the access type to public public, private images - private will not be available for selecting a VM template in the provider instance. How to change the access type of the created image, see page.
oVirt, zVirt, HostVM, RED Virtualization, ROSA VirtualizationThe VM template must have a disk with the Bootable flag enabled. Check and enable the flag in the disk properties so that the VM can use this disk to run the operating system.

Disk allocation

Recommended: use LVM and store data in the root partition. As the VM disk grows, the root partition will expand. Minimum disk size is 60 GB.

To correctly expand the disk, follow the requirements for the selected partitioning scheme. When LVM is used, the PV that is part of a volume group must be the active and last partition in the partition table.

The top-level use of partitions other than the root one in the minimal configuration is as follows:

SectionDirectoriesPurposeVolume
/var//var/csi/rawfile/Local storage, custom PVs5 GB + PV
/var/logLogs20 GB
/var/lib/kubelet/Kubelet (emptydir)10 GB
/var/lib/containerd/Container Images10 GB
/home—Home directories500 MB
/boot—Boot section1 GB
/—Root partition20 GB

If necessary, allocate /var/log - allocate 20 GB.

If LVM is not used

The root partition / must be the active and last partition in the partition table. If other partitions are located behind the root partition, disk expansion will not work.


Step-by-step process for creating a template

Step 1: Create a VM in the virtualization platform

Create a virtual machine in oVirt, VMware vSphere, OpenStack, or another environment. Connect the VM to a network with working DHCP — cluster nodes obtain IP addresses via DHCP. Install an operating system. If the OS is not in the list of supported operating systems, you can still prepare the template, see Operating systems outside the tested list. Configure the disk according to recommendations above, fulfill VM requirements.

Step 2: Preparing the template with the stc utility

The stc utility runs on a working machine (not on the cluster host) running Linux OS. When using a mirror, specify the registry name in the same way as when deploying the platform.

  1. Download stc https://public.shturval.tech/stc-2.15.0 and make it executable:
chmod +x ./stc-2.15.0
  1. Start preparing the template on the VM (specify additionally the registry parameter if you are using a mirror instead of r.shturval.tech):
./stc-2.15.0 template --license="YOUR-LICENSE"

If during template preparation it is reported thatA node reboot is required to enable cgroup v2, wait until it finishes. Then run the stc template command again with the same parameters. The template will be ready only after the command has been successfully executed again without requiring a command restart.

On any Ubuntu version, template preparation may stop with this error starting shturvald:

Error: не удалось подготовить узел: ошибка запуска shturvald. 1 error occurred:
        * ошибка выполнения команды /bin/sh -c sudo std node status: exit status 1

In this case, run the stc template command again with the same parameters.

Stc template command parameters:

ParameterRequiredDescriptionDefault
--licenseYesLicense key for downloading packages-
--registryNoRegistry address (by default r.shturval.tech). Must match registry when installing the platform-
--platform-versionNoShturval platform version. Version compliance - in documentation-
--keep-cloud-initNoLeave cloud-init (required for Yandex Cloud)false
--fix-vmware-networkNoFixing network on VMs for VMware vSphere, VMware vCloud Director providers. Without a fix on vmxnet3, the checksum of tunnel traffic does not work correctly, which leads to problems with the Kubernetes overlay network. On non-VMware provider VMs, the patch is skippedtrue
--dhcp-no-domain-nameNoDisable the ability of DHCP to accept the domain-name parameter (configurable in netplan or dhclient). Can be used when a VM is on a corporate network with DHCP that distributes an organization’s domain, and the cluster nodes must resolve without a suffix.false

Examples of stc commands

Open loop:

./stc-2.15.0 template --license="YOUR-LICENSE"

Closed loop (mirror):

./stc-2.15.0 template --license="YOUR-LICENSE" --registry="YOUR-REGISTRY-ADDRESS"

Yandex Cloud (with cloud-init):

./stc-2.15.0 template --license="YOUR-LICENSE" --keep-cloud-init

oVirt (with dhcp-no-domain-name):

./stc-2.15.0 template --license="YOUR-LICENSE" --dhcp-no-domain-name

Operating systems outside the tested list

If necessary, you can prepare a VM template with an operating system outside the tested list. In this case, successful cluster deployment and the correctness of the template configuration are not guaranteed.

After you start stc template, the node configuration check covers the OS name, the release, the architecture, and the kernel version. If they are not in the supported list, the output shows a message with the text ошибка проверки операционной системы and additional information.

Continuing preparation after this message, the command installs the shturvald package and writes the kernel parameters. On an operating system from the supported list, the package installation method is already known. On an operating system outside the tested list, the command chooses a deb, rpm, or ALT build by checking which programs the virtual machine uses to install packages. The command chooses the deb build only when both dpkg and apt-get are present. It chooses the rpm or ALT build only when rpm is present.

Template preparation will stop if the machine has fewer than 4 vCPU or 8 GB of memory, Kubernetes is already running, or the ports the cluster needs are in use. The command also stops if the virtual machine has no programs that install packages.

If the shturvald package does not install on an operating system outside the tested list, links to the deb, rpm, and ALT builds are added to the error text. Choose the build that matches your operating system, install this package manually, and run stc template again with the same parameters.

Before powering off the VM

  1. Debian bookworm only. Skip this step on other operating systems.

After a successful stc template, do not power off the VM yet. On Debian 12 the utility does not configure the network, the AppArmor service, or the time zone. Set them manually.

Network. If the VM has /etc/network/interfaces and the file names enp1s0, replace every occurrence in this file with eth0. Otherwise the network may fail to come up after cloning. If the file is not present, skip this item.

AppArmor. Disable the service so that it no longer starts. If the system has the aa-teardown command, run it: it unloads AppArmor profiles that are already loaded.

Time zone. Set Europe/Moscow both in /etc/timezone and with timedatectl.

if [ -f /etc/network/interfaces ]; then
  sudo sed -i 's/enp1s0/eth0/g' /etc/network/interfaces
fi
sudo systemctl disable apparmor --now || true
sudo aa-teardown || true
echo Europe/Moscow | sudo tee /etc/timezone
sudo timedatectl set-timezone Europe/Moscow
  1. Shut down the VM in the virtualization platform. After entering the “off” state, convert the VM into a template using the provider’s tools.

Step 3: Uploading the template to the Shturval platform

Add the created template to the provider instance:

  • VMware vSphere
  • oVirt (zVirt, HostVM, ED Virtualization, ROSA Virtualization)
  • OpenStack
  • Basis Dynamix
  • VMware vCloud Director
  • Yandex Cloud

You can add multiple templates to one provider instance, including templates with the same Kubernetes version. Each template specifies one version of Kubernetes. The mapping of template name and Kubernetes version is stored on the instance InfrastructureProvider, in spec.templates. The Kubernetes version in the template determines the available platform versions when creating client clusters. Before selecting the Kubernetes version, please read correspondence between Shturval and Kubernetes versions.

If the instance has several templates for one Kubernetes version, the Basic data step of creating a client cluster shows the required VM template field. The selected template is applied to all nodes.

During an upgrade, if the instance has several VM templates with the same Kubernetes version, the first one in alphabetical order is selected and applied to all node groups. To make sure the intended template is used on upgrade, add one template of the next version. If there are several templates, the first one in alphabetical order is selected.

On the provider instance page in the Virtual machine templates block, click + to add a template. In the side window, select name (as in virtualization) and Kubernetes version. The corresponding Shturval platform version will be filled in automatically and will be available for viewing only.


InfraMachineTemplate

VM templates are the basis for InfraMachineTemplates, from which nodes in groups are created. Based on one VM template, you can configure several InfraMachineTemplates with different parameters (CPU, RAM, etc.).

For a general description of the steps involved in the emergence of nodes from a template when creating a client cluster, see also help on nodes during deployment.