Skip to content

Instantly share code, notes, and snippets.

@darktempla
Last active December 23, 2023 21:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darktempla/439d04a5da67748e99ca7c4fd9e87994 to your computer and use it in GitHub Desktop.
Save darktempla/439d04a5da67748e99ca7c4fd9e87994 to your computer and use it in GitHub Desktop.
Example of running k0s using vagrant and the k0sctl binary to install on the 2 nodes.
#
# NOTES:
# - by default k0sctl will detect the network interface to use (usually eth0) for this configuration this will not work.
# - override the default network interface so nodes can talk over public ip range
#
apiVersion: k0sctl.k0sproject.io/v1beta1
kind: Cluster
metadata:
name: k0s-cluster
spec:
hosts:
- ssh:
address: 192.100.0.41
user: vagrant
port: 22
keyPath: ./.vagrant/machines/k0s1/virtualbox/private_key
role: controller
privateInterface: eth1 # override the default network interface
- ssh:
address: 192.100.0.42
user: vagrant
port: 22
keyPath: ./.vagrant/machines/k0s2/virtualbox/private_key
role: worker
privateInterface: eth1 # override the default network interface
k0s:
version: 1.21.3+k0s.0
# Defines our Vagrant environment
#
# -*- mode: ruby -*-
# vi: set ft=ruby :
nodeCount = 2
image = "debian/buster64"
ipRangeStart = 40
Vagrant.configure("2") do |config|
# nodes
if nodeCount > 0
(1..nodeCount).each do |i|
config.vm.define "k0s#{i}" do |config|
config.vm.hostname = "k0s#{i}"
config.vm.box_check_update = false
config.vm.box = image
config.vm.network "public_network", ip: "192.100.0.#{ipRangeStart + i}", :bridge => 'en0: Wi-Fi 2 (AirPort)'
config.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment