Set static IPs for k3s nodes
This commit is contained in:
parent
3e68a6efd5
commit
f2191a73b1
2 changed files with 20 additions and 17 deletions
35
flake.nix
35
flake.nix
|
@ -36,16 +36,14 @@
|
|||
] ++ extraModules;
|
||||
};
|
||||
|
||||
makeK3sConfig = { hostname, serverIp ? null }:
|
||||
makeK3sConfig = { hostname, selfIp, serverIp ? null }:
|
||||
with image-builder.packages.aarch64-linux.modules;
|
||||
let
|
||||
device = "/dev/mapper/cryptdrive1";
|
||||
mountDir = "/btrfs/nvme";
|
||||
subvolumes = [
|
||||
"@var"
|
||||
"@var-lib"
|
||||
"@var-lib-rancher"
|
||||
"@var-log"
|
||||
# "@var-lib-rancher"
|
||||
# "@var-log-pods"
|
||||
];
|
||||
in
|
||||
makeConfig {
|
||||
|
@ -66,6 +64,17 @@
|
|||
({ config, ... }: {
|
||||
services.lvm.enable = true;
|
||||
|
||||
networking = {
|
||||
interfaces.end0.ipv4.addresses = [
|
||||
{
|
||||
address = selfIp;
|
||||
prefixLength = 24;
|
||||
}
|
||||
];
|
||||
defaultGateway = "192.168.20.1";
|
||||
nameservers = [ "192.168.20.21" "192.168.20.1" ];
|
||||
};
|
||||
|
||||
sops.secrets.k3sKeyFile = {
|
||||
format = "binary";
|
||||
sopsFile = ./secrets/k3sKeyFile.bin;
|
||||
|
@ -85,25 +94,15 @@
|
|||
fsType = "btrfs";
|
||||
options = [ "defaults" "rw" "compress=zstd" ];
|
||||
};
|
||||
"/var" = {
|
||||
inherit device;
|
||||
fsType = "btrfs";
|
||||
options = [ "defaults" "rw" "compress=zstd" "subvol=@var" ];
|
||||
};
|
||||
"/var/lib" = {
|
||||
inherit device;
|
||||
fsType = "btrfs";
|
||||
options = [ "defaults" "rw" "compress=zstd" "subvol=@var-lib" ];
|
||||
};
|
||||
"/var/lib/rancher" = {
|
||||
inherit device;
|
||||
fsType = "btrfs";
|
||||
options = [ "defaults" "rw" "compress=zstd" "subvol=@var-lib-rancher" ];
|
||||
};
|
||||
"/var/log" = {
|
||||
"/var/log/pods" = {
|
||||
inherit device;
|
||||
fsType = "btrfs";
|
||||
options = [ "defaults" "rw" "compress=zstd" "subvol=@var-log" ];
|
||||
options = [ "defaults" "rw" "compress=zstd" "subvol=@var-log-pods" ];
|
||||
};
|
||||
};
|
||||
})
|
||||
|
@ -268,10 +267,12 @@
|
|||
|
||||
k3s1 = makeK3sConfig {
|
||||
hostname = "k3s1";
|
||||
selfIp = "192.168.20.120";
|
||||
};
|
||||
|
||||
k3s2 = makeK3sConfig {
|
||||
hostname = "k3s2";
|
||||
selfIp = "192.168.20.121";
|
||||
serverIp = "192.168.20.120";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
environment.systemPackages = with pkgs; [
|
||||
bottom
|
||||
cryptsetup
|
||||
git
|
||||
htop
|
||||
neovim
|
||||
];
|
||||
|
||||
sops = {
|
||||
|
|
Loading…
Reference in a new issue