infrastructure/nixos/hosts/k3s/configuration.nix

48 lines
1.6 KiB
Nix
Raw Normal View History

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.
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
boot.loader.grub.device = "/dev/sda";
networking.hostName = "k3s-node1";
# 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. Its 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 ];
2021-10-17 23:34:05 +02:00
# Enable k3s as a master node
2021-10-17 21:26:38 +02:00
services.k3s = {
2021-10-17 23:34:05 +02:00
enable = true;
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
}