Install kubernetes with kubeadm

Kubeadm is a tool that helps you bootstrap a simple Kubernetes cluster and simplifies the deployment process.

Parst of the Kubernetes series  kubernetes01 # master node  kubernetes02 # frontend node  kubernetes03 # worker node  kubernetes04 # worker node  kubernetes05 # worker node

# hardware requirement

Install Docker

apt-get update
apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL | sudo apt-key add -
add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"
apt-get update
apt-get install docker-ce docker-ce-cli
systemct start docker
systemct enable docker


cat <<EOF >  /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

echo '1' > /proc/sys/net/ipv4/ip_forward
echo '1' > /proc/sys/net/bridge/bridge-nf-call-iptables

Disable swap

free -h
swapoff -a
swapoff -a
sed -i.bak -r 's/(.+ swap .+)/#\1/' /etc/fstab
free -h

Install kubeadm

apt-get install ebtables ethtool apt-transport-https

curl -s | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb kubernetes-xenial main

apt-get update && apt-get install -y kubelet kubeadm kubectl
apt-mark hold kubelet kubeadm kubect
systemctl enable kubelet && systemctl start kubelet
kubeadm config images pul

Init master

kubeadm init --pod-network-cidr= --apiserver-advertise-address=

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

kubectl apply -f

Join workers to cluster

kubeadm join --token XXXXXXXX \
    --discovery-token-ca-cert-hash sha256:XXXXXXXX