update: new urls, and 1 master 1 agent

This commit is contained in:
Michael Thomson
2026-02-24 09:27:08 -05:00
parent b68b96e5c7
commit cf49edab5c
10 changed files with 99 additions and 68 deletions

View File

@@ -5,9 +5,9 @@
```sh ```sh
cd <path to flake> cd <path to flake>
nix run github:nix-community/nixos-anywhere -- --build-on-remote --generate-hardware-config nixos-generate-config ./hosts/patrick/hardware-configuration.nix --flake .#patrick root@192.168.2.100 nix run github:nix-community/nixos-anywhere -- --build-on-remote --generate-hardware-config nixos-generate-config ./hosts/patrick/hardware-configuration.nix --flake .#patrick root@192.168.18.100
nix run github:nix-community/nixos-anywhere -- --build-on-remote --generate-hardware-config nixos-generate-config ./hosts/spongebob/hardware-configuration.nix --flake .#spongebob root@192.168.2.101 nix run github:nix-community/nixos-anywhere -- --build-on-remote --generate-hardware-config nixos-generate-config ./hosts/spongebob/hardware-configuration.nix --flake .#spongebob root@192.168.18.101
nix run github:nix-community/nixos-anywhere -- --build-on-remote --generate-hardware-config nixos-generate-config ./hosts/larry/hardware-configuration.nix --flake .#larry root@192.168.2.42 nix run github:nix-community/nixos-anywhere -- --build-on-remote --generate-hardware-config nixos-generate-config ./hosts/larry/hardware-configuration.nix --flake .#larry root@192.168.18.102
``` ```

View File

@@ -12,6 +12,7 @@
../../modules/k3s.nix ../../modules/k3s.nix
../../modules/nfs.nix ../../modules/nfs.nix
../../modules/longhorn.nix ../../modules/longhorn.nix
../../modules/tailscale.nix
../../modules/nvidia.nix ../../modules/nvidia.nix
]; ];
} }

View File

@@ -8,9 +8,9 @@
[ (modulesPath + "/installer/scan/not-detected.nix") [ (modulesPath + "/installer/scan/not-detected.nix")
]; ];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "sd_mod" ]; boot.initrd.availableKernelModules = [ "nvme" "ahci" "xhci_pci" ];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ]; boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
@@ -18,8 +18,8 @@
# still possible to use this option, but it's recommended to use it in conjunction # still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`. # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true; networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s31f6.useDHCP = lib.mkDefault true; # networking.interfaces.enp38s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
} }

View File

@@ -12,6 +12,7 @@
../../modules/k3s.nix ../../modules/k3s.nix
../../modules/nfs.nix ../../modules/nfs.nix
../../modules/longhorn.nix ../../modules/longhorn.nix
../../modules/tailscale.nix
]; ];
k3s = { k3s = {

View File

@@ -12,5 +12,10 @@
../../modules/k3s.nix ../../modules/k3s.nix
../../modules/nfs.nix ../../modules/nfs.nix
../../modules/longhorn.nix ../../modules/longhorn.nix
../../modules/tailscale.nix
]; ];
k3s = {
role = "agent";
};
} }

View File

@@ -8,9 +8,9 @@
[ (modulesPath + "/installer/scan/not-detected.nix") [ (modulesPath + "/installer/scan/not-detected.nix")
]; ];
boot.initrd.availableKernelModules = [ "nvme" "ahci" "xhci_pci" "usb_storage" "usbhid" "sd_mod" ]; boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "sd_mod" ];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ]; boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
@@ -18,9 +18,8 @@
# still possible to use this option, but it's recommended to use it in conjunction # still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`. # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true; networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp38s0.useDHCP = lib.mkDefault true; # networking.interfaces.enp0s31f6.useDHCP = lib.mkDefault true;
# networking.interfaces.wlo1.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
} }

View File

@@ -13,13 +13,20 @@ in {
default = false; default = false;
description = "Initialize cluster when set to true"; description = "Initialize cluster when set to true";
}; };
role = mkOption {
type = types.str;
default = "server";
};
}; };
config = { config = {
services = { services = {
k3s = { k3s = {
enable = true; enable = true;
role = "server"; role =
if cfg.init
then "server"
else cfg.role;
clusterInit = cfg.init; clusterInit = cfg.init;
serverAddr = serverAddr =
if cfg.init if cfg.init
@@ -29,11 +36,17 @@ in {
if cfg.init if cfg.init
then "" then ""
else meta.k3sToken; else meta.k3sToken;
disable = ["traefik" "servicelb" "local-storage"]; disable =
extraFlags = [ if cfg.init
then ["traefik" "servicelb" "local-storage"]
else [];
extraFlags =
if cfg.init
then [
"--kubelet-arg=allowed-unsafe-sysctls=net.ipv4.*" "--kubelet-arg=allowed-unsafe-sysctls=net.ipv4.*"
"--write-kubeconfig-mode \"0644\"" "--write-kubeconfig-mode \"0644\""
]; ]
else [];
}; };
}; };
}; };

12
modules/tailscale.nix Normal file
View File

@@ -0,0 +1,12 @@
{
config,
pkgs,
...
}: {
services.tailscale = {
enable = true;
useRoutingFeatures = "server";
extraSetFlags = [ "--advertise-exit-node" "--advertise-routes=10.0.0.0/8,192.168.18.0/24" ];
extraUpFlags = [ "--advertise-exit-node" "--advertise-routes=10.0.0.0/8,192.168.18.0/24" ];
};
}

View File

@@ -4,12 +4,12 @@ set -euo pipefail
SSH_USER="root" SSH_USER="root"
declare -A HOSTS=( declare -A HOSTS=(
["patrick"]="192.168.2.100" ["spongebob"]="192.168.18.101"
["spongebob"]="192.168.2.101"
["larry"]="192.168.2.42"
) )
for HOSTNAME in "${!HOSTS[@]}"; do ORDER=("spongebob")
for HOSTNAME in "${ORDER[@]}"; do
IP="${HOSTS[$HOSTNAME]}" IP="${HOSTS[$HOSTNAME]}"
echo "========================================" echo "========================================"