{"id":21845186,"url":"https://github.com/brazeg/k8s-homelab","last_synced_at":"2026-05-09T16:45:09.813Z","repository":{"id":264557623,"uuid":"893669797","full_name":"Brazeg/k8s-homelab","owner":"Brazeg","description":"Complete Kubernetes Lab Environment Setup Guide on Windows 11 using Ubuntu Virtual Machines","archived":false,"fork":false,"pushed_at":"2024-12-19T06:19:40.000Z","size":1835,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T12:08:16.258Z","etag":null,"topics":["devops","grafana","homelab","k8s","kubernetes","learning","local-cluster","promotheus","tutorial","vmware-workstation-17-pro"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Brazeg.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-25T01:54:30.000Z","updated_at":"2025-01-08T06:36:22.000Z","dependencies_parsed_at":"2024-11-25T04:33:18.482Z","dependency_job_id":null,"html_url":"https://github.com/Brazeg/k8s-homelab","commit_stats":null,"previous_names":["brazeg/k8s-homelab"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Brazeg%2Fk8s-homelab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Brazeg%2Fk8s-homelab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Brazeg%2Fk8s-homelab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Brazeg%2Fk8s-homelab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Brazeg","download_url":"https://codeload.github.com/Brazeg/k8s-homelab/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244828692,"owners_count":20517155,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["devops","grafana","homelab","k8s","kubernetes","learning","local-cluster","promotheus","tutorial","vmware-workstation-17-pro"],"created_at":"2024-11-27T23:08:27.101Z","updated_at":"2026-05-09T16:45:09.783Z","avatar_url":"https://github.com/Brazeg.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\nComplete guide to setting up a Kubernetes lab environment on an Ubuntu virtual machine hosted using VMware Workstation Pro on Windows 11 machine\n\n\u003cimg src=\"Space Captain.png\" alt=\"Lab Setup\" title=\"Kubernetes Space Captain\" width=\"800\"/\u003e\n\n- [Overview](#overview)\n- [Prerequisites for Kubernetes Lab Environment](#prerequisites-for-kubernetes-lab-environment)\n- [1. Infrastructure Setup](#1-infrastructure-setup)\n  - [1.1 VM Configuration in VMware Workstation Pro](#11-vm-configuration-in-vmware-workstation-pro)\n    - [Master Node (k8s-master):](#master-node-k8s-master)\n    - [Worker Node (k8s-worker):](#worker-node-k8s-worker)\n  - [1.2 Network Configuration](#12-network-configuration)\n- [2. Basic System Configuration](#2-basic-system-configuration)\n  - [2.1 Update System](#21-update-system)\n  - [2.2 Disable Swap](#22-disable-swap)\n  - [2.3 Load Kernel Modules](#23-load-kernel-modules)\n  - [2.4 Configure Sysctl](#24-configure-sysctl)\n  - [2.5 Configure Network Interfaces on both nodes](#25-configure-network-interfaces-on-both-nodes)\n- [3. Kubernetes Installation](#3-kubernetes-installation)\n  - [3.1 Install containerd](#31-install-containerd)\n  - [3.2 Install Kubernetes Components](#32-install-kubernetes-components)\n- [4. Initialize Kubernetes Cluster](#4-initialize-kubernetes-cluster)\n  - [4.1 Initialize Control Plane](#41-initialize-control-plane)\n  - [4.2 Set Up kubectl for Non-Root User](#42-set-up-kubectl-for-non-root-user)\n  - [4.3 Install Calico Network Plugin](#43-install-calico-network-plugin)\n- [5. Join Worker Node to Cluster](#5-join-worker-node-to-cluster)\n- [6. Verify Cluster Setup](#6-verify-cluster-setup)\n- [7. Install Monitoring Stack (Prometheus and Grafana)](#7-install-monitoring-stack-prometheus-and-grafana)\n  - [7.1 Install Helm](#71-install-helm)\n  - [7.2 Install Prometheus and Grafana](#72-install-prometheus-and-grafana)\n  - [7.3 Access Grafana](#73-access-grafana)\n  - [7.4 OPTIONAL Access Grafana and Promotheus using NodePort](#74-optional-access-grafana-and-promotheus-using-nodeport)\n  - [8.1 Check Node Status](#81-check-node-status)\n  - [8.2 Check Pod Status](#82-check-pod-status)\n  - [8.3 Check Logs](#83-check-logs)\n  - [8.4 Check Services](#84-check-services)\n- [9. Accessing Kubernetes Cluster from Windows Host Machine](#9-accessing-kubernetes-cluster-from-windows-host-machine)\n\n\n======================================\n## Overview\n\nThis guide will help you create a production-like Kubernetes cluster with 2 nodes (1 master, 1 worker) running on Ubuntu VMs. Instead of clicking through VM windows, you'll learn to manage everything like a pro:\n\n- Control your VMs through SSH directly from your Windows terminal 🚀\n- Execute commands remotely without accessing the VM console 💻\n- Run kubectl commands from your Windows machine 🎮\n- Set up everything from scratch for deep understanding 🔧\n\nUnlike simpler alternatives like Minikube or Kind, this setup mirrors a real production environment with multiple nodes, true networking, and SSH-based management. You'll gain hands-on experience with the complete installation process, network configuration, and infrastructure management.\n\nThink of it as your personal production environment - all the real-world practices, none of the complexity of cloud costs! Perfect for learning, testing, and experimenting with Kubernetes.\n\n\n## Prerequisites for Kubernetes Lab Environment\n1. Hardware Requirements\n\nHost Computer Specifications:\n\nCPU: Intel/AMD processor with virtualization support (VT-x/AMD-V)\nRAM: Minimum 8GB (16GB recommended)\nStorage: At least 40GB free space\nOperating System: Windows 11\n\n\n2. Software Requierments\n\n2.1 VMware Workstation Pro 17 (Free for personal useage)\nNote: The VMware Workstation 17 installation process might be more complicated currently due to the recent Broadcom acquisition of VMware.\n * Create an account on https://broadcom.com\n * go to https://support.broadcom.com/\n * Choose Cloud Foundation from the upper right menu\n * Now the installation file of VMware Workstation can be found in the My Downlaod section\n\n\n2.2 Ubuntu Server ISO\n\nDownloadable from the offical website: https://ubuntu.com/download/alternative-downloads\n\nDirect link: webtorrent: https://releases.ubuntu.com/22.04/ubuntu-22.04.5-live-server-amd64.iso.torrent\n\n\n1\\. Infrastructure Setup\n------------------------\n* Choose \"Typical\" installation when creating new VM\n* Select \"I will install the operating system later\" option\n* On the disk settings page:\n    * Select \"Store virtual disk as a single file\"\n    * Do NOT split disk into multiple files\n\n\n* During Ubuntu Server installation:\n    * In the storage configuration step, disable LVM (Logical Volume Management)\n    * Choose \"Use entire disk\" without LVM\n    * This makes the disk configuration simpler and more straightforward for a lab environment\n\n### 1.1 VM Configuration in VMware Workstation Pro\n\nuse typical installation\ndisable lg groups\nuse one file for storage\n\n#### Master Node (k8s-master):\n\n*   OS: Ubuntu Server 22.04.5 LTS\n*   CPU: 2 cores (minimum), 4 cores (recommended)\n*   RAM: 4GB (minimum), 8GB (recommended)\n*   Storage: 50GB (recommended)\n\n#### Worker Node (k8s-worker):\n\n*   OS: Ubuntu Server 22.04.5 LTS\n*   CPU: 2 cores (minimum)\n*   RAM: 2GB (minimum)\n*   Storage: 20GB (minimum)\n\n### 1.2 Network Configuration\n\nFor both master and worker nodes in the the VMware Workstation VM settings:\n\n1.  Set primary network adapter (Network Adapter 1) to NAT\n2.  Add a second network adapter (Network Adapter 2) set to Host-only\n\n2\\. Basic System Configuration\n------------------------------\n\nRun these steps on both master and worker nodes:\n\n### 2.1 Update System\n\n    sudo apt update \u0026\u0026 sudo apt upgrade -y\n    sudo apt install -y curl openssh-server net-tools nano\n\n### 2.2 Disable Swap\n\n    sudo swapoff -a\n    sudo sed -i '/ swap / s/^\\(.*\\)$/#\\1/g' /etc/fstab\n\n### 2.3 Load Kernel Modules\n\n    cat \u003c\u003cEOF | sudo tee /etc/modules-load.d/k8s.conf\n    overlay\n    br_netfilter\n    EOF\n    sudo modprobe overlay\n    sudo modprobe br_netfilter\n\n### 2.4 Configure Sysctl\n\n    cat \u003c\u003c EOF | sudo tee /etc/sysctl.d/k8s.conf\n    net.bridge.bridge-nf-call-iptables = 1\n    net.bridge.bridge-nf-call-ip6tables = 1\n    net.ipv4.ip_forward = 1\n    EOF\n    sudo sysctl --system\n\n### 2.5 Configure Network Interfaces on both nodes\nGet IP address information:\n\n    ip addr show\n\nNote the following:\n1. The lo interface (127.0.0.1) is the loopback interface, which we don't use for networking between VMs.\n2. The ens33 interface (192.x.x.x) is likely your NAT interface. This is the IP address you can use for SSH access from your host machine.\n\nUse one of these options to ease the copy pasting process and enhance the experince:\n\nEither open 2 sessions with the software Putty, as follows:\n* Enter the IP address of one of the VMs\n* Set the port to 22 (default for SSH)\n* Give the session a name (e.g., *\"k8s-master\" or \"k8s-worker\")\n* Click \"Save\" to save this session\n* Repeat for the other VM\n\nOR\n\nuse ssh directly from powershell or windows terminal (better experince):\n\n    ssh username@master-node-ip\n\n*Remember, when you're initializing the Kubernetes cluster on the master node, you'll use the Host-only IP address of the master node for the --apiserver-advertise-address parameter.*\n\n\n3. The ens37 interface is your Host-only adapter, but it's currently in a DOWN state and doesn't have an IP address assigned.\nThe ens37 host-only interface is needed to allow your VMs (k8s nodes) to communicate with each other and with your host computer in an isolated network, without needing access to the external internet\n\n\nBring up the ens37 interface:\n    \n    sudo ip link set ens37 up\n\nAssign an IP address to this interface:\n\n    sudo ip addr add 192.168.56.20/24 dev ens37\n\n\n\nEdit the Netplan configuration:\n\n    sudo nano /etc/netplan/00-installer-config.yaml\n\nAdd configuration for `ens37`:\n\n    network:\n      ethernets:\n        ens33:\n          dhcp4: true\n        ens37:\n          dhcp4: no\n          addresses: [192.168.56.20/24]  # Remember to use 192.168.56.21/24 for worker node\n      version: 2\n\nApply the configuration:\n\n    sudo netplan apply\n\nVerify with:\n\n    ip addr show\n\n3\\. Kubernetes Installation\n--------------------------\n\nPerform these steps on both master and worker nodes:\n\n### 3.1 Install containerd\n\nInstallling the container runtime enviroment \n\n    sudo apt install -y containerd\n    sudo mkdir -p /etc/containerd\n    containerd config default | sudo tee /etc/containerd/config.toml\n    sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml\n    sudo systemctl restart containerd\n\n### 3.2 Install Kubernetes Components\n\ninstalling kubernetes components and holding them from automatic updates\n\n    curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg\n    echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list\n    sudo apt update\n    sudo apt install -y kubelet kubeadm kubectl\n    sudo apt-mark hold kubelet kubeadm kubectl\n\n4\\. Initialize Kubernetes Cluster\n--------------------------------\n\nPerform these steps on the master node:\n\n### 4.1 Initialize Control Plane\n\n    sudo kubeadm init --pod-network-cidr=172.16.0.0/12 --apiserver-advertise-address=192.168.56.20\n\n### 4.2 Set Up kubectl for Non-Root User\n\n    mkdir -p $HOME/.kube\n    sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config\n    sudo chown $(id -u):$(id -g) $HOME/.kube/config\n\n### 4.3 Install Calico Network Plugin\n\n    kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.27.3/manifests/tigera-operator.yaml\n\nApply Calico configuration:\n\n    cat \u003c\u003c EOF | kubectl apply -f -\n    apiVersion: operator.tigera.io/v1\n    kind: Installation\n    metadata:\n      name: default\n    spec:\n      calicoNetwork:\n        ipPools:\n        - blockSize: 26\n          cidr: 172.16.0.0/12\n          encapsulation: VXLANCrossSubnet\n          natOutgoing: Enabled\n          nodeSelector: all()\n    ---\n    apiVersion: operator.tigera.io/v1\n    kind: APIServer \n    metadata: \n      name: default \n    spec: {}\n    EOF\n\n5\\. Join Worker Node to Cluster\n------------------------------\n\nOn the master node, generate a join command:\n\n    kubeadm token create --print-join-command\n\nOn the worker node, run the generated command with sudo -E:\n\n    sudo -E \u003cjoin-command\u003e\n\n6\\. Verify Cluster Setup\n-----------------------\n\nOn the master node:\n\n    kubectl get nodes\n\n7\\. Install Monitoring Stack (Prometheus and Grafana)\n----------------------------------------------------\n\nOn the master node:\n\n### 7.1 Install Helm\n\n    sudo apt-get install curl gpg apt-transport-https --yes\n    curl -fsSL https://packages.buildkite.com/helm-linux/helm-debian/gpgkey | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg \u003e /dev/null\n    echo \"deb [signed-by=/usr/share/keyrings/helm.gpg] https://packages.buildkite.com/helm-linux/helm-debian/any/ any main\" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list\n    sudo apt-get update\n    sudo apt-get install helm\n\n### 7.2 Install Prometheus and Grafana\n\n    # Create dedicated namespace for monitoring\n    kubectl create namespace monitoring\n    \n    # Add Prometheus helm repository\n    helm repo add prometheus-community https://prometheus-community.github.io/helm-charts\n    helm repo update\n    \n    # Install Prometheus and Grafana stack in monitoring namespace\n    helm install monitoring prometheus-community/kube-prometheus-stack \\\n      --namespace monitoring \\\n      --create-namespace \\\n      --set grafana.adminPassword=\"prom-operator\"\n\n### 7.3 Access Grafana\n\nTo access Grafana, use port-forwarding with SSH Tunneling:\n\n1. On your host machine (not the VM), open a new terminal and run:\n\n        ssh -L 3000:localhost:3000 username@master-node-ip\n\n2. Once connected, run the port-forward command in the SSH session:\n\n        kubectl port-forward deployment/monitoring-grafana 3000 --namespace=monitoring\n\n\nAccess Grafana at `http://localhost:3000` in your browser.\n\nDefault credentials:\n\n*   Username: admin\n*   Password: prom-operator\n\n###  7.4 OPTIONAL Access Grafana and Promotheus using NodePort\n*Alternativ to SSH Tunneling you can use the kubernetes service type NodePort, BUT KEEP IN MIND this is less secure without additional measuerments*\n\nWrite the following content into a monitoring-nodeports.yaml file then apply it with kubectl:\n\n    kubectl apply -f monitoring-nodeports.yaml\n\n*reverse with*:  kubectl delete -f monitoring-nodeports.yaml\n\nmonitoring-nodeports.yaml content: \n\n    apiVersion: v1\n    kind: Service\n    metadata:\n      name: prometheus-nodeport\n      namespace: monitoring\n      labels:\n        app: prometheus\n    spec:\n      type: NodePort\n      ports:\n        - port: 9090\n          targetPort: 9090\n          nodePort: 30909  # You can choose a port between 30000-32767\n          protocol: TCP\n          name: http\n      selector:\n        app.kubernetes.io/name: prometheus\n        prometheus: monitoring-kube-prometheus-prometheus\n    ---\n    apiVersion: v1\n    kind: Service\n    metadata:\n      name: grafana-nodeport\n      namespace: monitoring\n      labels:\n        app: grafana\n    spec:\n      type: NodePort\n      ports:\n        - port: 3000\n          targetPort: 3000\n          nodePort: 30300  # You can choose a port between 30000-32767\n          protocol: TCP\n          name: http\n     selector:\n        app.kubernetes.io/name: grafana\n\n\nFrom your Windows machine, try accessing in the browser:\n\n* http://192.168.56.20:30909 for Prometheus\n* http://192.168.56.20:30300 for Grafana\n\n\n\n8. Troubleshooting and Verification\n-----------------------------------\n\n### 8.1 Check Node Status\n\n    kubectl get nodes\n    kubectl describe nodes\n\n### 8.2 Check Pod Status\n\n    kubectl get pods --all-namespaces\n\n### 8.3 Check Logs\n\n    kubectl logs \u003cpod-name\u003e -n \u003cnamespace\u003e\n\n### 8.4 Check Services\n\n    kubectl get services --all-namespaces\n\n9\\. Accessing Kubernetes Cluster from Windows Host Machine\n---------------------------------------------------------\n\nSince you're using Windows and already have SSH access to your VMs, here's how to set up kubectl access from your Windows machine: First, ensure kubectl is installed on your Windows machine: You can install it using winget: winget install Kubernetes.kubectl Or download it directly from kubernetes.io\n\n1.  Create the kubectl config directory (if it doesn't exist) and the config file using powershell:\n    \n        mkdir \"$env:USERPROFILE\\.kube\"\n        New-Item -Path \"$env:USERPROFILE\\.kube\\config\" -Type File -Force\n\n2.  Copy the content of kubeconfig from the master node using your existing SSH connection\n\n3.  Paste this data into the %USERPROFILE%\\\\.kube\\config file on your windows machine using Notepad or your preferred text editor then run this in powershell to set the enviroment variable:\n\n        $env:KUBECONFIG = \"C:\\Users\\yourUserName\\.kube\\config\" \n    \n4.    Edit the config file using Notepad or your preferred text editor: Open %USERPROFILE%\\.kube\\config\n    \n5.  try pinging the `master node's IP: https://192.168.56.20:6443`, if not successfull you have to make sure the Network adapter is set correctly by VMware on your windows machine, for that do the following:\n\n    * type ncpa.cpl in the Run dialog or search bar\n\n    * Right-click on \"VMware Network Adapter VMnet1\" and choose Properties\n\n    * Select \"Internet Protocol Version 4 (TCP/IPv4)\" and click Properties\n\n    * Make sure that the IP address in the section \"Use the following IP address\" is the right one, then apply the changes.\n\n\nNow you can use kubectl commands from your host machine to interact with your Kubernetes cluster. \n\n``\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrazeg%2Fk8s-homelab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrazeg%2Fk8s-homelab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrazeg%2Fk8s-homelab/lists"}