{"id":17327100,"url":"https://github.com/ffromani/virt-kube-lab","last_synced_at":"2026-04-29T08:01:54.833Z","repository":{"id":140070967,"uuid":"174847775","full_name":"ffromani/virt-kube-lab","owner":"ffromani","description":"Notes, howtos, scripts, tools to build your own kubernetes lab on top of KVM virtual machines","archived":false,"fork":false,"pushed_at":"2019-03-21T20:42:59.000Z","size":12,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T05:12:52.255Z","etag":null,"topics":["documentation","howto","kubernetes","kvm","lab","lan","virtual-machine","virtualization"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ffromani.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":"2019-03-10T16:10:45.000Z","updated_at":"2024-04-02T17:41:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"d076d0c8-1dbe-41cd-900a-40f7a4088f3b","html_url":"https://github.com/ffromani/virt-kube-lab","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ffromani/virt-kube-lab","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffromani%2Fvirt-kube-lab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffromani%2Fvirt-kube-lab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffromani%2Fvirt-kube-lab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffromani%2Fvirt-kube-lab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ffromani","download_url":"https://codeload.github.com/ffromani/virt-kube-lab/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffromani%2Fvirt-kube-lab/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32416146,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T06:29:02.080Z","status":"ssl_error","status_checked_at":"2026-04-29T06:29:00.631Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["documentation","howto","kubernetes","kvm","lab","lan","virtual-machine","virtualization"],"created_at":"2024-10-15T14:18:43.394Z","updated_at":"2026-04-29T08:01:54.798Z","avatar_url":"https://github.com/ffromani.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kubernetes on Virtual Machines on your home lab\n\n## Introduction\nWRITEME\n\n## Definitions\nEntities used in this document:\n\n* `user` is the developer box. May be the same box as `host`, although we assume it isn't.\n* `host` is the box on which VMs run. We assume the developer connects to it from `client` using SSH.\n* `guest` is the OS running on any VM.\n* `gateway` is the host on which dnsmasq run (see `host/lan` setup below). May be the same box as `host`, although we assume it isn't.\n\n## hardware\nTODO\n\n## setup\n\n### general\n\nIn this document, we assume you have a checkout of the `virt-kube-lab` repo on the `user` box, and that all commands are run within the root directory of the repo:\n```bash\nuser# git clone https://github.com/mojaves/virt-kube-lab.git\nuser# cd virt-kube-lab\n```\n\n### host\n\nWRITEME\nHost distribution: CentOS 7\n\nset up bridge and export its name:\n\n```bash\n# host\nexport VM_BRIDGE=\"k8sbr0\"\n```\n\n### lan\n\n### Required packages\n```bash\n# host\nyum -y install \\\nlibguestfs \\\nlibguestfs-xfs \\\nlibguestfs-tools \\\nlibguestfs-tools-c \\\njq\n```\n\n### Provision golden image for virtual machines\n```bash\n# host\nvirt-builder -o /var/lib/libvirt/images/c7-base.qcow2 --size=80G --format qcow2 --ssh-inject root:file:kojiro-kube-lan.pub --update --selinux-relabel --root-password file:rootpw centos-7.6\n```\n\n### Initial steps\n\n```bash\n# host\nexport VM_NAME=\"c7-test-vm\"\n```\n\n### Provision virtual machines\n\nClone the disks:\n```bash\n# host\ncp -a /var/lib/libvirt/images/c7-base.qcow2 /var/lib/libvirt/images/${VM_NAME}.qcow2\n```\n\n\n#### Provision for All-in-One:\n```bash\n# host\nvirt-install --name ${VM_NAME} --ram 6144 --vcpus 4 --cpu host --os-type linux --os-variant centos7.0 --disk path=/var/lib/libvirt/images/${VM_NAME}.qcow2,device=disk,bus=virtio,format=qcow2 --network bridge=${VM_BRIDGE},model=virtio --graphics none --console pty,target_type=serial --import\n```\n\nTODO: set up CPU passthrough (KVM L2)\n\n### Set up DNS, IP\n```bash\n# TODO: dns\n```\n\nTODO: the jq queries are naive and fragile\n\nDiscover the network addresses of the box, using the main (/default) NIC\n```bash\n# host\nVM_MACADDR=$(virsh qemu-agent-command ${VM_NAME} '{\"execute\":\"guest-network-get-interfaces\"}' | jq -r '.return[1] | .[\"hardware-address\"]')\nVM_IPADDR=$(virsh qemu-agent-command ${VM_NAME} '{\"execute\":\"guest-network-get-interfaces\"}' | jq -r '.return[1] | .[\"ip-addresses\"][0] | .[\"ip-address\"]')\necho -e \"export VM_NAME=${VM_NAME}\\nexport VM_MACADDR=${VM_MACADDR}\\nexport VM_IPADDR=${VM_IPADDR}\"\n```\n\nNow copy paste the output of last command (`VM_MACADDR` and `VM_IPADDR` variable definition) on `client`\n\nSet the user-friendly hostname:\n```bash\n# user\nssh -oStrictHostKeyChecking=no root@${VM_IPADDR} hostnamectl set-hostname ${VM_NAME}.kube.lan\n```\n\n### Install base packages\n```bash\n# user\nssh -T root@${VM_IPADDR} yum -y install $( cat packages/centos7-guest-base.txt )\n```\n\n## Pick your distribution\n\nBelow the instructions for vanilla Kubernetes (K8S) and Openshift Origin (OKD)\n\n## Kubernetes (K8S)\n\n### Configure for Kubeadm\n\nThe following [script](scripts/-kube-box-setup.sh) demonstrates the needed/recommended steps to setup a box on which we wanna run kubernetes.\nThe script requires root privileges.\nThe script is built for convenience/fast setup. The steps are taken from the kubernetes documentation, so they are believed to be correct,\nbut there is no error check or recovery, so **YOU SHOULD NEVER RUN THIS SCRIPT UNAUDITED OR ON A PRODUCTION, OR OTHERWISE IMPORTANT, BOX**.\n\n```bash\n# !/bin/bash\nset -e\n\n## REPOS\ncat \u003c\u003cEOF \u003e /etc/yum.repos.d/kubernetes.repo\n[kubernetes]\nname=Kubernetes\nbaseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\ngpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg\nexclude=kube*\nEOF\n\n## SELinux\n# Set SELinux in permissive mode (effectively disabling it) - still needed as k8s 1.13, unfortunately.\nsetenforce 0\nsed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config\n\n## Kernel\n# setup kernel parameters needed/recommended by k8s\ncat \u003c\u003cEOF \u003e  /etc/sysctl.d/k8s.conf\nnet.bridge.bridge-nf-call-ip6tables = 1\nnet.bridge.bridge-nf-call-iptables = 1\nnet.ipv4.ip_forward = 1\nEOF\nsysctl --system\n# setup kernel modules needed/recommended by k8s\ncat \u003c\u003cEOF \u003e /etc/modules-load.d/k8s.conf\nbr_netfilter\nEOF\nmodprobe br_netfilter\n\n## Firewalld\nsystemctl stop firewalld\nsystemctl disable firewalld\nsystemctl mask firewalld\n\n## Reset iptables\niptables -P INPUT ACCEPT\niptables -P FORWARD ACCEPT\niptables -P OUTPUT ACCEPT\niptables -t nat -F\niptables -t mangle -F\niptables -F\niptables -X\n\n## Disable swap - to avoid annoyances with kubelet\ncp /etc/fstab /etc/fstab.orig\ngrep -v swap /etc/fstab.orig \u003e /etc/fstab\n```\n\nTo run the script on the provisioned VM:\n```\n# user\nssh -T root@${VM_IPADDR} \u003c kube-box-setup.sh\n```\n\n### Install required packages\n\n```bash\n# user\nssh root@${VM_NAME} yum install -y $( cat packages/centos7-guest-container-base.txt )\nssh root@${VM_NAME} yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes\n```\n\n```bash\n# user\nssh root@${VM_NAME} systemctl enable --now docker\nssh root@${VM_NAME} systemctl enable --now kubelet\n```\n\n### Run kubeadm\n\n```bash\n# we will use flannel, so use parameters recommended by flannel\n# user\nssh root@${VM_NAME} kubeadm init --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=swap\n```\n\n```bash\n# TODO: setup flannel\n```\n\n### Configure the host ass All-in-One\n\nTODO: (un)taint node\n\n\n## Openshift Origin (OKD)\n\nTODO\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fffromani%2Fvirt-kube-lab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fffromani%2Fvirt-kube-lab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fffromani%2Fvirt-kube-lab/lists"}