2023-11-19 01:11:49 +00:00
|
|
|
{
|
|
|
|
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;
|
2023-11-18 10:18:58 +00:00
|
|
|
};
|
|
|
|
|
2023-11-19 01:11:49 +00:00
|
|
|
mkExistingClaim = pvc: subPath: {
|
2023-11-18 10:29:24 +00:00
|
|
|
existingClaim = pvc;
|
|
|
|
inherit subPath;
|
|
|
|
};
|
|
|
|
|
2023-11-19 01:11:49 +00:00
|
|
|
mkSimpleHTTPRoute = namespace: name: port: {
|
2023-11-18 10:08:23 +00:00
|
|
|
service.main.ports.http.port = port;
|
|
|
|
route.main = {
|
2023-11-18 10:10:03 +00:00
|
|
|
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;}];}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2023-11-19 01:11:49 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|