Kubernetes Installation on Fedora 27 Cloud Base
Getting StartedI tried numerous ways to get a Kubernetes Master node to be installed on my bare-metal Fedora 25 distribution without success. With Kubernetes under such rapid development, it can be difficult to find a distribution platform which is able to keep up. Fedora 26 is represents a milestone in the development of Kubernetes, where instead of running the components of Kubernetes directly as services on the Master node, they have been containerized.
This post explains how to install a Kubernetes Master node using containers on a Linux host running Fedora 25. This host has libvirt installed already for storing the container metadata.
Managing Cloud Base ContainerThe container which will run the Kubernetes containers will be managed using Vagrant. Although the Vagrant documentation recommends installing directly from https://www.vagrantup.com/downloads.html, there is no package for the Fedora distribution there. If you are on a Windows, Mac, CentOS, or Debian platform, then you can install the vagrant software there. On Fedora, it was installed with:
dnf install vagrant
Obtaining the Fedora 27 Cloud Base container
Initializing the Vagrant Environment
To download the container image, first a "box" has to be added to vagrant. To create a download the image and create a Vagrantfile to customize how you deploy this image:
mkdir k8s-master; cd k8s-master
vagrant init fedora/27-cloud-base
You can customize many options for the container like memory, networking, shared directories, port forwarding, etc. If the above command was executed with the minimal option -m, comments would not have been provided. To get started, you need to allocate more than the 500 megabytes of memory that is normally provided. If you can afford the memory, allocate the 2,048 gigabytes by using the customization below.
Assuming you are using libvirt, add the following lines to the Vagrantfile after the "config.vm.box = fedora/27-cloud-base" line:
config.vm.hostname = "k8s-master"
config.vm.provider "libvirt" do |libvirt, override|
libvirt.memory = 2048
libvirt.nested = true
Starting and Accessing the Fedora 27 Cloud Base Container
Create the Kubernetes Repository Filecat > /etc/yum.repos.d/kubernetes.repo << HERE
Install the Packagesdnf install kubeadm.x86_64 kubectl.x86_64 kubelet.x86_64 kubernetes-cni.x86_64 bash-completion rsyslog docker -y
Configure the Kubelet service
Add to the /etc/systemd/system/kubelet.service.d/10-kubeadm.conf file $KUBELET_KUBECONFIG_ARGS:
systemctl enable kubelet
systemctl restart kubelet
Enable and Start the Services
systemctl enable docker --now
systemctl enable rsyslog --now
systemctl enable kubelet --now
Initialize the Kubernetes Clusterkubeadm init --pod-network-cidr 10.244.0.0/16
Prepare Home Directory
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
echo 'source <(kubectl completion bash)' >> .bashrc
Apply the Weave Network
kubectl apply -f https://git.io/weave-kube-1.6
Untaint the Master Node
kubectl taint nodes --all node-role.kubernetes.io/master-
If necessary the node can be re-tainted by executing:
kubectl taint nodes --all node-role.kubernetes.io/master=""
Get Cluster Information
Kubernetes master is running at https://192.168.121.9:6443
KubeDNS is running at https://192.168.121.9:6443/api/v1/namespaces/kube-system/services/kube-dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'