2024-10-28 15:05:06 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
ingressOpts = {name, ...}: {
|
2024-09-07 10:35:02 +00:00
|
|
|
options = {
|
|
|
|
host = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
entrypoint = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
default = "websecure";
|
|
|
|
};
|
|
|
|
|
|
|
|
service = {
|
|
|
|
name = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
portName = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-10-28 15:05:06 +00:00
|
|
|
in {
|
2024-09-07 10:35:02 +00:00
|
|
|
options = {
|
|
|
|
lab.ingresses = lib.mkOption {
|
|
|
|
type = with lib.types; attrsOf (submodule ingressOpts);
|
2024-10-28 15:05:06 +00:00
|
|
|
default = {};
|
2024-09-07 10:35:02 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
2024-10-28 15:05:06 +00:00
|
|
|
kubernetes.resources.ingresses =
|
|
|
|
builtins.mapAttrs
|
2024-09-07 10:35:02 +00:00
|
|
|
(name: ingress: {
|
|
|
|
metadata.annotations = {
|
|
|
|
"cert-manager.io/cluster-issuer" = "letsencrypt";
|
|
|
|
"traefik.ingress.kubernetes.io/router.entrypoints" = ingress.entrypoint;
|
|
|
|
};
|
|
|
|
|
|
|
|
spec = {
|
|
|
|
ingressClassName = "traefik";
|
|
|
|
|
2024-10-28 15:05:06 +00:00
|
|
|
rules = [
|
|
|
|
{
|
|
|
|
host = ingress.host;
|
2024-09-07 10:35:02 +00:00
|
|
|
|
2024-10-28 15:05:06 +00:00
|
|
|
http.paths = [
|
|
|
|
{
|
|
|
|
path = "/";
|
|
|
|
pathType = "Prefix";
|
2024-09-07 10:35:02 +00:00
|
|
|
|
2024-10-28 15:05:06 +00:00
|
|
|
backend.service = {
|
|
|
|
name = ingress.service.name;
|
|
|
|
port.name = ingress.service.portName;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
2024-09-07 10:35:02 +00:00
|
|
|
|
2024-10-28 15:05:06 +00:00
|
|
|
tls = [
|
|
|
|
{
|
|
|
|
secretName = "${name}-tls";
|
|
|
|
hosts = [ingress.host];
|
|
|
|
}
|
|
|
|
];
|
2024-09-07 10:35:02 +00:00
|
|
|
};
|
|
|
|
})
|
|
|
|
config.lab.ingresses;
|
|
|
|
};
|
|
|
|
}
|