require k8s: swarm services with a pod run in the cluster only
This commit is contained in:
parent
272af0b3e8
commit
57d40ae8ea
1 changed files with 1044 additions and 3125 deletions
|
|
@ -98,40 +98,27 @@ let
|
|||
serverName = if matrixCfg.serverName != null then matrixCfg.serverName else apex;
|
||||
servesMatrixDiscovery = matrixCfg.gatewayHost != null && serverName == apex;
|
||||
|
||||
# How the gateway reaches the controller. Its unix socket by default. With
|
||||
# the controller's TCP listener on, over TLS by the listener's name, with
|
||||
# How the gateway reaches the controller: over TLS by the listener's name, with
|
||||
# the gateway's client leaf — the listener refuses a handshake without it
|
||||
# (./swarm-controller.nix). `controllerDial` is empty on the socket, so the
|
||||
# two locations below render exactly what they rendered before the
|
||||
# listener existed.
|
||||
# (./swarm-controller.nix, which asserts the listener is on).
|
||||
# `toString` below so an unset `domain` reaches the assertion that names it
|
||||
# instead of failing evaluation first.
|
||||
controllerTcp = swarmCfg.controller.tcp;
|
||||
# In the cluster the listener is behind a Service, which the host's resolver
|
||||
# The listener is behind a Service in the cluster, which the host's resolver
|
||||
# answers through the cluster's DNS. The upstream is a variable, so nginx asks
|
||||
# the resolver per request: a name in the `proxy_pass` is looked up when the
|
||||
# configuration loads, which fails the load while the cluster is not up and
|
||||
# keeps the address of a Service that has since been recreated. The name the
|
||||
# certificate is verified as stays `tcp.domain` (`controllerDial`), so the
|
||||
# Service needs no certificate name of its own.
|
||||
controllerOnCluster = deployCfg.swarm-controller.runtime == "k8s";
|
||||
controllerUpstream =
|
||||
if controllerTcp.enable then
|
||||
if controllerOnCluster then
|
||||
"https://$swarm_controller_upstream"
|
||||
else
|
||||
"https://${toString controllerTcp.domain}:${toString controllerTcp.port}"
|
||||
else
|
||||
"http://unix:${deployCfg.swarm-controller.socketPath}:";
|
||||
controllerUpstream = "https://$swarm_controller_upstream";
|
||||
# `proxy_http_version` and `Connection` because `recommendedProxySettings`,
|
||||
# which sets them, is off on a location that pins its own `Host`: without
|
||||
# them nginx speaks HTTP/1.0 to the upstream, which ends the SSE streams'
|
||||
# keep-alive.
|
||||
controllerDial = lib.optionalString controllerTcp.enable ''
|
||||
${lib.optionalString controllerOnCluster ''
|
||||
resolver ${config.services.hyperhive.network.bridgeIp} valid=10s ipv6=off;
|
||||
set $swarm_controller_upstream ${deployCfg.swarm-controller.tcp.serviceHost}:${toString controllerTcp.port};
|
||||
''}
|
||||
controllerDial = ''
|
||||
resolver ${config.services.hyperhive.network.bridgeIp} valid=10s ipv6=off;
|
||||
set $swarm_controller_upstream ${deployCfg.swarm-controller.tcp.serviceHost}:${toString controllerTcp.port};
|
||||
${gatewayCfg.lib.verifiedProxyToWithClientCert (toString controllerTcp.domain) {
|
||||
certificate = deployCfg.swarm-controller.tcp.gatewayClientCertFile;
|
||||
key = deployCfg.swarm-controller.tcp.gatewayClientKeyFile;
|
||||
|
|
@ -139,7 +126,7 @@ let
|
|||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
'';
|
||||
controllerDialAttrs = lib.optionalAttrs controllerTcp.enable {
|
||||
controllerDialAttrs = {
|
||||
# nixpkgs appends its own `Host $host` after `extraConfig`, which would
|
||||
# override the pinned one — see the comment on verifiedProxyTo in
|
||||
# hive-gateway/vhost-lib.nix.
|
||||
|
|
@ -149,7 +136,7 @@ in
|
|||
{
|
||||
# No `enable` of its own: the UI is on wherever
|
||||
# `services.hyperhive.deploy.swarm-controller.enable` is, because it reaches
|
||||
# that daemon over its unix socket, or over its TCP listener when that is on.
|
||||
# that daemon over its TCP listener.
|
||||
# There is no `domain` option: the UI answers on the swarm apex, which the
|
||||
# swarm already declares once.
|
||||
|
||||
|
|
@ -400,7 +387,7 @@ in
|
|||
// {
|
||||
proxyPass = controllerUpstream;
|
||||
}
|
||||
// lib.optionalAttrs controllerTcp.enable {
|
||||
// {
|
||||
extraConfig = controllerDial;
|
||||
};
|
||||
# Swagger UI: same "nginx hosts the themed dist straight from
|
||||
|
|
|
|||
Loading…
Reference in a new issue