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 

Wednesday, February 11, 2026

Terraform

    Over 10 year ago, in 2014, HashiCorp company, lauched Terraform as open-source project. In 2023 (Hashcorp) change licence to BLS(Business Source License). Despite this change Terraform has 33% market share(December 2025). Infrastructure as code (IaC) is managing and provisioning IT resources. IaC code can be store in Git. Usage of Terraform, it has major advantages. 

Main advantages are repeatability and it saving time. During  building new infrastructure, all actions can be automated. It remove all flaws of manual creation of Infrastructure ( UI delay, UI changes, human fatigue). Automation can be incorporated by CI/CD pipelines.

In my homelab project, I developing back up with Velero. After research for cloud secret manager for my homelab, I select Google Cloud. Moreover I use Google Cloud calculator to find Google Cloud Storage has good price. It turn out that it has good price.  

 

Fun fact, Europe destination region is 0.02$ more expensive this Noth America.

In GCP Service Account, I created .json file to create cloud resources. It possible to create many .json files, where each file has limited access defined by IAM roles.

 

I created Linux variable "GOOGLE_APPLICATION_CREDENTIALS" to create resource by Terraform. 

Good practice is to add this variable to ~/.bashrc file, to have this variable avaiable after reboot of server.   

export GOOGLE_APPLICATION_CREDENTIALS="./kkk.json" 

kkk.json has all data to connect my GCP project. To keep this file save from commit, I updated .gitignore file

 

Preview of my .json file. 

 

 Here is my Terraform code to create Google Cloud Storage. Like in calculation above, I define to store my data in Warsaw, Poland Data center.

terraform {
    required_providers {
        google = {
            source  = "hashicorp/google"
            version = "~> 5.0"
        }
    }
}
provider "google" {
    project = var.project_id
    region  = var.region
}

variable "region" {
    type    = string
    default = "europe-central2"
}
variable "bucket_name" {
    type = string
    default = "homelab-k8s-storage-bucket-sidor"
}
resource "google_storage_bucket" "bucket" {
    name                        = var.bucket_name
    location                    = var.region
    uniform_bucket_level_access = true
}
variable "project_id" {
    type = string
    default = "mysecret-XXXXX"   ** FOR SAFETY REPLACED*XXXXX**
}


 

 

I will use most known Terraform commands():

- Terraform init - Initialize (2) the working directory, install required provider plugins and modules, and set up the backend. I can be executed by CI tools. 

 

 Command:

 - Terraform plan:

  • Ensures(3) the state is up to date by reading the current state of any already-existing remote infrastructure.
  • Determines the deltas between the current configuration and the prior state data.
  • Proposes a series of changes that will make the remote infrastructure match the current configuration.

My terraform plan has symbol "+ create" - it is when  resources do not exist. 

 

  Command:

 - Terraform apply - command executes (4) the actions proposed in a terraform        plan. It is used to deploy your infrastructure. Typically apply should be run after terraform init and terraform plan.

 

 In GCP, Google Cloud Storage "homelab-k8s-storage-bucket-sidor" was created.

After resource Google Cloud Storage was created, after execution second terraform -init, -plan, -apply - No changes - Infrastructure stay not modified. 

 

DOCs:

1. https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_bucket 

2. https://spacelift.io/blog/terraform-init#what-is-terraform-init

3. https://spacelift.io/blog/terraform-plan

4.  https://spacelift.io/blog/terraform-apply


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...