These instructions assume running Vagrant with a libvirt provider.
Install the vagrant-libvirt plugin using the following:
vagrant plugin install vagrant-libvirt
cat <<EOF > Vagrantfile
Vagrant.configure("2") do |config|
config.vm.define "master" do |master|
master.vm.box = "fedora/29-cloud-base"
master.vm.provider "libvirt" do |p|
p.cpus = 2
p.memory = 2048
end
end
config.vm.define "worker1" do |worker1|
worker1.vm.box = "fedora/29-cloud-base"
worker1.vm.provider "libvirt" do |p|
p.cpus = 2
p.memory = 4096
end
end
end
EOF
vagrant ssh master
# The rest should be done inside the master node
# Configure repository
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kube*
EOF
# Disable SELinux
sudo setenforce 0
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
# Install kubelet, kubeadm and kubectl
sudo dnf install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
# Start kubelet
sudo systemctl enable kubelet && sudo systemctl start kubelet
# Install Docker
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager \
--add-repo \
https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf install -y docker-ce
# Start Docker
sudo systemctl enable docker && sudo systemctl start docker
# Add $USER to docker group
sudo usermod -aG docker $USER
logout
NOTE: The
kubelet
service will not start at this stage. This is expected as the kubelet config file hasn't been generated yet bykubeadm
.
vagrant ssh master
# The rest should be done inside the master node
# '--pod-network-cidr' is for Calico
sudo kubeadm init --pod-network-cidr=192.168.0.0/16
# Verify k8s is running (master will not be ready until cluster networking is set up)
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl get nodes