Monday, February 23, 2026

K8s cluster - bash install



    In my homelab, I testes another method of installation of Kubernetes. Average time of installation of Kubernetes via Ansible was 15 min with addons. Before installation I also need to initially set Linux OS. I tryed to find faster instalation method. 

 My idea was to install Kubernetes via bash script from remote pc. Second step in this method was to use GitOps. To install all CRD'a I use Flux cd. Base instlatalation is faster and I all infrastrucure artefacts are store in Github repositotium.

 

Step 0.

Copy of SSH key from remote pc to node to connect with cluster control-plane and nodes faster.

Master node:

192.168.0.110

Worker node:

192.168.0.111

192.168.0.112

 

If node was used, ssh-key need to be removed from remote pc and added again by ssh-copy-id user@node-ip (ssh-copy-id sidor@192.168.0.110.

Repeat step above to all control planes and worker nodes. 

 

 Second step was creartion bash file, add execution rights and execute.

vi file-name.sh

chmod +x file-name.sh

sudo ./file-name.sh

To install control plane, I used bash script from Doku link (1). File is stored on my Github account. 

 

Excecution of k8s.sh script. 

 

    After instlation kubeadm  join command was printed out to add new homelab Kubernetes nodes.

  

Excecute commands below to initial master node. 

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

    In Third step is created, chmod'ed file and executed. Link do install worker nodes (1 and 2) node is in doku (2). Reapeat this step before joining worker nodes to control-plane . 

 

After bash is executed, run join command for each node. 

 

Sometimes worker nodes are NotReady status. 

 

Run commands listed below to fix this problem. 

sudo systemctl status kubelet
sudo journalctl -xeu kubelet -n 50

 

Kubenetes (control-plane and worker nodes) cluster is ready. See below.

 

Summary:

Instalation on each node was much more faster. In this method instalation was aprrox. 50% faster. This instalation method was semi-manual. 

Control-plane: 1M37S 

Worker 1: 1M58S +3S

Worker 2: 1M58S +3S  

Conclusion:

Second instalation method was 50% faster than KubeSpray, but it was semi-automatic.  For cloud solution can be used is Talos or Bottlerocket and automation by CI pipeline.

 DOC:

1. https://github.com/andsidor/HomeLab-Fluxcd/blob/main/k8s/DOCs/control-plane.sh

2. https://github.com/andsidor/HomeLab-Fluxcd/blob/main/k8s/DOCs/worker.sh 

No comments:

Post a Comment

K8s cluster - bash install

     In my homelab, I testes another method of installation of Kubernetes. Average time of installation of Kubernetes via Ansible was 15 min...