blob: 9c8f5128527b9d8837c0b4a415d18bd4e91f0440 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
{
config,
inputs,
lib,
pkgs,
this,
...
}:
with lib;
let
cfg = config.nixfiles.modules.k3s;
in
{
options.nixfiles.modules.k3s = {
enable = mkEnableOption "K3s";
};
config = mkIf cfg.enable {
assertions = [
{
assertion = cfg.enable -> !config.services.nginx.enable;
message = "NGINX port binding will conflict with a Load Balancer";
}
];
nixfiles.modules.common.shell.aliases = {
h = mkDefault "helm";
k = mkDefault "kubectl";
kns = mkDefault "kubens";
ktx = mkDefault "kubectx";
};
ark.directories = [
"/etc/rancher/k3s"
"/var/lib/rancher/k3s"
];
services.k3s = {
enable = true;
package = pkgs.k3s_1_29;
role = "server";
};
systemd.services.k3s.environment = {
K3S_KUBECONFIG_OUTPUT = "/etc/rancher/k3s/k3s.yaml";
K3S_KUBECONFIG_MODE = "644";
};
networking.firewall = {
trustedInterfaces = [ "cni0" ];
# allowedTCPPorts = [
# 80
# 443
# ];
};
environment.systemPackages = with pkgs; [
kubectx
kubernetes-helm
];
topology = {
nodes.${this.hostname}.services.k3s = {
name = "K3s";
icon = "${inputs.homelab-svg-assets}/assets/k3s.svg";
};
};
};
}
|