2021-10-29 16:47:37 +00:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
#
|
|
|
|
|
2022-03-15 17:29:56 +00:00
|
|
|
ENV['TEST_INSTALL_SH'] ||= '../../../install.sh'
|
2021-10-29 16:47:37 +00:00
|
|
|
|
|
|
|
Vagrant.configure("2") do |config|
|
|
|
|
config.vagrant.plugins = {
|
2021-11-08 23:26:21 +00:00
|
|
|
'vagrant-k3s' => {:version => '~> 0.1.3'},
|
2021-10-29 16:47:37 +00:00
|
|
|
}
|
2022-10-26 15:38:18 +00:00
|
|
|
config.vm.box = 'opensuse/Leap-15.4.x86_64'
|
2021-11-15 18:50:38 +00:00
|
|
|
config.vm.boot_timeout = ENV['TEST_VM_BOOT_TIMEOUT'] || 600 # seconds
|
|
|
|
config.vm.synced_folder '.', '/vagrant', disabled: true
|
2021-10-29 16:47:37 +00:00
|
|
|
|
|
|
|
config.vm.define 'install-opensuse-leap', primary: true do |test|
|
2021-11-15 18:50:38 +00:00
|
|
|
test.vm.hostname = 'smoke'
|
2021-10-29 16:47:37 +00:00
|
|
|
test.vm.provision 'k3s-upload', type: 'file', run: 'always', source: ENV['TEST_INSTALL_SH'], destination: 'install.sh'
|
|
|
|
# /sbin/apparmor_parser is needed by the 1.21 kubelet if the value of /sys/module/apparmor/parameters/enabled is Y
|
|
|
|
test.vm.provision 'k3s-prepare', type: 'shell', run: 'once', inline: 'zypper install -y apparmor-parser'
|
|
|
|
test.vm.provision 'k3s-install', type: 'k3s', run: 'once' do |k3s|
|
|
|
|
k3s.installer_url = 'file:///home/vagrant/install.sh'
|
|
|
|
k3s.args = %w[server]
|
2021-11-15 18:50:38 +00:00
|
|
|
k3s.env = ENV.select{|k,v| k.start_with?('K3S_') || k.start_with?('INSTALL_K3S_')}.merge({
|
|
|
|
:INSTALL_K3S_NAME => 'server',
|
|
|
|
:INSTALL_K3S_SKIP_SELINUX_RPM => 'true',
|
|
|
|
})
|
2022-08-15 21:31:37 +00:00
|
|
|
k3s.config = <<~YAML
|
|
|
|
token: 'vagrant'
|
|
|
|
YAML
|
2021-10-29 16:47:37 +00:00
|
|
|
k3s.config_mode = '0644' # side-step https://github.com/k3s-io/k3s/issues/4321
|
|
|
|
end
|
2021-11-15 18:50:38 +00:00
|
|
|
test.vm.provision "k3s-wait-for-node", type: "shell", run: ENV['CI'] == 'true' ? 'never' : 'once' do |sh|
|
2021-10-29 16:47:37 +00:00
|
|
|
sh.env = { :PATH => "/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin" }
|
|
|
|
sh.inline = <<~SHELL
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -eu -o pipefail
|
|
|
|
echo 'Waiting for node to be ready ...'
|
2021-11-15 18:50:38 +00:00
|
|
|
time timeout 300 bash -c 'while ! (kubectl wait --for condition=ready node/$(hostnamectl --static) 2>/dev/null); do sleep 5; done'
|
2021-10-29 16:47:37 +00:00
|
|
|
kubectl get node,all -A -o wide
|
|
|
|
SHELL
|
|
|
|
end
|
2021-11-15 18:50:38 +00:00
|
|
|
test.vm.provision "k3s-wait-for-coredns", type: "shell", run: ENV['CI'] == 'true' ? 'never' : 'once' do |sh|
|
2021-10-29 16:47:37 +00:00
|
|
|
sh.env = { :PATH => "/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin" }
|
|
|
|
sh.inline = <<~SHELL
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -eu -o pipefail
|
2022-09-29 23:25:28 +00:00
|
|
|
function describe-coredns {
|
|
|
|
RC=$?
|
|
|
|
if [[ $RC -ne 0 ]]; then
|
|
|
|
kubectl describe node
|
|
|
|
kubectl --namespace kube-system describe pod -l k8s-app=kube-dns
|
|
|
|
kubectl --namespace kube-system logs -l k8s-app=kube-dns
|
|
|
|
fi
|
|
|
|
exit $RC
|
|
|
|
}
|
|
|
|
trap describe-coredns EXIT
|
2022-08-26 16:36:50 +00:00
|
|
|
timeout 300 bash -c 'while ! (kubectl --namespace kube-system rollout status --timeout 10s deploy/coredns); do sleep 5; done'
|
2021-10-29 16:47:37 +00:00
|
|
|
SHELL
|
|
|
|
end
|
2021-11-15 18:50:38 +00:00
|
|
|
test.vm.provision "k3s-wait-for-local-storage", type: "shell", run: ENV['CI'] == 'true' ? 'never' : 'once' do |sh|
|
2021-10-29 16:47:37 +00:00
|
|
|
sh.env = { :PATH => "/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin" }
|
|
|
|
sh.inline = <<~SHELL
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -eu -o pipefail
|
2021-11-15 18:50:38 +00:00
|
|
|
time timeout 300 bash -c 'while ! (kubectl --namespace kube-system rollout status --timeout 10s deploy/local-path-provisioner 2>/dev/null); do sleep 5; done'
|
2021-10-29 16:47:37 +00:00
|
|
|
SHELL
|
|
|
|
end
|
2021-11-15 18:50:38 +00:00
|
|
|
test.vm.provision "k3s-wait-for-metrics-server", type: "shell", run: ENV['CI'] == 'true' ? 'never' : 'once' do |sh|
|
2021-10-29 16:47:37 +00:00
|
|
|
sh.env = { :PATH => "/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin" }
|
|
|
|
sh.inline = <<~SHELL
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -eu -o pipefail
|
2021-11-15 18:50:38 +00:00
|
|
|
time timeout 300 bash -c 'while ! (kubectl --namespace kube-system rollout status --timeout 10s deploy/metrics-server 2>/dev/null); do sleep 5; done'
|
2021-10-29 16:47:37 +00:00
|
|
|
SHELL
|
|
|
|
end
|
2021-11-15 18:50:38 +00:00
|
|
|
test.vm.provision "k3s-wait-for-traefik", type: "shell", run: ENV['CI'] == 'true' ? 'never' : 'once' do |sh|
|
2021-10-29 16:47:37 +00:00
|
|
|
sh.env = { :PATH => "/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin" }
|
|
|
|
sh.inline = <<~SHELL
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -eu -o pipefail
|
2021-11-15 18:50:38 +00:00
|
|
|
time timeout 300 bash -c 'while ! (kubectl --namespace kube-system rollout status --timeout 10s deploy/traefik 2>/dev/null); do sleep 5; done'
|
2021-10-29 16:47:37 +00:00
|
|
|
SHELL
|
|
|
|
end
|
2021-11-15 18:50:38 +00:00
|
|
|
test.vm.provision "k3s-status", type: "shell", run: ENV['CI'] == 'true' ? 'never' : 'once' do |sh|
|
2021-10-29 16:47:37 +00:00
|
|
|
sh.env = { :PATH => "/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin" }
|
|
|
|
sh.inline = <<~SHELL
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -eux -o pipefail
|
|
|
|
kubectl get node,all -A -o wide
|
|
|
|
SHELL
|
|
|
|
end
|
2021-11-15 18:50:38 +00:00
|
|
|
test.vm.provision "k3s-procps", type: "shell", run: ENV['CI'] == 'true' ? 'never' : 'once' do |sh|
|
|
|
|
sh.env = { :PATH => "/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin" }
|
|
|
|
sh.inline = <<~SHELL
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -eux -o pipefail
|
|
|
|
ps auxZ | grep -E 'k3s|kube|container' | grep -v grep
|
|
|
|
SHELL
|
|
|
|
end
|
2021-10-29 16:47:37 +00:00
|
|
|
end
|
|
|
|
|
2021-11-15 18:50:38 +00:00
|
|
|
%w[libvirt virtualbox vmware_desktop].each do |p|
|
2021-10-29 16:47:37 +00:00
|
|
|
config.vm.provider p do |v|
|
|
|
|
v.cpus = ENV['TEST_VM_CPUS'] || 2
|
|
|
|
v.memory = ENV['TEST_VM_MEMORY'] || 2048
|
|
|
|
end
|
|
|
|
end
|
|
|
|
config.vm.provider :virtualbox do |v,o|
|
|
|
|
v.gui = false
|
|
|
|
v.check_guest_additions = false
|
|
|
|
end
|
|
|
|
end
|