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


Thursday, January 1, 2026

TZ- time zone

                  

 

In first day of new Year I woudl like to write about Time Zones from perspective  of self-hosted apps.

When I deploy self-hosted apps, I encounter question, what value shoudl I  set in envioroment variable TZ.

I was not certain what had had set up. With help comes function tzselect(1) in Linux. 

I type  tzselect function. I was asked to specify location from provided list. In second step I select my country form list.

Now, I know.

TZ='Europe/Warsaw'; export TZ

 

 

LINK:

1.  https://www.cyberciti.biz/faq/linux-unix-set-tz-environment-variable/ 

 

Saturday, December 27, 2025

ARGO CD Homelab YAML

  

 

I am back!  In past days/ months I do not post. Reason why this happend, I played with KubeSpray installation and Longhorn. I try to automate some process, but self learnining has costs in time and errors. 

To summary my story, I select K3s Kubernetes with Longhorn for Storage for my Homelab.

 

 

I have bash script to install Argo Cd in my Homelab.

I used advanced instalation with helm. To have in the future be able to easer to update Helm chart. 

https://github.com/andsidor/Homelab-argocd/tree/master/argo-cd

As always to run bash it has to have execution rights.

I apply chmod and executed file.

chmod +x ./argo-install-advanced.sh && ./argo-install-advanced.sh 



I use Cloudflare tunnel to access to server.

https://argo.andrzejsidor.online

For the record I protect my Cloudflare tunnel from unauthorised access.

 

I added Argo CD server service list to protect my apps. 

 

When You try open link for my Argo CD server, You will see this page. It works with my email only. :)

 

 

In Lens I can see all pods in argocd namespaces are running.

 

 

In CLI CRD's with name 'argo' are running.

 

 

To use Gitops philosophy, objects it has to be declared in file. Ephemeral definition is no go. Git repository is source of truth.

I created Application CRD for Argo CD.

---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: nginx-demo
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/andsidor/Homelab-argocd
    targetRevision: master
    path: apps/app1/overlays
    kustomize:
      namePrefix: "demo-"
  destination:
    server: https://kubernetes.default.svc
    namespace: apps
  syncPolicy:
    automated:
      prune: true
      selfHeal: true 

 

kubectl apply -f ./file.yaml

After synchronization of Argo CD Application in present.


 

 

After clicking tile with nginx-demo, more details are present of each object in tree mode

 

 

In Pods mode is visible where each pod on which node is running.


 

In network mode we can see assigned IP for this service. It was possbile because in my homelab I have installed Ingress Traefik Controller. 

 

 

New apps are comming... in my homelab.

 

 

Saturday, October 25, 2025

Kubespray Homelab

 

    In the past I broke my K3s homelab more than few times. To set up K3s cluster again it was not complicated. I want to automate process of set up my cluster. Pararerly I started prepare to CKA exam. I done some reserach, and I find tool to set up cluster for me. This tool was kubespray(1). You may ask what is Kubespray. Kubespray is an open-source application developed to automate Kubernetes installation and configuration processes. It uses Ansible to perform instalation regardless of the infrastructure(2).

Kubespray support 14 Linux distributions(1). 

It support core components like: kubernetes, etcd, docker, containerd, cri-0.        For Network Plugins it support 8 plugins, for example support calico, cilium and flannel. It can install aplication like helm, cert-manager, argocd, ingress-nginx and metallb. Kubespray also has plugins for AWS, Azure, GCP and for local installation.

 

Stage 1. Preparation

To guarante success, for instalation process current users need to be added in sudoers file to not ask for password. 

Add user to group to allow execute any command. It is important to reverse this set up after installation.

sidor ALL=(ALL) NOPASSWD:ALL 

 

For better file management I create new folder for itmes from Github Kubespray repository. I set python venv to have area when requirements file will be installed.

 

Install apps from app list in file 'requirements.txt' with --ignore-installwed flag.


-sudo apt-get install python3-pip
 
*Pip install bez sudo 
 
 
 

I clone Kubespray GitHub repository. 


I declare IP adresse of my Ubuntu Servers in my local network. All servers had set SSH connection, by SSH-COPY-ID. 

declare -a IPS=(10.0.0.4 10.0.0.5 10.0.0.6)
 


In file listed below set select what core elements, apps and addons I want to be installed in my Homelab cluster.

cp -rfp inventory/sample inventory/sidor 

- addons file

- cluster file
 
 
 

At first attempt, I failed. I thought, that only uninstall K3s will works. I was wrong. 


Next day, I reinstalled all my machines. I apply command:
 
Update directly inventory file: inventory/sidor/invenory.ini
 
ansible-playbook -i <inventory-file> --become --become-user=root <cluster-file> 

*If You not have SSH key run:
ssh-keygen -t rsa -b 4096
in next step run ssh-copy-id  <user>@<server-IP>

 
Comment(19.11.2025)
Lesson learn for next Kubespray instalation. 
If You make brake during instalation (ansible command.....), in first step You need to activate envoroment.This is very important.
 
source kubespray-venv/bin/activate 
 
It takes 12M and 21S to install and set up cluster K8s for me with with selected addons. For it is huge step to have K8s Kubernetes Cluster. This will great place for practice for CKA exam and my portfolio.

Even set up was successfull, in final step, I copy config and add rights to this config.



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

 
Here K8s cluster is ready. 


with installed apps and addons.


 
This tools is good my homelab. When I first time try to install K8s manully it take me 15 times longer. On every step I amy make mistake. When process is automated, it can be repeatable and faster. Automation is a key.
 

DOCS:

1. https://github.com/kubernetes-sigs/kubespray

2. https://faun.pub/guide-to-efficient-kubernetes-cluster-setup-with-kubespray-8a29c58b13a2

 

PS. 

Kubespray fullfill my current needs. 
I am aware there are much faster tools like Talos, but on current stage this YAGNI. 

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