K3s on a Centos vm

This post is about installing lightweight Kubernetes (K3s) on our new vm.


The previous post was all about being able to install Kubernetes quickly. For that I will use k3s from Rancher because it is fast. Let's go!


We do this for testing so we can safely disable the firewall and SELinux on our CentOS vm. This is because SELinux is still experimental in K3s. We also need to enable ssh password authentication so we can issue scp commands from our host machine. For this we just add the following lines to the extra script part of our Vagrantfile:

$extra = <<-EXTRA
dnf update -y && dnf install vim net-tools git lsof tar -y
sed -i 's/enforcing/disabled/g' /etc/selinux/config
sed -i 's/PasswordAuthentication\s.*no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
systemctl disable firewalld
systemctl restart sshd

Vagrant.configure("2") do |config|
  config.vm.define "node01" do |node01_config|
    node01_config.vm.box ="generic/centos8"
    node01_config.vm.hostname = "centos01"
    node01_config.vm.provider :libvirt do |domain|
      domain.memory = 4096
      domain.cpus = 2
      domain.nested = true
      domain.volume_cache = 'none'
  config.vm.provision "shell", inline: $extra

Now log on the the virtual machine and issue these commands:

curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config

Now wait a bit. Once ready, you can issue:

kubectl get pods --all-namespaces

Manage K3s from the host

 scp vagrant@ .

Edit the config and change the address from the server to the ip address of your vm. (Mine is

Then run:

kubectl get pods --kubeconfig config --all-namespaces