This commit is contained in:
alex 2024-01-18 22:49:35 -05:00
parent f2ec867e0e
commit f6d0d58ec1
1 changed files with 41 additions and 28 deletions

View File

@ -21,6 +21,11 @@
# For k3s # For k3s
boot.kernel.sysctl = { "net.ipv4.ip_forward" = 1; }; boot.kernel.sysctl = { "net.ipv4.ip_forward" = 1; };
boot.kernelParams = [
"cgroup_enable=cpuset"
"cgroup_memory=1"
"cgroup_enable=memory"
];
networking.hostName = "nixos-rpi"; # Define your hostname. networking.hostName = "nixos-rpi"; # Define your hostname.
# Pick only one of the below networking options. # Pick only one of the below networking options.
@ -66,36 +71,44 @@
# ${CMD_K3S_EXEC} # ${CMD_K3S_EXEC}
# Adapted from https://get.k3s.io/ # Adapted from https://get.k3s.io/
systemd.services.k3s = { # systemd.services.k3s = {
description = "Lightweight Kubernetes"; # description = "Lightweight Kubernetes";
documentation = [ "https://k3s.io" ]; # documentation = [ "https://k3s.io" ];
serviceConfig = { # serviceConfig = {
Type = "notify"; # Type = "notify";
# EnvironmentFile = "-/etc/default/%N"; # # EnvironmentFile = "-/etc/default/%N";
# EnvironmentFile = "-/etc/sysconfig/%N"; # # EnvironmentFile = "-/etc/sysconfig/%N";
# EnvironmentFile = -${FILE_K3S_ENV}; # # EnvironmentFile = -${FILE_K3S_ENV};
KillMode = "process"; # KillMode = "process";
Delegate = "yes"; # Delegate = "yes";
# Having non-zero Limit*s causes performance problems due to accounting overhead # # Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting. # # in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE = 1048576; # LimitNOFILE = 1048576;
LimitNPROC = "infinity"; # LimitNPROC = "infinity";
LimitCORE = "infinity"; # LimitCORE = "infinity";
TasksMax = "infinity"; # TasksMax = "infinity";
TimeoutStartSec = 0; # TimeoutStartSec = 0;
Restart = "always"; # Restart = "always";
RestartSec = "5 s"; # RestartSec = "5 s";
# ExecStartPre = /bin/sh - xc '! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service 2>/dev/null'; # # ExecStartPre = /bin/sh - xc '! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service 2>/dev/null';
# ExecStartPre = -/sbin/modprobe br_netfilter; # # ExecStartPre = -/sbin/modprobe br_netfilter;
# ExecStartPre = -/sbin/modprobe overlay; # # ExecStartPre = -/sbin/modprobe overlay;
ExecStart = "${pkgs.k3s}/bin/k3s server --write-kubeconfig-mode=644"; # ExecStart = "${pkgs.k3s}/bin/k3s server --write-kubeconfig-mode=644";
}; # };
after = [ "network-online.target" ]; # after = [ "network-online.target" ];
wants = [ "network-online.target" ]; # wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ]; # wantedBy = [ "multi-user.target" ];
}; # };
systemd.services.k3s.enable = true; systemd.services.k3s.enable = true;
services.k3s.role = "server";
services.k3s.extraFlags = toString [
# "--kubelet-arg=v=4" # Optionally add additional args to k3s
];
environment.variables = {
KUBECONFIG = "/home/nixos/.kube/k3s.yaml";
};
# Define a user account. Don't forget to set a password with passwd. # Define a user account. Don't forget to set a password with passwd.
users.users.nixos = { users.users.nixos = {