infra/homelab/endpoints.nix

93 lines
2.1 KiB
Nix

let
endpoints = {
"proxmox" = {
location = "192.168.50.3";
host = "proxmox.gmem.ca";
port = 8006;
protocol = "HTTPS";
};
"austin" = {
location = "192.168.50.237";
host = "austin.gmem.ca";
port = 8080;
protocol = "HTTP";
};
"tokyo" = {
location = "192.168.50.124";
host = "tokyo.gmem.ca";
port = 8000;
protocol = "HTTP";
};
"ibiza" = {
location = "192.168.50.182";
host = "ibiza.gmem.ca";
port = 8000;
protocol = "HTTP";
};
};
in {
kubernetes.resources.services =
builtins.mapAttrs (name: endpoint: {
metadata.namespace = "endpoints";
spec = {
ports.${name} = {
port = endpoint.port;
targetPort = endpoint.port;
};
};
})
endpoints;
kubernetes.resources.endpoints =
builtins.mapAttrs (name: endpoint: {
metadata.namespace = "endpoints";
subsets = [
{
addresses = [{ip = endpoint.location;}];
ports = [
{
name = name;
port = endpoint.port;
protocol = "TCP";
}
];
}
];
})
endpoints;
kubernetes.resources.ingresses =
builtins.mapAttrs (name: endpoint: {
metadata = {
name = name;
namespace = "endpoints";
annotations = {
"nginx.ingress.kubernetes.io/proxy-body-size" = "10g";
"cert-manager.io/cluser-issuer" = "le-issuer";
"nginx.ingress.kubernetes.io/backend-protocol" = endpoint.protocol;
};
};
spec = {
tls = [
{
hosts = [endpoint.host];
}
];
rules = [
{
host = endpoint.host;
http.paths = [
{
path = "/";
pathType = "Prefix";
backend.service = {
name = name;
port.number = endpoint.port;
};
}
];
}
];
};
})
endpoints;
}