- https://cloud.redhat.com/blog/crictl-vs-podman
- https://kubernetes.io/docs/home/
- https://kubernetes.io/docs/setup/
In order to initialize the Kubernetes leader run the following commands on the first master node:
ip_leader=$( ip r | grep -v docker | awk '/eth0.proto.kernel/{ print $9 }' )
kube=kube-apiserver
log=/tmp/install-leader.log
sleep=10
calico=https://docs.projectcalico.org/v3.22/manifests/calico.yaml
pod_network_cidr=192.168.0.0/16
kubeconfig=/etc/kubernetes/admin.conf
echo ${ip_leader} ${kube} | sudo tee --append /etc/hosts
sudo swapoff --all
sudo kubeadm init --upload-certs --control-plane-endpoint "${kube}" --pod-network-cidr ${pod_network_cidr} --ignore-preflight-errors all 2>&1 | tee --append ${log}
Once the initialization has completed continue with the following commands still on the first master node:
sudo kubectl apply --filename ${calico} --kubeconfig ${kubeconfig} 2>& 1 | tee --append ${log}
mkdir -p ${HOME}/.kube/
sudo cp /etc/kubernetes/admin.conf ${HOME}/.kube/config
sudo chown -R $( id -u ):$( id -g ) ${HOME}/.kube/
echo 'source <(kubectl completion bash)' | tee --append ${HOME}/.bashrc
source ${HOME}/.bashrc
Check that the Leader master is ready before continuing:
kubectl get no | grep Ready
Once the Leader master is ready you can continue with these commands:
sudo sed --in-place /${kube}/d /etc/hosts
sudo sed --in-place /127.0.0.1.*localhost/s/$/' '${kube}/ /etc/hosts
grep ^kubeadm.join ${log} -A1
Now you are ready to join the worker nodes to the Kubernetes cluster. Run the following commands on the worker nodes:
ip_master1=172.X.X.X # HERE SUBSTITUTE THE VALUE OF THE IP ADDRESS FOR THE LEADER MASTER ${ip_leader}
# FOR EXAMPLE: ip_master1=172.31.1.138
kube=kube-apiserver
echo ${ip_master1} ${kube} | sudo tee --append /etc/hosts
In order to join the worker node to the cluster you need to run the output of the previous command from the Leader master like explained in the following paragraph:
sudo XXXXXXXXXXX # HERE YOU SUBSTITUTE THE OUTPUT OF THE FOLLOWING COMMAND RUN ON THE LEADER MASTER: grep ^kubeadm.join ${log} -A1
# FOR EXAMPLE:
# sudo kubeadm join kube-apiserver:6443 --token xxx.xxx --discovery-token-ca-cert-hash sha256:xxx
Check on the Leader master that the worker nodes have correctly joined the cluster:
kubectl get no
Other useful commands:
kubectl api-resources
kubectl create ns ns1
kubectl create ns ns2
kubectl api-resources | grep netpol