cluster/services/ways: support buckets

This commit is contained in:
Max Headroom 2024-07-07 23:38:56 +02:00
parent 7570369072
commit 4cacd03afb
2 changed files with 16 additions and 3 deletions

View file

@ -1,12 +1,18 @@
{ lib, depot, ... }:
{ config, lib, depot, ... }:
{
options.ways = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule {
type = lib.types.attrsOf (lib.types.submodule ({ options, ... }: {
imports = [ ./way.nix ];
domainSuffixExternal = depot.lib.meta.domain;
domainSuffixInternal = "internal.${depot.lib.meta.domain}";
});
extras = lib.mkIf options.bucket.isDefined {
locations."/".extraConfig = ''
proxy_set_header Host "${options.bucket.value}.${config.links.garageWeb.hostname}";
'';
};
}));
default = {};
};
}

View file

@ -48,6 +48,10 @@ with lib;
type = types.str;
};
bucket = mkOption {
type = types.str;
};
healthCheckPath = mkOption {
type = types.path;
default = "/.well-known/ways/internal-health-check";
@ -93,5 +97,8 @@ with lib;
nginxUpstreamName = "ways_upstream_${builtins.hashString "md5" options.consulService.value}";
target = "http://${options.nginxUpstreamName.value}";
})
(lib.mkIf options.bucket.isDefined {
consulService = "garage-web";
})
];
}