2023-11-19 01:11:49 +00:00
|
|
|
{
|
|
|
|
charts,
|
|
|
|
kubelib,
|
2023-11-19 03:01:30 +00:00
|
|
|
pkgs,
|
2023-11-19 01:11:49 +00:00
|
|
|
vars,
|
|
|
|
}: rec {
|
2023-11-19 03:11:40 +00:00
|
|
|
strToImageAttrs = string:
|
|
|
|
with builtins; let
|
|
|
|
vals = split ":" string;
|
|
|
|
in {
|
|
|
|
repository = elemAt vals 0;
|
|
|
|
tag = elemAt vals 2;
|
|
|
|
};
|
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 =
|
2023-11-19 03:01:30 +00:00
|
|
|
pkgs.lib.attrsets.recursiveUpdate
|
|
|
|
(configVolume
|
|
|
|
// httpRoute
|
|
|
|
// {
|
2023-11-19 03:11:40 +00:00
|
|
|
controllers.main.containers.main.image = strToImageAttrs mainImage;
|
2023-11-19 03:01:30 +00:00
|
|
|
})
|
|
|
|
extraValues;
|
2023-11-19 01:11:49 +00:00
|
|
|
};
|
2023-11-18 10:08:23 +00:00
|
|
|
}
|