{"id":15090204,"url":"https://github.com/felipelaptrin/on-prem-k8s","last_synced_at":"2026-01-07T06:51:19.464Z","repository":{"id":242993652,"uuid":"808313740","full_name":"felipelaptrin/on-prem-k8s","owner":"felipelaptrin","description":"Creating Kubernetes clusters using Rancher, Terraform and Vagrant","archived":false,"fork":false,"pushed_at":"2024-06-06T04:16:10.000Z","size":496,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-03T15:55:33.277Z","etag":null,"topics":["blog","devbox","kubernetes","opentofu","rancher","terraform","vagrant"],"latest_commit_sha":null,"homepage":"https://www.felipetrindade.com/on-premise-kubernetes/","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/felipelaptrin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-05-30T20:09:17.000Z","updated_at":"2024-10-05T04:53:14.000Z","dependencies_parsed_at":"2024-06-06T06:10:42.899Z","dependency_job_id":null,"html_url":"https://github.com/felipelaptrin/on-prem-k8s","commit_stats":null,"previous_names":["felipelaptrin/on-prem-k8s"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipelaptrin%2Fon-prem-k8s","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipelaptrin%2Fon-prem-k8s/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipelaptrin%2Fon-prem-k8s/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipelaptrin%2Fon-prem-k8s/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felipelaptrin","download_url":"https://codeload.github.com/felipelaptrin/on-prem-k8s/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246144217,"owners_count":20730373,"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":["blog","devbox","kubernetes","opentofu","rancher","terraform","vagrant"],"created_at":"2024-09-25T09:23:24.422Z","updated_at":"2026-01-07T06:51:19.434Z","avatar_url":"https://github.com/felipelaptrin.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# on-prem-k8s\n\nThis repository helps you deploy Kubernetes in an on-premise environment using Rancher and OpenTofu (Terraform). This is not a production-ready template since Rancher is being installed in a single node but can give you a good understanding of how Rancher should be set up.\n\n## Deployment\nThe deployment should be trivial to accomplish. To make the development live easier I set up [DevBox](https://www.jetify.com/devbox/docs/) in the project. So make sure you have it installed!\n\n1) Make sure you have nodes in place\nThe nodes should be able to reach (network) themselves. In case you don't have physical servers or VMs you can still test this by locally deploying VMs using Vagrant and VMware Fusion (Hypervisor). To do so, just follow the step below:\n\n- [Install Vagrant](https://developer.hashicorp.com/vagrant/docs/installation): We are using Vagrant to automate the creation of VMs using `Vagrantfile`.\n- [Install VMWare Fusion Pro](https://support.broadcom.com/group/ecx/productdownloads?subfamily=VMware+Fusion): We could have used any other hypervisor (e.g. Virtualbox) to deploy the VMs but I think VMware Fusion is a great option because it's one of the few free (for personal use) hypervisors that you can use with M-series Macbooks.\n- [Install VMware Utility](https://developer.hashicorp.com/vagrant/docs/providers/vmware/vagrant-vmware-utility): This will provide VMware provider plugin (that we are installing next) with various functionalities.\n- [Install Vagrant VMware plugin](https://developer.hashicorp.com/vagrant/docs/providers/vmware/installation): Simply run `vagrant plugin update vagrant-vmware-desktop`.\nhttps://profile.broadcom.com/web/registration\n\nAfter this is done, simply run `vagrant up` and the VMs will be created for you.\n\n2) Install dependencies\nMake sure you have [DevBox](https://www.jetify.com/devbox/docs/) installed.\n\n```sh\ndevbox shell\n```\n\n3) Configure OpenTofu (Terraform) variables\n\nThe `infrastructure` folder contains all the terraform files that will deploy Rancher and the managed Kubernetes cluster. You can check the `variables.tf` file to understand all the inputs of the code. You can create a `vars.tfvars` file with your desired configuration (make sure to create this file inside the `infrastructure` folder). A completely valid configuration can be seen below:\n\n```hcl\nk3s_version          = \"v1.28.10+k3s1\"\ncert_manager_version = \"v1.14.5\"\nrancher_version      = \"v2.8.4\"\nrancher_endpoint     = \"192.168.110.10.sslip.io\"\nmanagement_cluster = {\n  host        = \"127.0.0.1\",\n  user        = \"vagrant\"\n  password    = \"vagrant\"\n  port        = 2222\n  private_key = \"/Users/felipe/Desktop/folders/personal/rancher/.vagrant/machines/rancher-manager/vmware_fusion/private_key\"\n}\nmanaged_cluster = {\n  development = {\n    kubernetes_version = \"v1.28.10+rke2r1\"\n    nodes = [{\n      host        = \"127.0.0.1\",\n      user        = \"vagrant\"\n      password    = \"vagrant\"\n      port        = 2200\n      private_key = \"/Users/felipe/Desktop/folders/personal/rancher/.vagrant/machines/node01/vmware_fusion/private_key\",\n      role        = [\"controlplane\"]\n      },{\n      host        = \"127.0.0.1\",\n      user        = \"vagrant\"\n      password    = \"vagrant\"\n      port        = 2201\n      private_key = \"/Users/felipe/Desktop/folders/personal/rancher/.vagrant/machines/node02/vmware_fusion/private_key\"\n      role        = [\"etcd\"]\n      },\n      {\n      host        = \"127.0.0.1\",\n      user        = \"vagrant\"\n      password    = \"vagrant\"\n      port        = 2202\n      private_key = \"/Users/felipe/Desktop/folders/personal/rancher/.vagrant/machines/node03/vmware_fusion/private_key\"\n      role        = [\"worker\"]\n      }]\n  }\n}\n```\n\nPS: Make sure to edit `managed_cluster.\u003ccluster-name\u003e.nodes[]` accordingly. If you are using Vagrant to create the machines you can run `vagrant ssh-config` to get the `host`, `user`, `password`, `port` and `private_key`.\n\nThe given example creates a managed K8S node with three nodes, and each node as a single role (etcd, controlplane, worker). As commented before, this is NOT a production-ready example. Please check Rancher [documentation](https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/kubernetes-clusters-in-rancher-setup/checklist-for-production-ready-clusters/recommended-cluster-architecture).\n\n4) Configure Rancher Helm chart values\n\nIf you are not using Vagrant, you will need to change the `hostname` of the `infrastructure/bootstrap/values.yaml` file to be the value of the host that will have Rancher installed. If you are using Vagrant, there is no need to change!\n\n5) Deploy using OpenTofu\n\nRun the following commands:\n\n```sh\ncd infrastructure\ntofu init\ntofu apply --var-file=\"vars.tfvars\"\n```\n\n6) Access the local rancher endpoint\n\n```sh\n192.168.110.10.sslip.io\n```\n\nThis will be different if you didn't use Vagrant.\n\n7) Are you satisfied? Destroy everything!\n\nFrom the root of this repository run\n\n```\nvagrant destroy\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipelaptrin%2Fon-prem-k8s","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelipelaptrin%2Fon-prem-k8s","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipelaptrin%2Fon-prem-k8s/lists"}