@rocket.chat/houston 0.27.0-next.3 → 2.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +109 -15
- package/bin/houston +62 -0
- package/data/docs/ARCHITECTURE.md +387 -0
- package/data/docs/automation.md +107 -0
- package/data/docs/e2ee.md +76 -0
- package/data/docs/eks.md +258 -0
- package/data/docs/gui.md +282 -0
- package/data/docs/guide.md +642 -0
- package/data/docs/kubernetes.md +138 -0
- package/data/docs/loadtest.md +264 -0
- package/data/docs/troubleshooting.md +203 -0
- package/data/docs/upgrading.md +84 -0
- package/data/docs/voice.md +253 -0
- package/data/iam/engineer-policy.json +11 -0
- package/data/iam/engineer-rbac.yaml +42 -0
- package/data/iam/operator-policy.json +211 -0
- package/data/loadtest/badbot.js +22 -0
- package/data/loadtest/common.js +170 -0
- package/data/loadtest/custom.js +20 -0
- package/data/loadtest/journey.js +58 -0
- package/data/loadtest/login.js +18 -0
- package/data/loadtest/messages.js +13 -0
- package/data/loadtest/mixed.js +57 -0
- package/data/loadtest/read.js +12 -0
- package/data/loadtest/webhook.js +20 -0
- package/data/monitoring/houston-logs.json +98 -0
- package/data/monitoring/k6-loadtest.json +610 -0
- package/data/monitoring/mongodb-exporter.json +3007 -0
- package/data/monitoring/node-exporter-full.json +16114 -0
- package/data/monitoring/rocketchat-metrics.json +6471 -0
- package/data/presets/airgapped.yaml +16 -0
- package/data/presets/default.yaml +9 -0
- package/data/seed/avatar-0.png +0 -0
- package/data/seed/avatar-1.png +0 -0
- package/data/seed/avatar-2.png +0 -0
- package/data/seed/avatar-3.png +0 -0
- package/data/seed/avatar-4.png +0 -0
- package/data/seed/avatar-5.png +0 -0
- package/data/seed/avatar-6.png +0 -0
- package/data/seed/avatar-7.png +0 -0
- package/data/seed/seed-metrics.csv +3 -0
- package/data/seed/seed-preview.png +0 -0
- package/data/seed/seed-report.pdf +32 -0
- package/data/seed/seed-runbook.txt +3 -0
- package/data/skill/SKILL.md +399 -0
- package/data/versions.yaml +55 -0
- package/data/voice/freeswitch/drachtio.xml +52 -0
- package/data/voice/freeswitch/public.xml +87 -0
- package/data/webui/app.css +2003 -0
- package/data/webui/index.html +678 -0
- package/data/webui/js/api.js +561 -0
- package/data/webui/js/boot.js +44 -0
- package/data/webui/js/clusters-tail.js +1377 -0
- package/data/webui/js/clusters.js +896 -0
- package/data/webui/js/create.js +276 -0
- package/data/webui/js/detail.js +507 -0
- package/data/webui/js/jobs.js +636 -0
- package/data/webui/js/logs.js +634 -0
- package/data/webui/js/main.js +14 -0
- package/data/webui/js/options.js +408 -0
- package/data/webui/js/people.js +438 -0
- package/data/webui/js/perf.js +303 -0
- package/data/webui/js/render.js +438 -0
- package/data/webui/js/shared.js +3 -0
- package/data/webui/js/state.js +583 -0
- package/data/webui/js/theme.js +123 -0
- package/data/webui/js/util.js +584 -0
- package/dist/cli/app.js +593 -0
- package/dist/cli/capabilities.js +76 -0
- package/dist/cli/cell-widths.js +495 -0
- package/dist/cli/entry.js +10 -0
- package/dist/cli/error-panel.js +492 -0
- package/dist/cli/handlers/actor.js +84 -0
- package/dist/cli/handlers/https.js +614 -0
- package/dist/cli/handlers/prompt.js +299 -0
- package/dist/cli/handlers/users.js +226 -0
- package/dist/cli/handlers.js +3694 -0
- package/dist/cli/help.js +183 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/perf.js +814 -0
- package/dist/cli/render.js +254 -0
- package/dist/cli/serve.js +858 -0
- package/dist/cli/spec-data.js +2599 -0
- package/dist/cli/spec-types.js +8 -0
- package/dist/cli/usage-error.js +520 -0
- package/dist/cli/wire.js +70 -0
- package/dist/core/audit.js +346 -0
- package/dist/core/backup-compat.js +85 -0
- package/dist/core/backup.js +1639 -0
- package/dist/core/cluster.js +1398 -0
- package/dist/core/configimport.js +345 -0
- package/dist/core/data.js +267 -0
- package/dist/core/database-of.js +82 -0
- package/dist/core/diagnose.js +159 -0
- package/dist/core/doctor.js +1518 -0
- package/dist/core/edge/acme.js +338 -0
- package/dist/core/edge/engine.js +500 -0
- package/dist/core/edge/networks.js +174 -0
- package/dist/core/edge/paths.js +107 -0
- package/dist/core/edge/routes.js +251 -0
- package/dist/core/edge/routeyml.js +195 -0
- package/dist/core/edge/runtime.js +493 -0
- package/dist/core/edge/spec.js +305 -0
- package/dist/core/edge/types.js +202 -0
- package/dist/core/eks-docs.js +135 -0
- package/dist/core/eks.js +2240 -0
- package/dist/core/envvars.js +562 -0
- package/dist/core/eventlog.js +541 -0
- package/dist/core/firstrun.js +153 -0
- package/dist/core/journal.js +694 -0
- package/dist/core/kube/ask.js +231 -0
- package/dist/core/kube/capabilities.js +269 -0
- package/dist/core/kube/certmanager.js +452 -0
- package/dist/core/kube/chart.js +413 -0
- package/dist/core/kube/cluster.js +196 -0
- package/dist/core/kube/context.js +545 -0
- package/dist/core/kube/endpoints.js +448 -0
- package/dist/core/kube/exec.js +195 -0
- package/dist/core/kube/forward.js +732 -0
- package/dist/core/kube/grafana-ingress.js +110 -0
- package/dist/core/kube/ingress.js +218 -0
- package/dist/core/kube/manifests.js +361 -0
- package/dist/core/kube/monitoring.js +768 -0
- package/dist/core/kube/names.js +237 -0
- package/dist/core/kube/namespace.js +678 -0
- package/dist/core/kube/operator.js +941 -0
- package/dist/core/kube/probe.js +202 -0
- package/dist/core/kube/reachability.js +163 -0
- package/dist/core/kube/release.js +439 -0
- package/dist/core/kube/replicaset.js +180 -0
- package/dist/core/kube/scale.js +398 -0
- package/dist/core/kube/status.js +633 -0
- package/dist/core/kube/tools.js +238 -0
- package/dist/core/kube/transfer.js +173 -0
- package/dist/core/kube/workspace.js +423 -0
- package/dist/core/lifecycle/admin.js +64 -0
- package/dist/core/lifecycle/create-docker.js +1549 -0
- package/dist/core/lifecycle/create-k8s.js +960 -0
- package/dist/core/lifecycle/destroy.js +339 -0
- package/dist/core/lifecycle/inspect.js +636 -0
- package/dist/core/lifecycle/naming.js +298 -0
- package/dist/core/lifecycle/notes.js +862 -0
- package/dist/core/lifecycle/ownership.js +313 -0
- package/dist/core/lifecycle/payload.js +401 -0
- package/dist/core/lifecycle/ports.js +388 -0
- package/dist/core/lifecycle/preconditions.js +367 -0
- package/dist/core/lifecycle/pruning.js +551 -0
- package/dist/core/lifecycle/ready.js +818 -0
- package/dist/core/lifecycle/request.js +510 -0
- package/dist/core/lifecycle/seeding.js +281 -0
- package/dist/core/lifecycle/sizing.js +392 -0
- package/dist/core/lifecycle/state.js +286 -0
- package/dist/core/lifecycle/tlsplan.js +704 -0
- package/dist/core/lifecycle/types.js +232 -0
- package/dist/core/loadtest.js +1051 -0
- package/dist/core/migrate.js +612 -0
- package/dist/core/monitor.js +494 -0
- package/dist/core/postready.js +976 -0
- package/dist/core/promote.js +804 -0
- package/dist/core/rcapi.js +1336 -0
- package/dist/core/recovery.js +75 -0
- package/dist/core/runner/engine.js +394 -0
- package/dist/core/runner/host.js +298 -0
- package/dist/core/runner/locks.js +129 -0
- package/dist/core/runner/paths.js +173 -0
- package/dist/core/runner/ports.js +172 -0
- package/dist/core/runner/queries.js +612 -0
- package/dist/core/runner/record.js +563 -0
- package/dist/core/scaleseed.js +271 -0
- package/dist/core/seed-db.js +208 -0
- package/dist/core/sessions.js +472 -0
- package/dist/core/skill.js +326 -0
- package/dist/core/sso-identities.js +172 -0
- package/dist/core/sso.js +703 -0
- package/dist/core/tls-local.js +311 -0
- package/dist/core/tls.js +878 -0
- package/dist/core/topology.js +482 -0
- package/dist/core/upgrade.js +877 -0
- package/dist/core/users.js +739 -0
- package/dist/lib/audit.js +100 -0
- package/dist/lib/close-matches.js +238 -0
- package/dist/lib/compose.js +672 -0
- package/dist/lib/config.js +1398 -0
- package/dist/lib/context.js +18 -0
- package/dist/lib/errors.js +305 -0
- package/dist/lib/events.js +208 -0
- package/dist/lib/float-text.js +126 -0
- package/dist/lib/format.js +1320 -0
- package/dist/lib/home.js +325 -0
- package/dist/lib/journal.js +122 -0
- package/dist/lib/json-text.js +733 -0
- package/dist/lib/jsonout.js +382 -0
- package/dist/lib/lock.js +516 -0
- package/dist/lib/login-name.js +202 -0
- package/dist/lib/map-limit.js +29 -0
- package/dist/lib/mkdir-parents.js +90 -0
- package/dist/lib/mongo-kernel.js +67 -0
- package/dist/lib/monitoring.js +492 -0
- package/dist/lib/platform-name.js +59 -0
- package/dist/lib/presets/common.js +390 -0
- package/dist/lib/presets/composite.js +326 -0
- package/dist/lib/presets/e2ee.js +143 -0
- package/dist/lib/presets/email.js +172 -0
- package/dist/lib/presets/guides.js +27 -0
- package/dist/lib/presets/index.js +490 -0
- package/dist/lib/presets/keycloak.js +371 -0
- package/dist/lib/presets/ldap.js +1285 -0
- package/dist/lib/presets/livechat.js +220 -0
- package/dist/lib/presets/multi-instance.js +124 -0
- package/dist/lib/presets/oidc.js +161 -0
- package/dist/lib/presets/public.js +496 -0
- package/dist/lib/presets/registry.js +64 -0
- package/dist/lib/presets/s3-minio.js +300 -0
- package/dist/lib/presets/saml.js +149 -0
- package/dist/lib/presets/scenario.js +51 -0
- package/dist/lib/presets/types.js +86 -0
- package/dist/lib/presets/voice-pbx.js +320 -0
- package/dist/lib/presets/voice.js +345 -0
- package/dist/lib/presets/webhooks.js +182 -0
- package/dist/lib/redact.js +106 -0
- package/dist/lib/seed-options.js +68 -0
- package/dist/lib/seed-profiles.js +59 -0
- package/dist/lib/targz.js +1383 -0
- package/dist/lib/teammode.js +25 -0
- package/dist/lib/tempdir.js +162 -0
- package/dist/lib/unicode-tables.js +2335 -0
- package/dist/lib/version-spec.js +357 -0
- package/dist/lib/versions.js +463 -0
- package/dist/lib/yaml-dump.js +1361 -0
- package/dist/perf/baseline.js +168 -0
- package/dist/perf/constrain.js +299 -0
- package/dist/perf/k6.js +235 -0
- package/dist/perf/mongoprof.js +171 -0
- package/dist/perf/rcmetrics.js +191 -0
- package/dist/perf/report.js +386 -0
- package/dist/perf/resources.js +236 -0
- package/dist/perf/slo.js +111 -0
- package/dist/perf/timeline.js +187 -0
- package/dist/perf/timings.js +85 -0
- package/dist/perf/verdict.js +201 -0
- package/dist/seams/aws-cli.js +126 -0
- package/dist/seams/docker-cli.js +280 -0
- package/dist/seams/exec.js +861 -0
- package/dist/seams/fs/lock.js +528 -0
- package/dist/seams/kubectl.js +83 -0
- package/dist/seams/rc-http.js +921 -0
- package/dist/seed/apply.js +190 -0
- package/dist/seed/assets.js +76 -0
- package/dist/seed/check.js +391 -0
- package/dist/seed/client.js +172 -0
- package/dist/seed/executor.js +726 -0
- package/dist/seed/history.js +281 -0
- package/dist/seed/kinds.js +91 -0
- package/dist/seed/plan.js +432 -0
- package/dist/seed/receipt.js +339 -0
- package/dist/seed/repairs.js +75 -0
- package/dist/seed/verification.js +363 -0
- package/dist/seed/wording.js +248 -0
- package/dist/web/app.js +326 -0
- package/dist/web/jobs.js +510 -0
- package/dist/web/route-deps.js +211 -0
- package/dist/web/route-table.js +213 -0
- package/dist/web/routes/backup.js +244 -0
- package/dist/web/routes/clusters.js +303 -0
- package/dist/web/routes/data.js +187 -0
- package/dist/web/routes/edge.js +82 -0
- package/dist/web/routes/index.js +63 -0
- package/dist/web/routes/jobs.js +95 -0
- package/dist/web/routes/logs.js +297 -0
- package/dist/web/routes/meta.js +191 -0
- package/dist/web/routes/people.js +151 -0
- package/dist/web/routes/perf.js +95 -0
- package/dist/web/routes/repros.js +550 -0
- package/dist/web/routes/session.js +361 -0
- package/dist/web/routes/spa.js +198 -0
- package/dist/web/security.js +475 -0
- package/dist/web/signin.js +246 -0
- package/package.json +70 -32
- package/.eslintrc +0 -94
- package/.swcrc +0 -18
- package/dist/bin.js +0 -3
- package/dist/cli.js +0 -184
- package/dist/commands/createBranch.js +0 -194
- package/dist/outputCI.js +0 -59
- package/src/bin.js +0 -4
- package/src/cli.ts +0 -25
- package/src/commands/createBranch.ts +0 -28
- package/src/outputCI.ts +0 -12
- package/src-old/logs.js +0 -323
- package/src-old/md.js +0 -191
- package/src-old/release-table.js +0 -60
- package/src-old/set-version.js +0 -614
- package/src-old/utils.js +0 -15
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Where the edge's files live, and the two shapes read back out of them.
|
|
4
|
+
*
|
|
5
|
+
* Tier 0 of `src/core/edge/`. The package keeps its established tiering, which cannot
|
|
6
|
+
* import upward:
|
|
7
|
+
*
|
|
8
|
+
* paths, types -> engine -> acme, networks -> routeyml -> spec -> routes -> runtime
|
|
9
|
+
*/
|
|
10
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}) : (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
o[k2] = m[k];
|
|
20
|
+
}));
|
|
21
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
+
}) : function(o, v) {
|
|
24
|
+
o["default"] = v;
|
|
25
|
+
});
|
|
26
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
27
|
+
var ownKeys = function(o) {
|
|
28
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
29
|
+
var ar = [];
|
|
30
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
31
|
+
return ar;
|
|
32
|
+
};
|
|
33
|
+
return ownKeys(o);
|
|
34
|
+
};
|
|
35
|
+
return function (mod) {
|
|
36
|
+
if (mod && mod.__esModule) return mod;
|
|
37
|
+
var result = {};
|
|
38
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
39
|
+
__setModuleDefault(result, mod);
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.UNIT_PATH = exports.RULE_HOST = exports.ADDR_RE = exports.CONTAINER = exports.PROJECT = exports.SPEC_FILE = exports.DYNAMIC_DIR = exports.EDGE_DIR = void 0;
|
|
45
|
+
exports.edgeLock = edgeLock;
|
|
46
|
+
exports.edgeDir = edgeDir;
|
|
47
|
+
exports.dynamicDir = dynamicDir;
|
|
48
|
+
exports.composePath = composePath;
|
|
49
|
+
exports.routePath = routePath;
|
|
50
|
+
exports.certsDir = certsDir;
|
|
51
|
+
const config = __importStar(require("../../lib/config"));
|
|
52
|
+
const home_1 = require("../../lib/home");
|
|
53
|
+
const locks_1 = require("../runner/locks");
|
|
54
|
+
/** `<home>/edge` -- deliberately a sibling of `repros/`, never inside it. */
|
|
55
|
+
exports.EDGE_DIR = 'edge';
|
|
56
|
+
/** Traefik watches this for one routing file per registered name. */
|
|
57
|
+
exports.DYNAMIC_DIR = 'dynamic';
|
|
58
|
+
/** The Edge spec as written, so a later process can rebuild it exactly. */
|
|
59
|
+
exports.SPEC_FILE = 'spec.json';
|
|
60
|
+
/**
|
|
61
|
+
* The compose project name. The underscore is load-bearing: `sanitize()` maps every
|
|
62
|
+
* non `[a-z0-9-]` character to "-", so no repro can ever be named `houston_edge`, and the
|
|
63
|
+
* edge's project therefore cannot collide with a repro literally named "edge" -- which
|
|
64
|
+
* WOULD collide under `PROJECT_PREFIX + name`, and would let `down` on that repro tear
|
|
65
|
+
* down the box's only ingress.
|
|
66
|
+
*/
|
|
67
|
+
exports.PROJECT = 'houston_edge';
|
|
68
|
+
/** The edge's own container, as compose names it: `<project>-<service>-<index>`. */
|
|
69
|
+
exports.CONTAINER = `${exports.PROJECT}-edge-1`;
|
|
70
|
+
/**
|
|
71
|
+
* Serialise shared edge mutations across workspace jobs and CLI processes.
|
|
72
|
+
*
|
|
73
|
+
* The reserved project name cannot be a sanitised workspace name. Take this after a
|
|
74
|
+
* workspace lock; nested prepare/write/up/down calls reuse the seam's reentrant lock.
|
|
75
|
+
*/
|
|
76
|
+
async function edgeLock(body) {
|
|
77
|
+
return await (0, locks_1.reproLock)(exports.PROJECT, body);
|
|
78
|
+
}
|
|
79
|
+
function edgeDir() {
|
|
80
|
+
return (0, home_1.joinPath)(config.home(), exports.EDGE_DIR);
|
|
81
|
+
}
|
|
82
|
+
function dynamicDir() {
|
|
83
|
+
return (0, home_1.joinPath)(edgeDir(), exports.DYNAMIC_DIR);
|
|
84
|
+
}
|
|
85
|
+
function composePath() {
|
|
86
|
+
return (0, home_1.joinPath)(edgeDir(), 'compose.yml');
|
|
87
|
+
}
|
|
88
|
+
function routePath(name) {
|
|
89
|
+
return (0, home_1.joinPath)(dynamicDir(), `${name}.yml`);
|
|
90
|
+
}
|
|
91
|
+
function certsDir() {
|
|
92
|
+
return (0, home_1.joinPath)(edgeDir(), 'certs');
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* `<address>:<port>`, the only shape a Traefik TCP server takes.
|
|
96
|
+
*
|
|
97
|
+
* Checked rather than trusted: a bare address here loads as a router with no reachable
|
|
98
|
+
* server, so the name answers nothing and Traefik says so only in its own log.
|
|
99
|
+
*/
|
|
100
|
+
exports.ADDR_RE = /^[A-Za-z0-9._[\]:-]+:\d{1,5}$/u;
|
|
101
|
+
/**
|
|
102
|
+
* The host a generated route matches, whichever kind it is. `Host()` for an HTTP router,
|
|
103
|
+
* `HostSNI()` for a TCP passthrough.
|
|
104
|
+
*/
|
|
105
|
+
exports.RULE_HOST = /Host(?:SNI)?\(`([^`]+)`\)/u;
|
|
106
|
+
/** Where a unit file goes. Printed, never written -- see `systemdUnit`. */
|
|
107
|
+
exports.UNIT_PATH = '/etc/systemd/system/houston.service';
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.routeReachable = routeReachable;
|
|
37
|
+
exports.isPassthrough = isPassthrough;
|
|
38
|
+
exports.register = register;
|
|
39
|
+
exports.deregister = deregister;
|
|
40
|
+
exports.routeHost = routeHost;
|
|
41
|
+
exports.hostOwner = hostOwner;
|
|
42
|
+
exports.routesFor = routesFor;
|
|
43
|
+
exports.registered = registered;
|
|
44
|
+
exports.reattachAll = reattachAll;
|
|
45
|
+
/**
|
|
46
|
+
* The route files, and who claims which name. Tier 5 of `src/core/edge/`.
|
|
47
|
+
*/
|
|
48
|
+
const fs = __importStar(require("node:fs"));
|
|
49
|
+
const path = __importStar(require("node:path"));
|
|
50
|
+
const YAML = __importStar(require("yaml"));
|
|
51
|
+
const format_1 = require("../../lib/format");
|
|
52
|
+
const paths_1 = require("../runner/paths");
|
|
53
|
+
const networks_1 = require("./networks");
|
|
54
|
+
const paths = __importStar(require("./paths"));
|
|
55
|
+
const paths_2 = require("./paths");
|
|
56
|
+
const routeyml_1 = require("./routeyml");
|
|
57
|
+
const spec_1 = require("./spec");
|
|
58
|
+
const types_1 = require("./types");
|
|
59
|
+
/**
|
|
60
|
+
* Whether the edge can actually deliver `name`'s route, given what it is attached to.
|
|
61
|
+
*
|
|
62
|
+
* TWO DIFFERENT QUESTIONS behind one column. An HTTP route is delivered over a Docker
|
|
63
|
+
* network the edge has joined, so membership is the test. A PASSTHROUGH route forwards raw
|
|
64
|
+
* TCP to an address -- a cluster NodePort -- and joins no workspace network at all, so
|
|
65
|
+
* membership is always false for it and the honest answer is not "unreachable".
|
|
66
|
+
*
|
|
67
|
+
* `/api/edge` learned this and `edge status` did not, so the CLI reported `NO (502)` for
|
|
68
|
+
* every Kubernetes workspace. Measured in production conditions: a workspace answering
|
|
69
|
+
* HTTP 200 from the internet on a real Let's Encrypt certificate, listed as unreachable by
|
|
70
|
+
* the command whose job is to say so. One implementation here because that is the second
|
|
71
|
+
* time these two front ends disagreed about the same route file.
|
|
72
|
+
*/
|
|
73
|
+
async function routeReachable(name, attached) {
|
|
74
|
+
if (isPassthrough(name))
|
|
75
|
+
return true;
|
|
76
|
+
return new Set(attached).has(await (0, networks_1.workspaceNetwork)(name));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Whether `name`'s route passes TLS through rather than terminating it.
|
|
80
|
+
*
|
|
81
|
+
* Read from the route FILE, and parsed rather than sniffed for a substring: the caller
|
|
82
|
+
* that needs it is `reattachAll` on the `edge start` path, which is looking at routes and
|
|
83
|
+
* may have no workspace record to consult -- a route outlives its workspace, which is the
|
|
84
|
+
* whole reason `deregister` exists.
|
|
85
|
+
*
|
|
86
|
+
* False for anything unreadable. The only consequence of being wrong here is an attach
|
|
87
|
+
* that was not needed, which is a no-op, so the safe answer is the one that behaves as
|
|
88
|
+
* this function's absence did.
|
|
89
|
+
*/
|
|
90
|
+
function isPassthrough(name) {
|
|
91
|
+
try {
|
|
92
|
+
const doc = YAML.parse(fs.readFileSync(paths.routePath(name), 'utf8'), {
|
|
93
|
+
uniqueKeys: false,
|
|
94
|
+
});
|
|
95
|
+
return doc !== null && typeof doc === 'object' && 'tcp' in doc;
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Add (or replace) a workspace's route. Picked up without a restart.
|
|
103
|
+
*
|
|
104
|
+
* Returns whether `host` needs a certificate OF ITS OWN -- false when the edge's wildcard
|
|
105
|
+
* already covers it, which is what the caller counts against the weekly limit. Decided
|
|
106
|
+
* here because this is where the edge's own configuration is readable.
|
|
107
|
+
*
|
|
108
|
+
* Attaching is part of registering, not a separate step a caller can forget: a route
|
|
109
|
+
* pointing at a container the edge cannot resolve is a 502 rather than an error, which is
|
|
110
|
+
* the hardest kind of failure to diagnose.
|
|
111
|
+
*
|
|
112
|
+
* `passthrough` is an `<address>:<port>` the edge forwards raw TCP to instead of
|
|
113
|
+
* terminating -- a Kubernetes workspace's ingress. It takes a plain address on purpose:
|
|
114
|
+
* the edge has no business knowing what a cluster is, and keeping this module
|
|
115
|
+
* runtime-agnostic is what stops "does this workspace terminate TLS" from becoming a
|
|
116
|
+
* build-time property again.
|
|
117
|
+
*
|
|
118
|
+
* Two things do NOT happen for a passthrough, and both would be wrong rather than merely
|
|
119
|
+
* wasteful. There is no `attach`: that joins a Docker network named after a compose
|
|
120
|
+
* project, and a Kubernetes workspace has neither. And the return is always false, because
|
|
121
|
+
* no certificate is requested for a name the edge does not present one for -- counting it
|
|
122
|
+
* against the weekly limit would spend budget on nothing.
|
|
123
|
+
*/
|
|
124
|
+
async function register(name, host, options = {}) {
|
|
125
|
+
// A compose recreation must not race the network attach and leave this new route
|
|
126
|
+
// pointing at a network joined only by the container it just replaced.
|
|
127
|
+
return await paths.edgeLock(async () => await registerLocked(name, host, options));
|
|
128
|
+
}
|
|
129
|
+
async function registerLocked(name, host, { instances = 1, local = false, passthrough = '', passthroughHttp = '', grafana = false, publicPaths = [], } = {}) {
|
|
130
|
+
fs.mkdirSync(paths.dynamicDir(), { recursive: true });
|
|
131
|
+
if (passthrough !== '') {
|
|
132
|
+
await (0, paths_1.atomicWrite)(paths.routePath(name), (0, routeyml_1.passthroughRouteYml)(name, host, passthrough, passthroughHttp));
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
const door = (0, spec_1.current)();
|
|
136
|
+
const covered = door !== null && (0, types_1.covers)(door, host);
|
|
137
|
+
await (0, paths_1.atomicWrite)(paths.routePath(name), await (0, routeyml_1.workspaceRouteYml)(name, host, {
|
|
138
|
+
instances,
|
|
139
|
+
local,
|
|
140
|
+
grafana,
|
|
141
|
+
paths: publicPaths,
|
|
142
|
+
wildcardBase: covered ? door.domain : '',
|
|
143
|
+
}));
|
|
144
|
+
await (0, networks_1.attach)(name);
|
|
145
|
+
return !covered;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Remove a workspace's route. Removing the file 404s that host and leaves every other
|
|
149
|
+
* route untouched -- verified.
|
|
150
|
+
*/
|
|
151
|
+
function deregister(name) {
|
|
152
|
+
fs.rmSync(paths.routePath(name), { force: true });
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The hostname `name`'s route claims, or ''.
|
|
156
|
+
*
|
|
157
|
+
* Read from the file rather than from the workspace record, for the same reason
|
|
158
|
+
* `isPassthrough` is: a route outlives its workspace, and the caller that needs to know
|
|
159
|
+
* about a collision is looking at routes.
|
|
160
|
+
*/
|
|
161
|
+
function routeHost(name) {
|
|
162
|
+
try {
|
|
163
|
+
const found = paths_2.RULE_HOST.exec(fs.readFileSync(paths.routePath(name), 'utf8'));
|
|
164
|
+
return found === null ? '' : found[1];
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
return '';
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Which OTHER workspace's route already claims `host`, or ''.
|
|
172
|
+
*
|
|
173
|
+
* NOTHING CHECKED THIS, and ports have been guarded since long before names were. A route
|
|
174
|
+
* file is keyed by WORKSPACE NAME, so two workspaces given the same `--domain` each write
|
|
175
|
+
* their own file claiming the same `Host()` -- and Traefik picks one. That is the failure
|
|
176
|
+
* the design warns about in the same words: it "looks stable under testing and would
|
|
177
|
+
* silently serve the wrong workspace forever".
|
|
178
|
+
*
|
|
179
|
+
* Found by running it: three route files on one box all claiming
|
|
180
|
+
* `HostSNI(rc-rpro-test.kestron.org)` after a matrix of scenarios, two of them pointing at
|
|
181
|
+
* NodePorts that no longer existed. Traefik chose a dead one, so the name returned EOF,
|
|
182
|
+
* cert-manager's self check failed, and the certificate never issued -- for a chain that
|
|
183
|
+
* was otherwise completely correct.
|
|
184
|
+
*
|
|
185
|
+
* `excluding` is the workspace being created or brought back, which is allowed to re-claim
|
|
186
|
+
* its own name.
|
|
187
|
+
*/
|
|
188
|
+
function hostOwner(host, { excluding = '' } = {}) {
|
|
189
|
+
if (host === '')
|
|
190
|
+
return '';
|
|
191
|
+
for (const other of registered()) {
|
|
192
|
+
if (other === excluding)
|
|
193
|
+
continue;
|
|
194
|
+
if ((0, format_1.foldCase)(routeHost(other)) === (0, format_1.foldCase)(host))
|
|
195
|
+
return other;
|
|
196
|
+
}
|
|
197
|
+
return '';
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* EVERY route file claiming `host`, not just the first.
|
|
201
|
+
*
|
|
202
|
+
* `hostOwner` answers "is this name taken", which needs one name and stops. This answers
|
|
203
|
+
* "what would I have to remove to free it", and the difference is not theoretical: the
|
|
204
|
+
* collision that cost an hour of debugging was THREE route files on one host, two of them
|
|
205
|
+
* pointing at NodePorts that no longer existed. A cleanup that removed one would have left
|
|
206
|
+
* the name still broken and still claimed.
|
|
207
|
+
*/
|
|
208
|
+
function routesFor(host) {
|
|
209
|
+
if (host === '')
|
|
210
|
+
return [];
|
|
211
|
+
return registered().filter((name) => (0, format_1.foldCase)(routeHost(name)) === (0, format_1.foldCase)(host));
|
|
212
|
+
}
|
|
213
|
+
/** Workspace names with a route right now (the GUI's own route excluded). */
|
|
214
|
+
function registered() {
|
|
215
|
+
let entries;
|
|
216
|
+
try {
|
|
217
|
+
if (!fs.statSync(paths.dynamicDir()).isDirectory())
|
|
218
|
+
return [];
|
|
219
|
+
entries = fs.readdirSync(paths.dynamicDir());
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
return [];
|
|
223
|
+
}
|
|
224
|
+
return entries
|
|
225
|
+
.filter((entry) => entry.endsWith('.yml'))
|
|
226
|
+
.map((entry) => path.basename(entry, '.yml'))
|
|
227
|
+
.filter((stem) => !stem.startsWith('_'))
|
|
228
|
+
.sort();
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Join every routed workspace's network. Returns the ones that failed.
|
|
232
|
+
*
|
|
233
|
+
* Attachments are RUNTIME state on the container, so recreating the edge -- an upgrade, a
|
|
234
|
+
* `restart`, a reboot that pulls a new image -- loses every one of them while the route
|
|
235
|
+
* files survive untouched. The result is a set of names that answer 502 rather than
|
|
236
|
+
* erroring, so this runs after every start rather than waiting for someone to notice.
|
|
237
|
+
*/
|
|
238
|
+
async function reattachAll() {
|
|
239
|
+
const failed = [];
|
|
240
|
+
for (const name of registered()) {
|
|
241
|
+
// A passthrough route has no network to join -- it names an address, not a container.
|
|
242
|
+
// Attaching would run `docker network connect` for a compose project that does not
|
|
243
|
+
// exist, fail, and report a perfectly healthy Kubernetes workspace as one the edge
|
|
244
|
+
// could not reach, on every restart.
|
|
245
|
+
if (isPassthrough(name))
|
|
246
|
+
continue;
|
|
247
|
+
if (!(await (0, networks_1.attach)(name)))
|
|
248
|
+
failed.push(name);
|
|
249
|
+
}
|
|
250
|
+
return failed;
|
|
251
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.guiRouteYml = guiRouteYml;
|
|
4
|
+
exports.workspaceRouteYml = workspaceRouteYml;
|
|
5
|
+
exports.passthroughRouteYml = passthroughRouteYml;
|
|
6
|
+
/**
|
|
7
|
+
* The routing files Traefik watches. Tier 3 of `src/core/edge/`.
|
|
8
|
+
*/
|
|
9
|
+
const config_1 = require("../../lib/config");
|
|
10
|
+
const compose_1 = require("../../lib/compose");
|
|
11
|
+
const errors_1 = require("../../lib/errors");
|
|
12
|
+
const format_1 = require("../../lib/format");
|
|
13
|
+
const networks_1 = require("./networks");
|
|
14
|
+
const paths_1 = require("./paths");
|
|
15
|
+
/**
|
|
16
|
+
* The routing file for the GUI itself.
|
|
17
|
+
*
|
|
18
|
+
* When a wildcard is available this router is what asks for it -- one request covering the
|
|
19
|
+
* apex and every `*.domain` workspace, so no workspace ever costs a certificate again.
|
|
20
|
+
*/
|
|
21
|
+
function guiRouteYml(value) {
|
|
22
|
+
const wildcard = value.wildcard ? `*.${value.domain}` : '';
|
|
23
|
+
// The port as the spec holds it: a spec that holds 7071.0 routes to `:7071.0`, as it
|
|
24
|
+
// always has.
|
|
25
|
+
return routeYml('gui', value.domain, [`http://host.docker.internal:${(0, format_1.storedText)(value.guiPort)}`], {
|
|
26
|
+
sticky: false,
|
|
27
|
+
wildcard,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The routing file a workspace registers: `host` -> its Rocket.Chat.
|
|
32
|
+
*
|
|
33
|
+
* `wildcardBase` is the edge's domain when its wildcard already covers `host`. The route
|
|
34
|
+
* then names that wildcard instead of the host, so Traefik serves the existing certificate
|
|
35
|
+
* rather than requesting a per-name one.
|
|
36
|
+
*/
|
|
37
|
+
async function workspaceRouteYml(name, host, { instances = 1, wildcardBase = '', local = false, grafana = false, paths = [], } = {}) {
|
|
38
|
+
const backends = [];
|
|
39
|
+
for (const service of (0, compose_1.rcServiceNames)(instances)) {
|
|
40
|
+
backends.push(`http://${await (0, networks_1.backendContainer)(name, service)}:${String(config_1.RC_CONTAINER_PORT)}`);
|
|
41
|
+
}
|
|
42
|
+
// A preset's own UIs at their paths (`lib/presets/public.ts`), each to its container.
|
|
43
|
+
const extra = [];
|
|
44
|
+
for (const p of paths) {
|
|
45
|
+
extra.push([
|
|
46
|
+
p.service,
|
|
47
|
+
p.path,
|
|
48
|
+
`http://${await (0, networks_1.backendContainer)(name, p.service)}:${String(p.container_port)}`,
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
return routeYml(name, host, backends, {
|
|
52
|
+
local,
|
|
53
|
+
wildcard: wildcardBase !== '' ? `*.${wildcardBase}` : '',
|
|
54
|
+
grafanaBackend: grafana ? `http://${await (0, networks_1.backendContainer)(name, 'grafana')}:3000` : '',
|
|
55
|
+
paths: extra,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A route that does NOT decrypt: match `host` by SNI, forward raw TCP.
|
|
60
|
+
*
|
|
61
|
+
* The second kind of backend, and the reason it exists is fidelity rather than
|
|
62
|
+
* convenience. A Kubernetes workspace's certificate lives in a cluster Secret and its
|
|
63
|
+
* Ingress is what terminates TLS -- so if the edge terminated instead, the `tls:` block,
|
|
64
|
+
* the Secret and cert-manager would never run, and those are exactly where a customer's
|
|
65
|
+
* certificate bugs live. Passing through means the bytes the browser exchanges with the
|
|
66
|
+
* ingress are the bytes it would exchange in production.
|
|
67
|
+
*
|
|
68
|
+
* `tcp` and `http` routers share the entrypoint deliberately: Traefik matches TCP routers
|
|
69
|
+
* by SNI FIRST and falls through to HTTP routers for anything unmatched, which is what
|
|
70
|
+
* lets one :443 terminate for a Compose name and pass through for a Kubernetes one.
|
|
71
|
+
* Measured on this box, one entrypoint, two names: the Compose name received the edge's
|
|
72
|
+
* own leaf and the Kubernetes name received the cluster's Secret, byte-identical to it.
|
|
73
|
+
*
|
|
74
|
+
* No `certResolver` and no certificate of any kind: naming one would make the edge request
|
|
75
|
+
* a certificate for a name it is not serving, and the wildcard question (`covers`) does not
|
|
76
|
+
* arise either, because nothing here presents a certificate. That is why `register`
|
|
77
|
+
* returns false for this shape.
|
|
78
|
+
*/
|
|
79
|
+
function passthroughRouteYml(key, host, address, httpAddress = '') {
|
|
80
|
+
for (const addr of httpAddress === '' ? [address] : [address, httpAddress]) {
|
|
81
|
+
if (!paths_1.ADDR_RE.test(addr || '')) {
|
|
82
|
+
throw new errors_1.ValidationError(`a passthrough backend needs \`<address>:<port>\`, not '${addr}' — Traefik would ` +
|
|
83
|
+
`load the router with no reachable server and ${host} would answer nothing, with ` +
|
|
84
|
+
"the reason only in the edge's own log.");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// THE HTTP-01 CHALLENGE, to the cluster's own :80. cert-manager answers it from a solver
|
|
88
|
+
// Ingress on the cluster's plain-HTTP side; the edge redirected it to HTTPS instead, where
|
|
89
|
+
// there is no solver, so the certificate never issued. Only the challenge path: every
|
|
90
|
+
// other http:// request keeps the edge's redirect.
|
|
91
|
+
const challenge = httpAddress === ''
|
|
92
|
+
? ''
|
|
93
|
+
: 'http:\n' +
|
|
94
|
+
' routers:\n' +
|
|
95
|
+
` ${key}-acme-http:\n` +
|
|
96
|
+
` rule: "Host(\`${host}\`) && PathPrefix(\`/.well-known/acme-challenge/\`)"\n` +
|
|
97
|
+
' entryPoints: [web]\n' +
|
|
98
|
+
// Above Traefik's bypassed internal HTTP solver and the redirect. Scoped by
|
|
99
|
+
// hostname, so a Docker name still reaches the edge's own challenge handler.
|
|
100
|
+
' priority: 100\n' +
|
|
101
|
+
` service: ${key}-acme-http\n` +
|
|
102
|
+
' services:\n' +
|
|
103
|
+
` ${key}-acme-http:\n` +
|
|
104
|
+
' loadBalancer:\n' +
|
|
105
|
+
' servers:\n' +
|
|
106
|
+
` - url: "http://${httpAddress}"\n`;
|
|
107
|
+
return ('# Generated by houston. Do not edit by hand.\n' +
|
|
108
|
+
'# A TCP passthrough: the edge does NOT decrypt this name.\n' +
|
|
109
|
+
'tcp:\n' +
|
|
110
|
+
' routers:\n' +
|
|
111
|
+
` ${key}:\n` +
|
|
112
|
+
` rule: "HostSNI(\`${host}\`)"\n` +
|
|
113
|
+
' entryPoints: [websecure]\n' +
|
|
114
|
+
` service: ${key}\n` +
|
|
115
|
+
' tls:\n' +
|
|
116
|
+
' passthrough: true\n' +
|
|
117
|
+
' services:\n' +
|
|
118
|
+
` ${key}:\n` +
|
|
119
|
+
' loadBalancer:\n' +
|
|
120
|
+
' servers:\n' +
|
|
121
|
+
` - address: "${address}"\n` +
|
|
122
|
+
challenge);
|
|
123
|
+
}
|
|
124
|
+
function routeYml(key, host, backends, { sticky = true, wildcard = '', local = false, grafanaBackend = '', paths = [], } = {}) {
|
|
125
|
+
const servers = backends.map((backend) => ` - url: "${backend}"`).join('\n');
|
|
126
|
+
// certResolver rather than a static certificate: the edge requests per name, and Traefik
|
|
127
|
+
// derives WHAT to request from the Host() rule -- which is why the rule must name the
|
|
128
|
+
// host and not be a bare PathPrefix.
|
|
129
|
+
//
|
|
130
|
+
// `domains` overrides that derivation. Naming the wildcard makes every router under it
|
|
131
|
+
// resolve to ONE certificate: Traefik obtains it once and reuses it, which is the
|
|
132
|
+
// difference between 1 and N against the weekly limit.
|
|
133
|
+
//
|
|
134
|
+
// A local certificate is LOADED from disk (`issueLocalCert` wrote it into the watched
|
|
135
|
+
// directory), so naming a resolver would make Traefik go and request one from Let's
|
|
136
|
+
// Encrypt for a .localhost name that can never be validated.
|
|
137
|
+
let tlsBlock = local ? ' tls: {}\n' : ' tls:\n certResolver: le\n';
|
|
138
|
+
if (wildcard !== '' && !local) {
|
|
139
|
+
tlsBlock += ` domains:\n - main: "${wildcard}"\n`;
|
|
140
|
+
if (wildcard.replace(/^\*\./u, '') === host) {
|
|
141
|
+
// The apex is not matched by its own wildcard, so the router that requests it has to
|
|
142
|
+
// ask for both or the GUI's own name is uncovered.
|
|
143
|
+
tlsBlock =
|
|
144
|
+
' tls:\n certResolver: le\n domains:\n' +
|
|
145
|
+
` - main: "${host}"\n sans: ["${wildcard}"]\n`;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
let body = '# Generated by houston. Do not edit by hand.\n' +
|
|
149
|
+
'http:\n' +
|
|
150
|
+
' routers:\n' +
|
|
151
|
+
` ${key}:\n` +
|
|
152
|
+
` rule: "Host(\`${host}\`)"\n` +
|
|
153
|
+
' entryPoints: [websecure]\n' +
|
|
154
|
+
` service: ${key}\n` +
|
|
155
|
+
tlsBlock +
|
|
156
|
+
(grafanaBackend
|
|
157
|
+
? ` ${key}-grafana:\n` +
|
|
158
|
+
` rule: "Host(\`${host}\`) && PathPrefix(\`/grafana\`)"\n` +
|
|
159
|
+
' entryPoints: [websecure]\n' +
|
|
160
|
+
` service: ${key}-grafana\n` +
|
|
161
|
+
tlsBlock
|
|
162
|
+
: '') +
|
|
163
|
+
paths
|
|
164
|
+
.map(([service, path]) => ` ${key}-${service}:\n` +
|
|
165
|
+
` rule: "Host(\`${host}\`) && PathPrefix(\`${path}\`)"\n` +
|
|
166
|
+
' entryPoints: [websecure]\n' +
|
|
167
|
+
` service: ${key}-${service}\n` +
|
|
168
|
+
tlsBlock)
|
|
169
|
+
.join('') +
|
|
170
|
+
' services:\n' +
|
|
171
|
+
` ${key}:\n` +
|
|
172
|
+
' loadBalancer:\n' +
|
|
173
|
+
' servers:\n' +
|
|
174
|
+
`${servers}\n`;
|
|
175
|
+
if (sticky) {
|
|
176
|
+
// DDP websockets must not be bounced between instances mid-session.
|
|
177
|
+
body +=
|
|
178
|
+
' sticky:\n cookie:\n name: rc_lb\n secure: true\n';
|
|
179
|
+
}
|
|
180
|
+
if (grafanaBackend) {
|
|
181
|
+
body +=
|
|
182
|
+
` ${key}-grafana:\n` +
|
|
183
|
+
' loadBalancer:\n' +
|
|
184
|
+
' servers:\n' +
|
|
185
|
+
` - url: "${grafanaBackend}"\n`;
|
|
186
|
+
}
|
|
187
|
+
for (const [service, , backend] of paths) {
|
|
188
|
+
body +=
|
|
189
|
+
` ${key}-${service}:\n` +
|
|
190
|
+
' loadBalancer:\n' +
|
|
191
|
+
' servers:\n' +
|
|
192
|
+
` - url: "${backend}"\n`;
|
|
193
|
+
}
|
|
194
|
+
return body;
|
|
195
|
+
}
|