To initialize the Kubernetes cluster, execute the operations on the first main node:
Start the initialization command under the root user:
kubeadm init
Finish the root user session:
exit
Log in under the different user and grant to him all cluster management privileges:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Get the command for cluster connection. To do this, execute the command under the name of the selected user:
kubeadm create token --print-join-command
The example of response:
kubeadm join {<main node IP address>}:6443 --token XXXXXXXXXXXX \
--discovery-token-ca-cert-hash sha256:YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
IMPORTANT. Execute the obtained command on each cluster node under the root user.
After executing the operations, the Kubernetes cluster is initialized on the main node. Next, set up the intra-cluster network.
Intra-cluster network (CNI) is set up using the cilium utility on the first main node.
To set up intra-cluster network:
Get the list of cluster nodes:
kubectl get nodes
After this the list of cluster nodes with the NotReady status is obtained. Status depends on intra-cluster network settings.
Add a link to the cilium utility to the Helm repository and install the utility:
helm repo add cilium https://helm.cilium.io/
helm install cilium cilium/cilium --version 1.15.4 --namespace kube-system
CILIUM_CLI_VERSION=$(curl -s https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt)
CLI_ARCH=amd64
if [ "$(uname -m)" = "aarch64" ]; then CLI_ARCH=arm64; fi
curl -L --fail --remote-name-all https://github.com/cilium/cilium-cli/releases/download/${CILIUM_CLI_VERSION}/cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum}
sha256sum --check cilium-linux-${CLI_ARCH}.tar.gz.sha256sum
sudo tar xzvfC cilium-linux-${CLI_ARCH}.tar.gz /usr/local/bin
rm cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum}
Check status of the intra-cluster network:
cilium status --wait
Cluster nodes should change their status to Ready.
Start intra-cluster network test and wait until it is finished:
cilium connectivity test
The example of response:
69/69 tests successful (0 warnings)
If there are no errors and warnings, the network and cluster are set up correctly.
Get the list of cluster nodes again:
kubectl get nodes
After this the list of cluster nodes with the Ready status is obtained.
Next, set up the Kubernetes external network.
See also:
Preparation and Deployment of Fault-Tolerant Cluster Based on Kubernetes | Setting Up Kubernetes External Network