This commit is contained in:
ari committed 2024-10-27 21:09:46 -04:00
1 parent 73e98c99f3
commit a320dec5ff
4 files changed
+76

No files matched your search

+1
View File
@@ -8,5 +8,6 @@
./jellyfin.nix
./admin.nix
./arrs
./k8s
];
}
+48
View File
@@ -0,0 +1,48 @@
{ config, pkgs, lib, ... }:
let
cfg = config.skyg.nixos.server.k8s;
in
{
import = [
./master.nix
./node.nix
];
options = {
skyg.nixos.server.k8s = {
enable = lib.mkEnableOption
"Enable K8s";
isMaster = lib.mkEnableOption
"Enable as master";
masterIP = lib.mkOption {
type = lib.types.str;
};
masterHostName = lib.mkOption {
type = lib.types.str;
};
masterAPIPort = lib.mkOption {
type = lib.types.number;
default = 6443;
};
};
};
config = lib.mkIf cfg.enable {
# resolve master hostname
networking.extraHosts = "${cfg.masterIP} ${cfg.masterHostName}";
# packages for administration tasks
environment.systemPackages = with pkgs; [
kompose
kubectl
kubernetes
];
services.kubernetes = {
masterAddress = cfg.masterHostName;
easyCerts = true;
apiserverAddress = "https://${cfg.masterHostName}:${toString cfg.masterAPIPort}";
addons.dns.enable = true;
kubelet.extraOpts = "--fail-swap-on=false";
};
};
}
+15
View File
@@ -0,0 +1,15 @@
{ config, lib, ... }:
let
cfg = config.skyg.nixos.server.k8s;
in
{
config = lib.mkIf (cfg.enable && cfg.isMaster) {
services.kubernetes = {
roles = [ "master" "node" ];
apiserver = {
securePort = cfg.masterAPIPort;
advertiseAddress = cfg.masterIP;
};
};
};
}
+12
View File
@@ -0,0 +1,12 @@
{ config, lib, ... }:
let
cfg = config.skyg.nixos.server.k8s;
in
{
config = lib.mkIf (cfg.enable && (!cfg.isMaster)) {
services.kubernetes = {
roles = [ "node" ];
kubelet.kubeconfig.server = "https://${cfg.masterHostName}:${toString cfg.masterAPIPort}";
};
};
}