All Projects → hugolgst → nixos-raspberry-pi-cluster

hugolgst / nixos-raspberry-pi-cluster

Licence: other
A user-guide to create a Raspberry Pi (3B+, 4) cluster under NixOS and managed by NixOps

Programming Languages

Nix
1067 projects

Projects that are alternatives of or similar to nixos-raspberry-pi-cluster

django-nixos
NixOS/NixOps configuration for Django
Stars: ✭ 21 (-69.57%)
Mutual labels:  nixops, nixos
nixops-tutorial
Tutorial for practical deployments with NixOps
Stars: ✭ 93 (+34.78%)
Mutual labels:  nixops, nixos
Magento-2-aws-cluster-terraform
Magento 2 AWS autoscaling cluster with Terraform and Packer or ImageBuilder. Adobe Commerce Cloud alternative. The best ecommerce infrastructure. Drive more sales online. Transparent billing. Developer-friendly. No hidden bottlenecks.
Stars: ✭ 107 (+55.07%)
Mutual labels:  cluster
docker-volume-hetzner
Docker Volume Plugin for accessing Hetzner Cloud Volumes
Stars: ✭ 81 (+17.39%)
Mutual labels:  cluster
comma
Comma runs software without installing it. [maintainers=@Artturin,@burke,@DavHau]
Stars: ✭ 626 (+807.25%)
Mutual labels:  nixos
Multi-Node-TimescaleDB
The multi-node setup of TimescaleDB 🐯🐯🐯 🐘 🐯🐯🐯
Stars: ✭ 42 (-39.13%)
Mutual labels:  cluster
k3d-action
A GitHub Action to run lightweight ephemeral Kubernetes clusters during workflow. Fundamental advantage of this action is a full customization of embedded k3s clusters. In addition, it provides a private image registry and multi-cluster support.
Stars: ✭ 137 (+98.55%)
Mutual labels:  cluster
fromElisp
An Emacs Lisp reader in Nix.
Stars: ✭ 26 (-62.32%)
Mutual labels:  nixos
k8s-discovery
Auto discover the running environment and serves the kubernetes clientset interface for interaction
Stars: ✭ 44 (-36.23%)
Mutual labels:  cluster
dotfiles
I showed you my source code, pls respond
Stars: ✭ 45 (-34.78%)
Mutual labels:  nixos
terraform-aws-eks-workers
Terraform module to provision an AWS AutoScaling Group, IAM Role, and Security Group for EKS Workers
Stars: ✭ 82 (+18.84%)
Mutual labels:  cluster
soa-checklist
Microservice Oriented Architecture checklist
Stars: ✭ 92 (+33.33%)
Mutual labels:  cluster
caddy-tlsconsul
🔒 Consul K/V storage for Caddy Web Server / Certmagic TLS data
Stars: ✭ 89 (+28.99%)
Mutual labels:  cluster
clusterhat-image
Converts Raspbian/Raspberry Pi OS images to support Cluster HAT
Stars: ✭ 71 (+2.9%)
Mutual labels:  cluster
node-codis
Codis client for Node.js.
Stars: ✭ 18 (-73.91%)
Mutual labels:  cluster
urb-k8s
Kubernetes adapter for Universal Resource Broker
Stars: ✭ 19 (-72.46%)
Mutual labels:  cluster
gradle2nix
Generate Nix expressions which build Gradle-based projects.
Stars: ✭ 71 (+2.9%)
Mutual labels:  nixos
nix-gaming
Gaming on Nix
Stars: ✭ 142 (+105.8%)
Mutual labels:  nixos
ha cluster exporter
Prometheus exporter for Pacemaker based Linux HA clusters
Stars: ✭ 63 (-8.7%)
Mutual labels:  cluster
nixconfig
My NixOS config
Stars: ✭ 67 (-2.9%)
Mutual labels:  nixos

nixos-raspberry-pi-cluster

A user-guide to create a Raspberry Pi (3B+, 4) cluster under NixOS and managed by NixOps.

In this guide, the nodes are all connected to a VPN server using Wireguard.

Table of contents

  1. Installation
    1. Booting the Raspberry Pis
    2. First viable configuration
  2. NixOps deployment
    1. Install NixOps
    2. Create the deployment
    3. Deploy the configurations

Installation

Booting the Raspberry Pis

4

For the Raspberry Pi 4, a Hydra job build a SD Image for it. You can find the job here, just pick the latest successful job and download the image.

3B+

In order to boot NixOS on a Raspberry Pi 3B+ you'll have to build your own image. Find its Nix expression at rpi3B+/sd-image.nix

First of all, if your main computer is not ARM-based, you have to emulate ARM on your system.

  1. Add the following parameter to your NixOS configuration:
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];

Then make sure to rebuild your system via nixos-rebuild switch

  1. You can now build the image via this command (which might take a while depending on your computer)
nix-build '<nixpkgs/nixos>' -A config.system.build.sdImage --argstr system aarch64-linux -I nixos-config=sd-image.nix

You might find useful information on this wiki post.

Uncompress the image and flash it

  1. The image created will be compressed with the zst format, to decompress it use:
nix-shell -p zstd --run "unzstd nixos-sd-image-20.09pre242769.61525137fd1-aarch64-linux.img.zst
  1. You can now flash the image to your SD card! Example with dd:
dd bs=4M if=nixos-sd-image-21.03pre262561.581232454fd-aarch64-linux.img of=/dev/mmcblk0 conv=fsync

Booting

Then, plug a keyboard and a screen via the HDMI/micro-HDMI ports.

To connect it to internet, either plug a Ethernet cable or connect to the wifi with:

wpa_supplicant -B -i wlan0 -c <(wpa_passphrase 'SSID' 'password')

First viable configuration

After booting on the Raspberry Pi, generate the configuration via:

nixos-generate-configuration

4

Then, you can pull the default configuration

curl https://raw.githubusercontent.com/hugolgst/nixos-raspberry-pi-cluster/master/rpi4/default-configuration.nix > /etc/nixos/configuration.nix

3B+

After successfully booting your RPI3B+, you have to pull the default configuration file in /etc/nixos/configuration.nix

curl https://raw.githubusercontent.com/hugolgst/nixos-raspberry-pi-cluster/master/rpi3B%2B/default-configuration.nix > /etc/nixos/configuration.nix

Rebuild

Then tweak the configuration file as you want and rebuild/reboot the system

nixos-rebuild switch
reboot

NixOps deployment

To manage the Raspberry Pi cluster, we can use NixOps.

Install NixOps

First of all make sure to have it installed on your system:

nix-env -iA nixos.nixops

or

nix-shell -p nixops

or add it to your system packages in /etc/nixos/configuration.nix.

Create the deployment

Create the deployment using this command

nixops create nixops/cluster.nix -d <your-deployment-name>

Then you can list all your deployments and check if yours is present with:

nixops list

To have more information about the commands available and the tool in general, check the manual.

Make sure to have your ssh public key in the root authorized keys!

users.extraUsers.root.openssh.authorizedKeys.keys = [
  "ssh-rsa ... host"
];

Deploy the configurations

You can tweak the configuration(s) in nixops/cluster.nix and the nixops/ files as you want.

In order to deploy the configuration you can use the deploy tag.

nixops deploy -d <your-deployment-name>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].