@rocket.chat/houston 0.27.0-next.2 → 2.1.8
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 +108 -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 +669 -0
- package/data/docs/kubernetes.md +138 -0
- package/data/docs/troubleshooting.md +193 -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 +168 -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 +39 -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 +3678 -0
- package/dist/cli/help.js +183 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/perf.js +810 -0
- package/dist/cli/render.js +254 -0
- package/dist/cli/serve.js +858 -0
- package/dist/cli/spec-data.js +2593 -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 +344 -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 +691 -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 +1533 -0
- package/dist/core/lifecycle/create-k8s.js +939 -0
- package/dist/core/lifecycle/destroy.js +339 -0
- package/dist/core/lifecycle/inspect.js +635 -0
- package/dist/core/lifecycle/naming.js +298 -0
- package/dist/core/lifecycle/notes.js +726 -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 +753 -0
- package/dist/core/lifecycle/request.js +525 -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 +995 -0
- package/dist/core/migrate.js +612 -0
- package/dist/core/monitor.js +494 -0
- package/dist/core/postready.js +969 -0
- package/dist/core/promote.js +804 -0
- package/dist/core/rcapi.js +1285 -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 +868 -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 +369 -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 +296 -0
- package/dist/perf/k6.js +235 -0
- package/dist/perf/mongoprof.js +171 -0
- package/dist/perf/rcmetrics.js +178 -0
- package/dist/perf/report.js +386 -0
- package/dist/perf/resources.js +224 -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 +67 -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 -192
- package/src/bin.js +0 -4
- package/src/cli.ts +0 -25
- package/src/commands/createBranch.ts +0 -25
- 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,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.grafanaIngressName = grafanaIngressName;
|
|
4
|
+
exports.grafanaIngressManifest = grafanaIngressManifest;
|
|
5
|
+
exports.ensureGrafanaIngress = ensureGrafanaIngress;
|
|
6
|
+
/** One workspace's host routes /grafana to the cluster's shared Grafana. */
|
|
7
|
+
const node_crypto_1 = require("node:crypto");
|
|
8
|
+
const errors_1 = require("../../lib/errors");
|
|
9
|
+
const events_1 = require("../../lib/events");
|
|
10
|
+
const tls_1 = require("../tls");
|
|
11
|
+
const ask_1 = require("./ask");
|
|
12
|
+
const certmanager_1 = require("./certmanager");
|
|
13
|
+
const monitoring_1 = require("./monitoring");
|
|
14
|
+
const names_1 = require("./names");
|
|
15
|
+
const namespace_1 = require("./namespace");
|
|
16
|
+
const release_1 = require("./release");
|
|
17
|
+
function bag(value) {
|
|
18
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
19
|
+
? value
|
|
20
|
+
: {};
|
|
21
|
+
}
|
|
22
|
+
/** Leave four characters for the TLS Secret suffix, with a stable collision-resistant tail. */
|
|
23
|
+
function grafanaIngressName(workspace) {
|
|
24
|
+
const raw = `grafana-${workspace}`;
|
|
25
|
+
return raw.length <= 59
|
|
26
|
+
? raw
|
|
27
|
+
: `grafana-${workspace.slice(0, 42).replace(/-+$/u, '')}-${(0, node_crypto_1.createHash)('sha256').update(workspace).digest('hex').slice(0, 8)}`;
|
|
28
|
+
}
|
|
29
|
+
function grafanaIngressManifest(workspace, host, ingressClass, issuer) {
|
|
30
|
+
const name = grafanaIngressName(workspace);
|
|
31
|
+
const labels = { ...(0, namespace_1.labelsFor)(workspace), [monitoring_1.GRAFANA_INGRESS_LABEL]: 'true' };
|
|
32
|
+
return JSON.stringify({
|
|
33
|
+
apiVersion: 'networking.k8s.io/v1',
|
|
34
|
+
kind: 'Ingress',
|
|
35
|
+
metadata: {
|
|
36
|
+
name,
|
|
37
|
+
namespace: monitoring_1.MONITORING_NAMESPACE,
|
|
38
|
+
labels,
|
|
39
|
+
annotations: {
|
|
40
|
+
'cert-manager.io/cluster-issuer': (0, certmanager_1.issuerName)(issuer),
|
|
41
|
+
// ingress-shim copies the Ingress labels to the Certificate; this also labels
|
|
42
|
+
// its Secret, so all three resources can be reclaimed by the same selector.
|
|
43
|
+
'cert-manager.io/secret-template': JSON.stringify({ labels }),
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
spec: {
|
|
47
|
+
ingressClassName: ingressClass,
|
|
48
|
+
tls: [{ hosts: [host], secretName: `${name}-tls` }],
|
|
49
|
+
rules: [
|
|
50
|
+
{
|
|
51
|
+
host,
|
|
52
|
+
http: {
|
|
53
|
+
paths: [
|
|
54
|
+
{
|
|
55
|
+
path: '/grafana',
|
|
56
|
+
pathType: 'Prefix',
|
|
57
|
+
backend: { service: { name: monitoring_1.GRAFANA_SERVICE, port: { number: monitoring_1.GRAFANA_PORT } } },
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
async function ensureGrafanaIngress(workspace, { context, publicUrl, ingressClass, issuer, emit = events_1.nullEmit, }) {
|
|
67
|
+
const host = new URL(publicUrl).hostname;
|
|
68
|
+
const name = grafanaIngressName(workspace);
|
|
69
|
+
let newCertificate = false;
|
|
70
|
+
for (const [kind, resource] of [
|
|
71
|
+
['ingress', name],
|
|
72
|
+
['certificate', `${name}-tls`],
|
|
73
|
+
['secret', `${name}-tls`],
|
|
74
|
+
]) {
|
|
75
|
+
// APPLY_TIMEOUT: a must-answer question inside an attach job, as in `removeGrafanaIngress`.
|
|
76
|
+
const seen = (0, ask_1.require_)(await (0, ask_1.askObject)(kind, resource, {
|
|
77
|
+
namespace: monitoring_1.MONITORING_NAMESPACE,
|
|
78
|
+
context,
|
|
79
|
+
timeout: names_1.APPLY_TIMEOUT,
|
|
80
|
+
}), `Grafana ${kind} '${resource}'`, { context });
|
|
81
|
+
if ((0, ask_1.present)(seen)) {
|
|
82
|
+
const labels = bag(bag(seen.doc.metadata).labels);
|
|
83
|
+
if (labels[names_1.OWNER_LABEL_KEY] !== names_1.OWNER_LABEL_VALUE ||
|
|
84
|
+
labels[names_1.WORKSPACE_LABEL] !== workspace ||
|
|
85
|
+
labels[monitoring_1.GRAFANA_INGRESS_LABEL] !== 'true')
|
|
86
|
+
throw new errors_1.ConflictError(`Grafana ${kind} '${resource}' in ${monitoring_1.MONITORING_NAMESPACE} belongs to somebody else`);
|
|
87
|
+
if (kind === 'certificate') {
|
|
88
|
+
const spec = bag(seen.doc.spec);
|
|
89
|
+
newCertificate =
|
|
90
|
+
!Array.isArray(spec.dnsNames) ||
|
|
91
|
+
!spec.dnsNames.includes(host) ||
|
|
92
|
+
bag(spec.issuerRef).name !== (0, certmanager_1.issuerName)(issuer);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else if (kind === 'certificate')
|
|
96
|
+
newCertificate = true;
|
|
97
|
+
}
|
|
98
|
+
(0, events_1.info)(emit, `serving ${publicUrl}/grafana through the shared stack`, { phase: 'monitor' });
|
|
99
|
+
await (0, release_1.apply)(grafanaIngressManifest(workspace, host, ingressClass, issuer), {
|
|
100
|
+
namespace: monitoring_1.MONITORING_NAMESPACE,
|
|
101
|
+
context,
|
|
102
|
+
});
|
|
103
|
+
if (issuer.mode === 'acme' && newCertificate) {
|
|
104
|
+
(0, tls_1.recordIssuance)(host, '', `${context}:${monitoring_1.MONITORING_NAMESPACE}:${name}-tls`);
|
|
105
|
+
const warning = (0, tls_1.budgetWarning)(host);
|
|
106
|
+
if (warning)
|
|
107
|
+
(0, events_1.warn)(emit, warning, { phase: 'tls' });
|
|
108
|
+
}
|
|
109
|
+
await (0, certmanager_1.waitForCertificate)(`${name}-tls`, { namespace: monitoring_1.MONITORING_NAMESPACE, context, emit });
|
|
110
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TOOLS_INGRESS = exports.INGRESS_CLASS_INTERVAL = exports.INGRESS_CLASS_TRIES = exports.INGRESS_NAMESPACE = exports.INGRESS_RELEASE = exports.INGRESS_CHART = exports.INGRESS_REPO_URL = exports.INGRESS_REPO = void 0;
|
|
4
|
+
exports.ensureIngress = ensureIngress;
|
|
5
|
+
exports.toolsIngressManifest = toolsIngressManifest;
|
|
6
|
+
exports.ingressValues = ingressValues;
|
|
7
|
+
/**
|
|
8
|
+
* The ingress controller, adopted when one is already there and installed when not.
|
|
9
|
+
*/
|
|
10
|
+
const errors_1 = require("../../lib/errors");
|
|
11
|
+
const events_1 = require("../../lib/events");
|
|
12
|
+
const ask_1 = require("./ask");
|
|
13
|
+
const capabilities_1 = require("./capabilities");
|
|
14
|
+
const certmanager_1 = require("./certmanager");
|
|
15
|
+
const context_1 = require("./context");
|
|
16
|
+
const exec_1 = require("./exec");
|
|
17
|
+
const names_1 = require("./names");
|
|
18
|
+
const release_1 = require("./release");
|
|
19
|
+
const realSleep = (seconds) => new Promise((resolve) => setTimeout(resolve, seconds * 1000));
|
|
20
|
+
/**
|
|
21
|
+
* The ingress controller houston installs when a cluster has none, and where. The official
|
|
22
|
+
* Rocket.Chat guide's own example, so a cluster houston filled in looks like a cluster
|
|
23
|
+
* somebody followed the guide on.
|
|
24
|
+
*
|
|
25
|
+
* THE CHART'S DEFAULT SERVICE TYPE IS LEFT ALONE, and that is the whole reason no NodePort
|
|
26
|
+
* is configured anywhere: on a cluster with a provider it gets an address and the cluster
|
|
27
|
+
* owns :443, and on one without it stays pending while Kubernetes allocates NodePorts
|
|
28
|
+
* anyway. `ingressEndpoint` reads whichever exists.
|
|
29
|
+
*/
|
|
30
|
+
exports.INGRESS_REPO = 'traefik';
|
|
31
|
+
exports.INGRESS_REPO_URL = 'https://traefik.github.io/charts';
|
|
32
|
+
exports.INGRESS_CHART = `${exports.INGRESS_REPO}/traefik`;
|
|
33
|
+
exports.INGRESS_RELEASE = 'traefik';
|
|
34
|
+
exports.INGRESS_NAMESPACE = 'traefik';
|
|
35
|
+
exports.INGRESS_CLASS_TRIES = 30;
|
|
36
|
+
exports.INGRESS_CLASS_INTERVAL = 2.0;
|
|
37
|
+
/** Install the ingress controller and wait for its rollout. */
|
|
38
|
+
async function installIngressController(context, emit) {
|
|
39
|
+
(0, events_1.info)(emit, `no ingress controller in '${context}' — installing ${exports.INGRESS_CHART} into ` +
|
|
40
|
+
`${exports.INGRESS_NAMESPACE} (once per cluster, the guide's own command)`, { phase: 'tls', pct: 12 });
|
|
41
|
+
await exec_1.kube.run(['helm', 'repo', 'add', exports.INGRESS_REPO, exports.INGRESS_REPO_URL, '--force-update'], {
|
|
42
|
+
timeout: names_1.APPLY_TIMEOUT,
|
|
43
|
+
env: (0, exec_1.helmEnv)(context),
|
|
44
|
+
});
|
|
45
|
+
await exec_1.kube.run(['helm', 'repo', 'update', exports.INGRESS_REPO], {
|
|
46
|
+
timeout: names_1.APPLY_TIMEOUT,
|
|
47
|
+
env: (0, exec_1.helmEnv)(context),
|
|
48
|
+
});
|
|
49
|
+
// Same blast radius as the operator and the monitoring stack: one shared release, so a
|
|
50
|
+
// killed install wedges it for every later workspace on this cluster.
|
|
51
|
+
await (0, release_1.clearPendingRelease)(exports.INGRESS_RELEASE, exports.INGRESS_NAMESPACE, context, { emit });
|
|
52
|
+
// DELIBERATELY NOT `--wait`, and NOT the rollback flag either -- which implies it. Helm's
|
|
53
|
+
// readiness check for a Service of type LoadBalancer waits for
|
|
54
|
+
// `status.loadBalancer.ingress` to be populated, and this chart's Service is a
|
|
55
|
+
// LoadBalancer by default. On a cluster with no provider that never happens, so `--wait`
|
|
56
|
+
// cannot succeed on precisely the cluster houston is installing into. Measured on k3s
|
|
57
|
+
// started with `--disable servicelb`: five minutes, then a rollback, on an install whose
|
|
58
|
+
// three pods were fine.
|
|
59
|
+
const res = await exec_1.kube.run([
|
|
60
|
+
'helm',
|
|
61
|
+
'upgrade',
|
|
62
|
+
'--install',
|
|
63
|
+
exports.INGRESS_RELEASE,
|
|
64
|
+
exports.INGRESS_CHART,
|
|
65
|
+
'--kube-context',
|
|
66
|
+
context,
|
|
67
|
+
'-n',
|
|
68
|
+
exports.INGRESS_NAMESPACE,
|
|
69
|
+
'--create-namespace',
|
|
70
|
+
'--timeout',
|
|
71
|
+
'5m',
|
|
72
|
+
], { timeout: names_1.INSTALL_TIMEOUT, env: (0, exec_1.helmEnv)(context) });
|
|
73
|
+
if (res.returncode !== 0) {
|
|
74
|
+
throw new errors_1.CreateFailedError(`could not install an ingress controller into '${context}': ${(0, ask_1.why)(res)}`);
|
|
75
|
+
}
|
|
76
|
+
// The controller itself, which `--wait` would have covered had it been usable.
|
|
77
|
+
await exec_1.kube.run([
|
|
78
|
+
'kubectl',
|
|
79
|
+
'--context',
|
|
80
|
+
context,
|
|
81
|
+
'-n',
|
|
82
|
+
exports.INGRESS_NAMESPACE,
|
|
83
|
+
'rollout',
|
|
84
|
+
'status',
|
|
85
|
+
`deployment/${exports.INGRESS_RELEASE}`,
|
|
86
|
+
'--timeout=180s',
|
|
87
|
+
], { timeout: names_1.INSTALL_TIMEOUT, own: (0, names_1.isOurs)(context) });
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The IngressClass to use. Adopts one if the cluster has it, installs if not.
|
|
91
|
+
*
|
|
92
|
+
* `invited` means a human asked for this cluster to be set up (`cluster prepare`) rather
|
|
93
|
+
* than houston reaching for an ingress on the way to booting a workspace. Locality was
|
|
94
|
+
* standing in for consent; installing a LoadBalancer Service into somebody else's cluster
|
|
95
|
+
* uninvited is the thing to avoid, and being asked to is not that.
|
|
96
|
+
*
|
|
97
|
+
* ADOPTING COMES FIRST, and not only to save work: the ingress controller is the component
|
|
98
|
+
* whose behaviour a support case is usually about, so a cluster that already runs nginx must
|
|
99
|
+
* keep running nginx. Installing Traefik over the top would reproduce the wrong thing in
|
|
100
|
+
* exactly the dimension that matters.
|
|
101
|
+
*
|
|
102
|
+
* Only on a cluster that is on this machine: an ingress controller's Service is a
|
|
103
|
+
* LoadBalancer by chart default, and on a managed cluster that provisions a real cloud load
|
|
104
|
+
* balancer -- a billable resource, created implicitly, in somebody's account.
|
|
105
|
+
*
|
|
106
|
+
* Never removed. An ingress controller serves every Ingress in the cluster, including ones
|
|
107
|
+
* houston knows nothing about, and taking the box's ingress away on a `down --volumes` would
|
|
108
|
+
* be a far bigger surprise than leaving it.
|
|
109
|
+
*/
|
|
110
|
+
async function ensureIngress({ context, distribution = '', invited = false, prefer = '', emit = events_1.nullEmit, sleep = realSleep, }) {
|
|
111
|
+
const seen = await (0, capabilities_1.ingressClasses)(context);
|
|
112
|
+
if (seen === null) {
|
|
113
|
+
throw new errors_1.DockerError(`could not read the IngressClasses in cluster '${context}', so houston cannot tell ` +
|
|
114
|
+
'whether it has an ingress controller. Check the credential in your kubeconfig — ' +
|
|
115
|
+
"refusing to guess, because 'I cannot ask' and 'there is none' are different answers.");
|
|
116
|
+
}
|
|
117
|
+
if (seen.length > 0 && prefer !== '') {
|
|
118
|
+
// NAMED BY THE OPERATOR, and refused rather than silently ignored. Somebody who passes
|
|
119
|
+
// `--ingress-class alb` and gets nginx has been overruled without being told.
|
|
120
|
+
if (!seen.includes(prefer)) {
|
|
121
|
+
throw new errors_1.PreflightError(`cluster '${context}' has no IngressClass named '${prefer}'. It has: ` +
|
|
122
|
+
`${seen.join(', ') || 'none'}.`);
|
|
123
|
+
}
|
|
124
|
+
(0, events_1.info)(emit, `ingress: using '${prefer}' as asked`, { phase: 'tls' });
|
|
125
|
+
return prefer;
|
|
126
|
+
}
|
|
127
|
+
if (seen.length > 1) {
|
|
128
|
+
// SAID OUT LOUD, because a choice among several is a decision and this is the only place
|
|
129
|
+
// it is visible. `ingressClasses` puts the cluster's own default first; where there is
|
|
130
|
+
// no default the order is by name, which is arbitrary but at least the same every time.
|
|
131
|
+
(0, events_1.info)(emit, `ingress: adopting '${String(seen[0])}' — this cluster has ${seen.join(', ')}. ` +
|
|
132
|
+
'`--ingress-class` names a different one.', { phase: 'tls' });
|
|
133
|
+
return seen[0];
|
|
134
|
+
}
|
|
135
|
+
if (seen.length === 1) {
|
|
136
|
+
(0, events_1.info)(emit, `ingress: adopting '${String(seen[0])}', already in this cluster`, {
|
|
137
|
+
phase: 'tls',
|
|
138
|
+
});
|
|
139
|
+
return seen[0];
|
|
140
|
+
}
|
|
141
|
+
if (!invited &&
|
|
142
|
+
!(await (0, context_1.isLocalCluster)(distribution || (await (0, context_1.distributionOf)(context)), context))) {
|
|
143
|
+
throw new errors_1.PreflightError(`cluster '${context}' has no ingress controller, and it is not on this machine, so ` +
|
|
144
|
+
"houston will not install one: the chart's Service is a LoadBalancer and that " +
|
|
145
|
+
'provisions a real load balancer in your cloud account. Install one yourself and ' +
|
|
146
|
+
`houston will adopt it:\n helm install ${exports.INGRESS_RELEASE} ${exports.INGRESS_CHART} -n ` +
|
|
147
|
+
`${exports.INGRESS_NAMESPACE} --create-namespace`);
|
|
148
|
+
}
|
|
149
|
+
await installIngressController(context, emit);
|
|
150
|
+
// THE CLASS, NOT THE RELEASE. helm returning means the Deployment is ready; the
|
|
151
|
+
// IngressClass is a separate object and the chart creates it, so a create that went
|
|
152
|
+
// straight on to reading the classes would find none and refuse for want of the thing it
|
|
153
|
+
// had just installed.
|
|
154
|
+
for (let attempt = 0; attempt < exports.INGRESS_CLASS_TRIES; attempt += 1) {
|
|
155
|
+
const found = await (0, capabilities_1.ingressClasses)(context);
|
|
156
|
+
if (found !== null && found.length > 0) {
|
|
157
|
+
(0, events_1.info)(emit, `ingress: installed '${String(found[0])}'`, { phase: 'tls' });
|
|
158
|
+
return found[0];
|
|
159
|
+
}
|
|
160
|
+
if (attempt < exports.INGRESS_CLASS_TRIES - 1)
|
|
161
|
+
await sleep(exports.INGRESS_CLASS_INTERVAL);
|
|
162
|
+
}
|
|
163
|
+
throw new errors_1.CreateFailedError(`${exports.INGRESS_CHART} installed into '${context}' but no IngressClass appeared, so nothing ` +
|
|
164
|
+
`would route to this workspace. \`kubectl get ingressclass\` and \`kubectl -n ` +
|
|
165
|
+
`${exports.INGRESS_NAMESPACE} get pods\`.`);
|
|
166
|
+
}
|
|
167
|
+
/** The Ingress, in the workspace's namespace, that serves a preset's own UIs. */
|
|
168
|
+
exports.TOOLS_INGRESS = 'houston-tools';
|
|
169
|
+
/**
|
|
170
|
+
* A preset's own UIs at paths of the workspace's HTTPS name (`lib/presets/public.ts`), each to
|
|
171
|
+
* its Service. Same host and the SAME certificate Secret as the chart's Ingress, so it asks
|
|
172
|
+
* cert-manager for nothing and costs no certificate; deleting the namespace removes it.
|
|
173
|
+
*/
|
|
174
|
+
function toolsIngressManifest(host, { ingressClass, secretName, paths, labels, }) {
|
|
175
|
+
return JSON.stringify({
|
|
176
|
+
apiVersion: 'networking.k8s.io/v1',
|
|
177
|
+
kind: 'Ingress',
|
|
178
|
+
metadata: { name: exports.TOOLS_INGRESS, labels },
|
|
179
|
+
spec: {
|
|
180
|
+
ingressClassName: ingressClass,
|
|
181
|
+
tls: [{ hosts: [host], secretName }],
|
|
182
|
+
rules: [
|
|
183
|
+
{
|
|
184
|
+
host,
|
|
185
|
+
http: {
|
|
186
|
+
paths: paths.map((p) => ({
|
|
187
|
+
path: p.path,
|
|
188
|
+
pathType: 'Prefix',
|
|
189
|
+
backend: { service: { name: p.service, port: { number: p.service_port } } },
|
|
190
|
+
})),
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* The official guide's ingress block, verbatim in shape.
|
|
199
|
+
*
|
|
200
|
+
* `host` is returned alongside because the chart uses it for BOTH the Ingress rule host and
|
|
201
|
+
* its own ROOT_URL -- see `valuesFor`, where passing a URL here once rendered
|
|
202
|
+
* `https://http://localhost:32812`.
|
|
203
|
+
*
|
|
204
|
+
* The chart builds the Ingress; houston hand-writes none. That matters beyond tidiness: the
|
|
205
|
+
* chart's own template is what path-splits `/sockjs` and `/websocket` to the ddp-streamer
|
|
206
|
+
* when microservices are on, and emulating a template is the signal that the layer is wrong.
|
|
207
|
+
*/
|
|
208
|
+
function ingressValues(host, { ingressClass, secretName, issuer = certmanager_1.CA_ISSUER, }) {
|
|
209
|
+
return {
|
|
210
|
+
host,
|
|
211
|
+
ingress: {
|
|
212
|
+
enabled: true,
|
|
213
|
+
ingressClassName: ingressClass,
|
|
214
|
+
annotations: { 'cert-manager.io/cluster-issuer': issuer },
|
|
215
|
+
tls: [{ secretName, hosts: [host] }],
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
}
|