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
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.
# Pick only one of the below networking options.
@ -66,36 +71,44 @@
# ${CMD_K3S_EXEC}
# Adapted from https://get.k3s.io/
systemd.services.k3s = {
description = "Lightweight Kubernetes";
documentation = [ "https://k3s.io" ];
serviceConfig = {
Type = "notify";
# EnvironmentFile = "-/etc/default/%N";
# EnvironmentFile = "-/etc/sysconfig/%N";
# EnvironmentFile = -${FILE_K3S_ENV};
KillMode = "process";
Delegate = "yes";
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE = 1048576;
LimitNPROC = "infinity";
LimitCORE = "infinity";
TasksMax = "infinity";
TimeoutStartSec = 0;
Restart = "always";
RestartSec = "5 s";
# 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 overlay;
ExecStart = "${pkgs.k3s}/bin/k3s server --write-kubeconfig-mode=644";
};
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
};
# systemd.services.k3s = {
# description = "Lightweight Kubernetes";
# documentation = [ "https://k3s.io" ];
# serviceConfig = {
# Type = "notify";
# # EnvironmentFile = "-/etc/default/%N";
# # EnvironmentFile = "-/etc/sysconfig/%N";
# # EnvironmentFile = -${FILE_K3S_ENV};
# KillMode = "process";
# Delegate = "yes";
# # Having non-zero Limit*s causes performance problems due to accounting overhead
# # in the kernel. We recommend using cgroups to do container-local accounting.
# LimitNOFILE = 1048576;
# LimitNPROC = "infinity";
# LimitCORE = "infinity";
# TasksMax = "infinity";
# TimeoutStartSec = 0;
# Restart = "always";
# RestartSec = "5 s";
# # 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 overlay;
# ExecStart = "${pkgs.k3s}/bin/k3s server --write-kubeconfig-mode=644";
# };
# after = [ "network-online.target" ];
# wants = [ "network-online.target" ];
# wantedBy = [ "multi-user.target" ];
# };
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.
users.users.nixos = {