Skip to content

Installing K2s

Prerequisites

  • K2s folder being available locally, see Getting K2s
  • The Windows host must match one of the Supported OS Versions
  • Local admin permissions are currently needed in order to be able to create virtual switches, VMs, etc.
  • Please try to install from an folder which is available on C:\ drive, since most open-source components assume this. We are testing the solution also on other drives, but cannot guarantee that the cluster will work fully.
  • Hardware: The system should offer at least 4G RAM free, as well as 50GB disk space free. Recommended are at least 6 CPU cores, but less are possible.
  • CPU virtualization must be enabled in the BIOS. To verify, open the Task Manager and check the Virtualization property on the Performance tab:
    Check Virtualization
    If you run the setup inside a VM, enable nested virtualization (e.g. when using Hyper-V:
    PowerShell
    Set-VMProcessor -VMName $Name -ExposeVirtualizationExtensions $true
    
    , see Configure Nested Virtualization for details).
  • Docker (Desktop) must not be running. Either stop Docker and set it to start manually or uninstall it completely
  • PowerShell execution policy must be RemoteSigned or less restrictive. To set the policy, run:
    PowerShell
    Set-ExecutionPolicy RemoteSigned -Force
    
  • curl.exe: the installed version in the Windows host must be at least 7.71.0 (to check it call curl.exe --version from the command shell).
  • Optional: Enable required Windows Features beforehand (they will get enabled during the installation anyways, but would require a system restart and installation re-run):
  • Windows 10/11
    PowerShell
    Enable-WindowsOptionalFeature -Online -FeatureName $('Microsoft-Hyper-V-All', 'Microsoft-Hyper-V', 'Microsoft-Hyper-V-Tools-All', 'Microsoft-Hyper-V-Management-PowerShell', 'Microsoft-Hyper-V-Hypervisor', 'Microsoft-Hyper-V-Services', 'Microsoft-Hyper-V-Management-Clients', 'Containers', 'VirtualMachinePlatform') -All -NoRestart
    
  • Windows Server OSs
    PowerShell
    Enable-WindowsOptionalFeature -Online -FeatureName $('Microsoft-Hyper-V', 'Microsoft-Hyper-V-Management-PowerShell', 'Containers', 'VirtualMachinePlatform') -All -NoRestart
    

Tip

For installing in WSL mode, add the Microsoft-Windows-Subsystem-Linux feature to the prior command.

Installation via k2s CLI

The K2s setup provides a variety of installation options. Based on the Hosting Variants, select one of the following setup variants:

To inspect the different install options, run:

Bash Session
<repo>\k2s.exe install -h

Info

By default, the installation assumes 6 CPU cores to be available on the host system. If less cores are available, reduce the number of virtual cores used by K2s according to the actual amount, e.g. when 4 cores are available, assign max. 4 virtual cores to K2s:

Bash Session
<repo>\k2s.exe install --master-cpus 4

Tip

If you acquired K2s via Cloning the Git repository, you might want to checkout a specific version first, e.g.:

Bash Session
git checkout v1.1.0

Note

K2s will start automatically after the installation has finished.

Installing Using Config Files

Instead of assembling many command-line parameters/flags to customize the installation, you can also pass a YAML file to the k2s install command configuring install parameters like node resource definitions (e.g. CPU, RAM or size of the hard drive):

Bash Session
<repo>\k2s.exe install [-c|--config] <path-to-config-file>

Example

Create a custom install config:

my_config.yaml
kind: k2s
apiVersion: v1
nodes:
  - role: control-plane
    resources:
      cpu: 8
      memory: 7GB
      disk: 60GB
env:
  httpProxy: 192.168.178.100:8765
installBehavior:
  showOutput: true
Start the installation passing this config:
Bash Session
<repo>\k2s.exe install -c c:\temp\my_config.yaml

To create a user-defined configuration for any of the hosting variants, take one of the corresponding Base Configuration Files as a template.

Online vs. Offline

Downloading all dependencies (i.e. binaries) on-the-fly is referred to as online installation, whereas offline refers to an installation package containing parts of or all the dependencies. If K2s was acquired via Downloading the Official Release Package, parts of the dependencies are already available locally. If an offline package was create according to Creating Offline Package, all dependencies are available offline.

As per default, the k2s CLI keeps downloaded files as well as the Linux-based control-plane image and reuses them. To change this behavior, use the following CLI flags (they apply to all installation variants1).

To delete all downloaded binaries and the control-plane image after installation, run:

Bash Session
<repo>\k2s.exe install -d

To force the download of all binaries and the re-creation of the control-plane image regardless of their local presence, run:

Bash Session
<repo>\k2s.exe install -f

Offline vs. Online Installation Diagram
graph TD
    CallScript["Installation scripts\n (Default, MultiVM, BuildOnlySetup)\n\n with\n [-DeleteFilesForOfflineInstallation]\n [-ForceOnlineInstallation]"] --> if_force_online_installation{"Switch\n ForceOnlineInstallation\n used ?"}
    if_force_online_installation --> |yes| BuildAndProvisionKubemasterBaseImage
    if_force_online_installation --> |no| if_base_image_available{"c\k\bin\Kubemaster-Base.vhdx\n available?"}
    if_base_image_available --> |yes| CopyBaseImage
    if_base_image_available --> |no| BuildAndProvisionKubemasterBaseImage
    BuildAndProvisionKubemasterBaseImage("Build and provision base image") --> PublishBaseImage("Publish base image as\n c\k\bin\Kubemaster-Base.vhdx")
    PublishBaseImage --> CopyBaseImage("Copy published base image to\n C\Users\Public\Documents\Hyper-V\Virtual hard disks")
    CopyBaseImage --> InstallLinuxNode("Install Linux node")
    InstallLinuxNode --> if_delete_files_for_offline_installation{"Switch\n -DeleteFilesForOfflineInstallation\n used ?"}
    if_delete_files_for_offline_installation --> |yes| DeleteBaseImage("Delete file c\k\bin\Kubemaster-Base.vhdx")
    if_delete_files_for_offline_installation --> |no| End
    DeleteBaseImage --> End

[Option 1] Host (Default)

Simply run:

Bash Session
<repo>\k2s.exe install

WSL

To install the control-plane in WSL 2 instead of a dedicated Linux VM, run:

Bash Session
<repo>\k2s.exe install --wsl

[Option 2] Multi VM

To create a new Windows worker VM on-the-fly based on an existing Windows image, run:

Bash Session
<repo>\k2s.exe install multivm -i '<path-to-my-windows-image>.iso'

[Option 3] Development-Only

To build and test containers without a K8s cluster, run:

Bash Session
<repo>\k2s.exe install buildonly


  1. Creating of and installing from an offline package is currently supported for Host Variant and Development-Only only.