Hardware Requirements MASTER/NODE
egrep --color 'vmx|svm' /proc/cpuinfo
Must have VMX or SVM processor flag that enables virtualisation.
vmstat -s | grep total
280000 K – must be more than
cat /proc/cpuinfo | grep cores | wc -l
must be 2+
If you are using VM for this task, it might not work due to a nested virtualisation limitation or poor performance. You can try on windows 10 with Hyper-V with Intel Processor(AMD does not work in windows10). Virtual-box offers nested virtualisation functionality on Linux with AMD processor. Recommended is to have a separate machine for Kubernetes.
Master/Node pre-installation
If you can, it is good to set up DNS connecting IP’s ait domain names.
setenforce 0
sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
echo "br_netfilter" >> /etc/modules-load.d/br_netfilter.conf
modprobe br_netfilter
echo "net.bridge.bridge-nf-call-ip6tables = 1">> /etc/sysctl.d/01-custom.conf
echo "net.bridge.bridge-nf-call-iptables = 1">> /etc/sysctl.d/01-custom.conf
echo "net.bridge.bridge-nf-call-arptables = 1" >> /etc/sysctl.d/01-custom.conf
sysctl -p /etc/sysctl.d/01-custom.conf
yum -y update && yum -y upgrade
cat <<EOF > /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
EOF
yum install kubeadm docker kubelet kubectl kubernetes-cni -y
swapoff -a
sudo sed -i.bak '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
systemctl restart docker && systemctl enable docker
systemctl restart kubelet && systemctl enable kubelet
If the firewall is set up (default not; install if needed; reboot):
yum install -y firewalld
systemctl restart firewalld && systemctl enable firewalld
firewall-cmd --permanent --add-port=6443/tcp
firewall-cmd --permanent --add-port=2379-2380/tcp
firewall-cmd --permanent --add-port=10250/tcp
firewall-cmd --permanent --add-port=10251/tcp
firewall-cmd --permanent --add-port=10252/tcp
firewall-cmd --permanent --add-port=10255/tcp
firewall-cmd --reload
Master: Initialize the Kubernetes Cluster:
kubeadm init --pod-network-cidr 192.168.0.0/16 --service-cidr 10.96.0.0/12 --service-dns-domain "k8s" --apiserver-advertise-address $(ifconfig $(route | grep '^default' | grep -o '[^ ]*$') | grep 'inet '| awk '{print $2}')
Save a join command for later from the output of init command.
As a normal user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
export KUBECONFIG=$HOME/.kube/config
export KUBECONFIG=$HOME/.kube/config | tee -a ~/.bashrc
You should install at least one network provider on master :
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
Read a full list of network providers from the resource section.
Master: Setup the Kubernetes Config:
As a normal user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
export KUBECONFIG=$HOME/.kube/config
export KUBECONFIG=$HOME/.kube/config | tee -a ~/.bashrc
Nodes: Setup and connect:
Make the same preparations as in Master/Node pre-installation
on each node to be connected. To connect a node to a master make commands as root on nodes:
kubeadm join 192.192.192.192:6443 --token ma53bs.fp0uwi2gc9p9efki \
--discovery-token-ca-cert-hash sha256:e756d6706e02f45dc1fa5d6254989d86612ed67aa0f6cd2fc2a2fe5462106vfc
Master: Deploy a POD Network to the Cluster:
As a normal user, deploy a [pod network]:
kubectl apply -f http://docs.projectcalico.org/v2.3/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml
Master: Install MINIKUBE:
cat <<EOF > /etc/yum.repos.d/virtualbox.repo
[virtualbox]
name=Oracle Linux / RHEL / CentOS-7 / x86_64 - VirtualBox
baseurl=https://download.virtualbox.org/virtualbox/rpm/rhel/7/x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc
EOF
yum update -y
yum install VirtualBox-6.0
virtualbox --version
If you got messages about not installed module, you need to build a driver by doing :
yum install binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms
reboot
/usr/lib/virtualbox/vboxdrv.sh setup
virtualbox --version
Then install minicube with commands below:
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
&& chmod +x minikube
install minikube /usr/local/bin
minikube start
Resources:
- https://github.com/kubernetes/kubernetes/tree/master/examples
- https://kubernetes.io/docs/concepts/cluster-administration/addons/
- http://blog.pichuang.com.tw/Installing-Kubernetes-on-Linux-with-kubeadm/
- https://blog.alexellis.io/kubernetes-in-10-minutes/
- http://alesnosek.com/blog/2017/02/14/accessing-kubernetes-pods-from-outside-of-the-cluster/
- https://www.if-not-true-then-false.com/2010/install-virtualbox-with-yum-on-fedora-centos-red-hat-rhel/comment-page-1/?PageSpeed=noscript
- https://kubernetes.io/docs/concepts/cluster-administration/addons/
- https://www.projectcalico.org/
- https://kubernetes.io/docs/tasks/tools/install-minikube/
- https://gist.github.com/spagu/edd64ed990bad83430ca29210edaf5ee/