1
0
Fork 0
mirror of https://git.sr.ht/~goorzhel/turboprop synced 2024-12-14 11:37:37 +00:00
turboprop/lib/app-template.nix

69 lines
1.5 KiB
Nix
Raw Normal View History

{
charts,
kubelib,
vars,
}: rec {
mkMainImage = repository: tag: {
# I get "tag" and "version" confused a lot, so
# it's better not to mind the attribute names.
inherit repository tag;
};
mkExistingClaim = pvc: subPath: {
2023-11-18 10:29:24 +00:00
existingClaim = pvc;
inherit subPath;
};
mkSimpleHTTPRoute = namespace: name: port: {
2023-11-18 10:08:23 +00:00
service.main.ports.http.port = port;
route.main = {
enabled = true;
2023-11-18 22:16:53 +00:00
hostnames = ["${name}.${vars.svcGateway.domain}"];
2023-11-18 10:08:23 +00:00
parentRefs = [
{
inherit namespace;
2023-11-18 22:16:53 +00:00
name = vars.svcGateway.name;
2023-11-18 10:08:23 +00:00
sectionName = "https";
}
];
rules = [
{backendRefs = [{inherit name namespace port;}];}
];
};
};
appTemplate = {
namespace,
name,
mainImage,
nfsConfigVolume ? false,
httpPort ? false,
extraValues ? {},
}: let
configVolume = {
persistence.config =
if nfsConfigVolume
then mkExistingClaim "svc" name
else
# TODO: There' room here to chain other types, like
# if longhornVolume then {...} else ...
{};
};
httpRoute =
if httpPort != false
then mkSimpleHTTPRoute namespace name httpPort
else {};
in
kubelib.buildHelmChart {
inherit name namespace;
chart = charts.bjw-s.app-template;
values =
configVolume
// httpRoute
// extraValues
// {
controllers.main.containers.main.image = mainImage;
};
};
2023-11-18 10:08:23 +00:00
}