Use kubeadm to create the cluster
First of all there are some articles that use minikube, so why don’t I use minikube
. In this series, I have server production
environment, not learning, local
environment.
First we will initialize the master node with kubeadm
Master Node
1 2 | sudo kubeadm init --pod-network-cidr=10.244.0.0/16 |
Next we will run the following command, follow the recommend of kubeadm init
1 2 3 4 | mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config |
At worker Node
Follow the last line command after kubeadm init
we go to the copy worker nodes and run the same command below.
1 2 | sudo kubeadm join <ip_v4_private>:6443 --token <token> --discovery-token-ca-cert-hash sha256:<chuỗi hash> |
Master Node
run the following command
1 2 | sudo kubectl get nodes |
Result:
1 2 3 4 | framgia1c.mylabserver.com NotReady master 2m v1.17.0 framgia2c.mylabserver.com NotReady <none> 1m v1.17.0 framgia3c.mylabserver.com NotReady <none> 1m v1.17.0 |
Deploy Pod Network – Flannel
So what are pods and what are pod networks?
See also https://medium.com/google-cloud/understanding-kubernetes-networking-pods-7117dd28727
So what is flannel?
See also https://kubernetes.io/docs/concepts/cluster-administration/networking/#flannel
For flannel to work properly, you must run kubeadm init –pod-network-cidr = 10.244.0.0 / 16 beforehand.
Run sysctl net.bridge.bridge-nf-call-iptables = 1 to transfer bridged IPv4 traffic to the iptables chain. This is a requirement for some CNI plugins to work, for more information please see here and here
1 2 | kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af15c65e414cf26827915/Documentation/kube-flannel.yml |
Result:
1 2 3 4 | framgia1c.mylabserver.com Ready master 3m v1.17.0 framgia2c.mylabserver.com Ready <none> 2m v1.17.0 framgia3c.mylabserver.com Ready <none> 2m v1.17.0 |
Next
We will deploy, create the easiest application service nginx
earth
facebook: facebook.com/quanghung997