The following flow is how to use kubeadm
to establish a Kubernetes cluster.
In the beginning, use the package management tool to install the necessary components of Kubernetes.
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" \ >> /etc/apt/sources.list.d/kubernetes.list
apt-get update
apt-get upgrade
apt-get install -y kubelet kubeadm kubectl kubernetes-cni
Setup the master and worker nodes separately.
Initialize the master node.
sudo su
kubeadm reset
kubeadm init --pod-network-cidr 10.244.0.0/16 --control-plane-endpoint 192.168.3.40
exit # logout the superuser
mkdir ~/.kube
sudo cp -i /etc/kubernetes/admin.conf ./.kube/config
sudo chown 1000:1000 ./.kube/config
kubectl get nodes -o wide -n kube-system
kubectl get pods -o wide -n kube-system
Make the worker node join the master one.
sudo su
kubeadm reset
kubeadm join 192.168.3.40:6443 --token <token> --discovery-token-ca-cert-hash sha256:<token>
After you setup the node network, next, you have to setup the network of pods.
# for the intel solution,
# flannel was not working
curl https://docs.projectcalico.org/manifests/calico.yaml -O
kubectl apply -f calico.yaml
# for the ARM solution
# calico does not support ARM
curl -sSL https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml > ./kube-flannel.yaml
kubectl apply -f ./kube-flannel.yaml
You can inspect the networking state on Pods.
kubectl get pods -o wide -n kube-system
kubectl describe nodes | grep PodCIDR
Now, the cluster was established. You can view the status of API from the dashboard.
curl -sSL https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.5/aio/deploy/recommended.yaml > dashboard.yaml
kubectl apply -f ./dashboard.yaml
kubectl get pods -o wide -n kubernetes-dashboard
# view from the node port
kubectl proxy --address 0.0.0.0 --accept-hosts='.*'
The followings are some tips when
kubeadm init
fails.You can add the following parameters
cgroup_enable=memory cgroup_memory=1
to the end of the file/boot/firmware/cmdline.txt
.Because the docker's default cgroup is different from k8s, you can add the configure
{"exec-opts": ["native.cgroupdriver=systemd"]}
to the file/etc/docker/daemon.json
and restart the docker.