nixos-servers/kubenix-modules/custom/tailscale.nix
Pim Kunis d3d6abdde8 feat: Rollout tailscale for media stack
fix: Add default for tailscale ingress option
2024-07-21 21:00:32 +02:00

52 lines
1.1 KiB
Nix

{ lib, config, ... }: {
options = with lib.types; {
lab.tailscaleIngresses = lib.mkOption {
type = attrsOf (submodule {
options = {
host = lib.mkOption { type = str; };
service = {
name = lib.mkOption { type = str; };
portName = lib.mkOption {
type = str;
default = "web";
};
};
};
});
default = { };
};
};
config =
let
cfg = config.lab.tailscaleIngresses;
mkTailscaleIngress = name: { host, service }: {
spec = {
ingressClassName = "tailscale";
rules = [{
http.paths = [{
path = "/";
pathType = "Prefix";
backend.service = {
name = service.name;
port.name = service.portName;
};
}];
}];
tls = [{
hosts = [ host ];
}];
};
};
in
{
kubernetes.resources.ingresses = builtins.mapAttrs mkTailscaleIngress cfg;
};
}