2021-10-25 12:50:04 +02:00
|
|
|
|
{ config, pkgs, lib, ... }: {
|
|
|
|
|
imports = [
|
|
|
|
|
# Include the results of the hardware scan.
|
|
|
|
|
./hardware-configuration.nix
|
|
|
|
|
];
|
2021-10-17 21:02:20 +02:00
|
|
|
|
|
|
|
|
|
# Use the GRUB 2 boot loader.
|
2022-06-12 12:25:46 +02:00
|
|
|
|
boot.loader.grub = {
|
|
|
|
|
enable = true;
|
|
|
|
|
version = 2;
|
|
|
|
|
device = "/dev/sda";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
boot.kernel.sysctl."fs.inotify.max_user_instances" = 2147483647; # INT_MAX, dynamically limited based on available memory
|
|
|
|
|
boot.kernel.sysctl."fs.inotify.max_user_watches" = 1048576;
|
2021-10-17 21:02:20 +02:00
|
|
|
|
|
|
|
|
|
# This value determines the NixOS release from which the default
|
|
|
|
|
# settings for stateful data, like file locations and database versions
|
|
|
|
|
# on your system were taken. It‘s perfectly fine and recommended to leave
|
|
|
|
|
# this value at the release version of the first install of this system.
|
|
|
|
|
# Before changing this value read the documentation for this option
|
|
|
|
|
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
|
|
|
|
|
system.stateVersion = "21.05"; # Did you read the comment?
|
|
|
|
|
|
|
|
|
|
# Additional packages
|
2021-10-25 12:50:04 +02:00
|
|
|
|
environment.systemPackages = with pkgs; [ iptables vim ];
|
2021-10-17 21:26:38 +02:00
|
|
|
|
|
2021-10-17 23:34:05 +02:00
|
|
|
|
# Disable the firewall as we need all the ports
|
2021-10-17 21:26:38 +02:00
|
|
|
|
networking.firewall.enable = false;
|
|
|
|
|
|
|
|
|
|
# Force-enable Cgroupv2
|
|
|
|
|
systemd.enableUnifiedCgroupHierarchy = lib.mkForce true;
|
|
|
|
|
|
2021-10-17 23:34:05 +02:00
|
|
|
|
# Ensure `mount` and `grep` are available
|
2021-10-17 21:26:38 +02:00
|
|
|
|
systemd.services.k3s.path = [ pkgs.gnugrep pkgs.utillinux ];
|
2022-08-20 10:32:30 +02:00
|
|
|
|
systemd.services.k3s.serviceConfig.TimeoutStartSec = 3000;
|
2021-10-17 21:26:38 +02:00
|
|
|
|
|
2021-10-17 23:34:05 +02:00
|
|
|
|
# Enable k3s as a master node
|
2021-10-17 21:26:38 +02:00
|
|
|
|
services.k3s = {
|
2022-08-25 10:24:31 +02:00
|
|
|
|
enable = true;
|
2021-10-17 23:34:05 +02:00
|
|
|
|
role = "server";
|
|
|
|
|
|
|
|
|
|
extraFlags = builtins.toString [
|
|
|
|
|
"--data-dir=/var/lib/k3s" # Set data dir to var lib
|
|
|
|
|
"--cluster-init" # Enable embedded etcd
|
|
|
|
|
"--disable=servicelb" # disable servicelb
|
|
|
|
|
"--no-deploy=traefik" # we want to configure traefik ourselves (or use nginx instead)
|
2021-10-30 15:59:28 +02:00
|
|
|
|
"--cluster-cidr=10.69.0.0/16" # the default of 10.42.0.0/16 clashes with my own network
|
2021-10-17 23:34:05 +02:00
|
|
|
|
];
|
2021-10-17 21:26:38 +02:00
|
|
|
|
};
|
2021-10-17 21:02:20 +02:00
|
|
|
|
}
|