{"id":25707720,"url":"https://github.com/jhsware/nix-infra-test","last_synced_at":"2025-06-17T01:36:44.864Z","repository":{"id":261751653,"uuid":"876289638","full_name":"jhsware/nix-infra-test","owner":"jhsware","description":"Minimal cluster setup for testing nix-infra","archived":false,"fork":false,"pushed_at":"2024-11-29T07:38:31.000Z","size":96878,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-30T14:47:41.792Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Nix","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/jhsware.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-10-21T18:06:21.000Z","updated_at":"2025-02-02T14:49:19.000Z","dependencies_parsed_at":"2025-02-25T08:49:06.895Z","dependency_job_id":null,"html_url":"https://github.com/jhsware/nix-infra-test","commit_stats":null,"previous_names":["jhsware/nix-infra-test"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jhsware/nix-infra-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhsware%2Fnix-infra-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhsware%2Fnix-infra-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhsware%2Fnix-infra-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhsware%2Fnix-infra-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jhsware","download_url":"https://codeload.github.com/jhsware/nix-infra-test/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhsware%2Fnix-infra-test/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260272649,"owners_count":22984361,"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":[],"created_at":"2025-02-25T08:38:52.111Z","updated_at":"2025-06-17T01:36:44.835Z","avatar_url":"https://github.com/jhsware.png","language":"Nix","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nix-infra-test\nThis is a micro cluster setup for testing nix-infra. It is intended to allow you to try out nix-infra with minimal configuration. All you need is a Hetzner account and some super basic configuration.\n\n1. Download [nix-infra](https://github.com/jhsware/nix-infra/releases) and install it\n\n2. Run [this script](https://github.com/jhsware/nix-infra-test/blob/main/scripts/get-test.sh) in the terminal to download test scripts:\n\n```sh\nsh \u003c(curl -L https://raw.githubusercontent.com/jhsware/nix-infra-test/refs/heads/main/scripts/get-test.sh)\n```\n3. Get an API-key for an empty Hetzner Cloud project\n\n4. Edit the .env in the created folder\n\n5. Run the test script\n\n```sh\nnix-infra-test/test-nix-infra-with-apps.sh --env=nix-infra-test/.env\n```\n\nOnce you have set up .env properly, the downloaded script will provision, configure and deploy your cluster. It will then run some tests to check that it is working properly and finish by tearing down the cluster. Copy and modify the script to create your own experimental cluster.\n\n## Test Script Options\n\nTo build without immediately tearing down the cluster:\n\n```sh\ntest-nix-infra-with-apps.sh --no-teardown --env=nix-infra-test/.env\n```\n\nUseful commands to explore the running test cluster (check the bash script for more):\n\n```sh\ntest-nix-infra-with-apps.sh etcd \"/cluster\" --env=nix-infra-test/.env\ntest-nix-infra-with-apps.sh cmd --target=ingress001 \"uptime\" --env=nix-infra-test/.env\ntest-nix-infra-with-apps.sh ssh ingress001 --env=nix-infra-test/.env\n```\n\nTo tear down the cluster:\n\n```sh\ntest-nix-infra-with-apps.sh teardown --env=nix-infra-test/.env\n```\n\n## Node Types\n\n```mermaid\nflowchart\n\ncontrol_node[Control Node]\ncluster_node[Cluster Node]\ningress_node[Ingress Node]\n```\n\nThe control node(s) make up the control plane and handles dynamic cluster state management such as:\n\n- overlay network\n- service mesh\n\nThis allows us to limit interaction to the specific nodes being changed during deployment. The cluster will automatically propagate changes to the other affected nodes in the cluster.\n\nThe worker nodes run databases and applications.\n\nThe ingress node(s) exposes the cluster to the internet.\n\n## Cluster Topology\n\n```mermaid\nflowchart\n\nsubgraph ctrl-plane\ndirection LR\n  etcd001 \u003c--\u003e etcd002 \u003c--\u003e etcd003\nend\n\nctrl-plane \u003c-- TLS --\u003e overlay-network\n\nsubgraph overlay-network\ndirection TB\n  registry001\n  service001\n  worker001\n  ingress001\nend\n```\n\nOrchestration and configuration of the cluster nodes is done over SSH directly to each target node. This allows parallell execution.\n\nThe overlay network is a Flanneld mesh network over a Wireguard encrypted network interface.\n\nServices and applications are exposed over a service mesh through local haproxy loadbalancer. This can provide a fault tolerant setup when you deploy multiple instances of a service or app.\n\n```mermaid\nstateDiagram-v2\n\nctrl_node --\u003e cluster_node : overlay network conf\u003cbr\u003eservice mesh conf\nCLI --\u003e ctrl_node : provision\nCLI --\u003e cluster_node : provision\nCLI --\u003e ctrl_node : deploy\nCLI --\u003e cluster_node : deploy\n\nstate ctrl_node {\n  etcd\n  systemd_ctrl\n  state  \"systemd\" as systemd_ctrl\n}\n\nstate cluster_node {\n  haproxy\n  confd\n  systemd\n  flanneld\n}\n\ncluster_node : cluster_node / ingress_node\n```\n\n## Deploying an Application\nEach node in the cluster has it's own configuration in the `nodes/` folder.\n\nIn this configuration you can configure what apps to run on that node and how you want them to be configured.\n\nThe actual deployment is done using the `deploy-apps` command and specifying the target nodes you want to update. All app configurations or the node will be affected.\n\n### Publish an OCI-Image\nBuild you local image, get the image tag and run:\n```sh\n$ scripts/publish [image_name] [image_tag] registry001\n```\n\nThe image will be uploaded to the private registry and is then available for deployment in your cluster.\n\n### Secrets\nTo securely provide secrets to your application, store them using the CLI `secrets` command or as an output from a CLI `action`command using the option `--store-as-secret=[name]`.\n\nThe secret will be encrypted in your local cluster configuration directory. When deploying an application, the CLI will pass any required secrets to the target and store it as a systemd credential. Systemd credentials are automatically encrypted/decrypted on demand.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhsware%2Fnix-infra-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjhsware%2Fnix-infra-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhsware%2Fnix-infra-test/lists"}