@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,452 @@
|
|
|
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.CERT_MANAGER_INTERVAL = exports.CERT_MANAGER_DEPLOYMENTS = exports.ACME_ISSUER_STAGING = exports.ACME_ISSUER = exports.ACME_STAGING = exports.ACME_PRODUCTION = exports.CERT_WAIT_INTERVAL = exports.CERT_WAIT_TRIES = exports.ISSUER_WAIT_INTERVAL = exports.CA_ISSUER_SECRET = exports.CA_ISSUER = exports.CERT_MANAGER_MANIFEST = exports.CERT_MANAGER_VERSION = void 0;
|
|
37
|
+
exports.certManagerInstalled = certManagerInstalled;
|
|
38
|
+
exports.issuerName = issuerName;
|
|
39
|
+
exports.issuerDirectory = issuerDirectory;
|
|
40
|
+
exports.certManagerInstallHint = certManagerInstallHint;
|
|
41
|
+
exports.ensureCertManager = ensureCertManager;
|
|
42
|
+
exports.caIssuerManifest = caIssuerManifest;
|
|
43
|
+
exports.ensureCaIssuer = ensureCaIssuer;
|
|
44
|
+
exports.acmeIssuerManifest = acmeIssuerManifest;
|
|
45
|
+
exports.ensureAcmeIssuer = ensureAcmeIssuer;
|
|
46
|
+
exports.ensureIssuer = ensureIssuer;
|
|
47
|
+
exports.waitForCertificate = waitForCertificate;
|
|
48
|
+
exports.tlsSecretFor = tlsSecretFor;
|
|
49
|
+
/**
|
|
50
|
+
* cert-manager and the issuers a workspace's ingress names.
|
|
51
|
+
*
|
|
52
|
+
* Installed only into a cluster houston may write to, and only after every read-only refusal
|
|
53
|
+
* has passed -- an install left behind by a refusal is the defect this ordering was measured
|
|
54
|
+
* against.
|
|
55
|
+
*/
|
|
56
|
+
const fs = __importStar(require("node:fs"));
|
|
57
|
+
const YAML = __importStar(require("yaml"));
|
|
58
|
+
const errors_1 = require("../../lib/errors");
|
|
59
|
+
const events_1 = require("../../lib/events");
|
|
60
|
+
const tls_local_1 = require("../tls-local");
|
|
61
|
+
const ask_1 = require("./ask");
|
|
62
|
+
const context_1 = require("./context");
|
|
63
|
+
const exec_1 = require("./exec");
|
|
64
|
+
const monitoring_1 = require("./monitoring");
|
|
65
|
+
const names_1 = require("./names");
|
|
66
|
+
const release_1 = require("./release");
|
|
67
|
+
const realSleep = (seconds) => new Promise((resolve) => setTimeout(resolve, seconds * 1000));
|
|
68
|
+
/**
|
|
69
|
+
* Whether cert-manager can issue in this cluster.
|
|
70
|
+
*
|
|
71
|
+
* Keyed on the CRD rather than on a Deployment name or a helm release: the release can be
|
|
72
|
+
* named anything, and `installCRDs` versus `crds.enabled` differ by cert-manager version --
|
|
73
|
+
* but nothing can issue a Certificate without the CRD, and its absence is exactly the
|
|
74
|
+
* failure that reads as "no matches for kind ClusterIssuer".
|
|
75
|
+
*/
|
|
76
|
+
async function certManagerInstalled(context) {
|
|
77
|
+
const res = await exec_1.kube.run(['kubectl', '--context', context, 'get', 'crd', 'certificates.cert-manager.io', '-o', 'name'], { own: (0, names_1.isOurs)(context) });
|
|
78
|
+
return res.returncode === 0 && res.stdout.includes('certificates.cert-manager.io');
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The pinned cert-manager release, and the command a person runs to get it. The OFFICIAL
|
|
82
|
+
* Rocket.Chat guide installs cert-manager with kubectl, not helm, and lists it as a
|
|
83
|
+
* PREREQUISITE -- so houston requires it and names this, rather than installing it into a
|
|
84
|
+
* cluster it does not own.
|
|
85
|
+
*
|
|
86
|
+
* Following the guide here is not deference, it deletes work: verified against the real
|
|
87
|
+
* v1.21.1 manifest, it contains no `startupapicheck` and no Job of any kind, so nothing can
|
|
88
|
+
* fail a post-install hook, and it carries the six CRDs directly, so the
|
|
89
|
+
* `crds.enabled`-versus-`installCRDs` trap has nowhere to happen.
|
|
90
|
+
*/
|
|
91
|
+
exports.CERT_MANAGER_VERSION = 'v1.21.1';
|
|
92
|
+
exports.CERT_MANAGER_MANIFEST = `https://github.com/cert-manager/cert-manager/releases/download/${exports.CERT_MANAGER_VERSION}/cert-manager.yaml`;
|
|
93
|
+
/**
|
|
94
|
+
* houston's own issuer, and the Secret holding the CA that backs it. A ClusterIssuer reads
|
|
95
|
+
* its Secret from the cluster-resource namespace, which for a default cert-manager install
|
|
96
|
+
* is its own.
|
|
97
|
+
*/
|
|
98
|
+
exports.CA_ISSUER = 'houston-ca';
|
|
99
|
+
exports.CA_ISSUER_SECRET = 'houston-ca';
|
|
100
|
+
exports.ISSUER_WAIT_INTERVAL = 2.0;
|
|
101
|
+
/**
|
|
102
|
+
* How long to wait for cert-manager to issue. 45 x 2 s was too tight for a FIRST issuance on
|
|
103
|
+
* a cold cluster: the ACME account has to be registered, the order placed, the http-01
|
|
104
|
+
* challenge served and validated by Let's Encrypt from outside, and on a first workspace all
|
|
105
|
+
* of that starts only once the image pull has finished.
|
|
106
|
+
*
|
|
107
|
+
* OBSERVED through the GUI on a fresh EKS cluster -- the wait expired, the ingress answered
|
|
108
|
+
* with its own default certificate, and the certificate arrived about a minute later. The
|
|
109
|
+
* cost of waiting longer is bounded and only paid with `--domain`; the cost of giving up
|
|
110
|
+
* early is a create that ends by reporting a failure that is not one.
|
|
111
|
+
*/
|
|
112
|
+
exports.CERT_WAIT_TRIES = 90;
|
|
113
|
+
exports.CERT_WAIT_INTERVAL = 2.0;
|
|
114
|
+
/**
|
|
115
|
+
* The ACME directories, and two ISSUER NAMES rather than one with a flag. Switching staging
|
|
116
|
+
* on and off must not reuse an account registered against the other directory:
|
|
117
|
+
* `privateKeySecretRef` holds the ACME account key, and pointing a production order at a
|
|
118
|
+
* staging account fails in a way that names neither.
|
|
119
|
+
*/
|
|
120
|
+
exports.ACME_PRODUCTION = 'https://acme-v02.api.letsencrypt.org/directory';
|
|
121
|
+
exports.ACME_STAGING = 'https://acme-staging-v02.api.letsencrypt.org/directory';
|
|
122
|
+
exports.ACME_ISSUER = 'houston-acme';
|
|
123
|
+
exports.ACME_ISSUER_STAGING = 'houston-acme-staging';
|
|
124
|
+
function issuerName(spec) {
|
|
125
|
+
if (spec.mode !== 'acme')
|
|
126
|
+
return exports.CA_ISSUER;
|
|
127
|
+
return spec.acmeStaging === true ? exports.ACME_ISSUER_STAGING : exports.ACME_ISSUER;
|
|
128
|
+
}
|
|
129
|
+
function issuerDirectory(spec) {
|
|
130
|
+
return spec.acmeStaging === true ? exports.ACME_STAGING : exports.ACME_PRODUCTION;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The three Deployments the official manifest creates. Waited for by name, because the
|
|
134
|
+
* manifest has no hooks and `kubectl apply` returns the moment the objects are accepted --
|
|
135
|
+
* and a ClusterIssuer created before the webhook is serving is accepted and then never
|
|
136
|
+
* reconciled.
|
|
137
|
+
*/
|
|
138
|
+
exports.CERT_MANAGER_DEPLOYMENTS = [
|
|
139
|
+
'cert-manager',
|
|
140
|
+
'cert-manager-webhook',
|
|
141
|
+
'cert-manager-cainjector',
|
|
142
|
+
];
|
|
143
|
+
exports.CERT_MANAGER_INTERVAL = 3.0;
|
|
144
|
+
/** What to run to satisfy the prerequisite, quoted from the official guide. */
|
|
145
|
+
function certManagerInstallHint() {
|
|
146
|
+
return `kubectl apply -f ${exports.CERT_MANAGER_MANIFEST}`;
|
|
147
|
+
}
|
|
148
|
+
/** Wait for cert-manager's deployments and CRDs after applying its manifest. */
|
|
149
|
+
async function waitForCertManager(context, emit, sleep) {
|
|
150
|
+
// THE WEBHOOK, not just the apply. `kubectl apply` returns as soon as the objects are
|
|
151
|
+
// accepted, and a ClusterIssuer created before the webhook is serving is accepted and then
|
|
152
|
+
// never reconciled -- no `.status` at all, so no Certificate ever issues and nothing says
|
|
153
|
+
// why.
|
|
154
|
+
for (const name of exports.CERT_MANAGER_DEPLOYMENTS) {
|
|
155
|
+
await exec_1.kube.run([
|
|
156
|
+
'kubectl',
|
|
157
|
+
'--context',
|
|
158
|
+
context,
|
|
159
|
+
'-n',
|
|
160
|
+
monitoring_1.CERT_MANAGER_NAMESPACE,
|
|
161
|
+
'rollout',
|
|
162
|
+
'status',
|
|
163
|
+
`deployment/${name}`,
|
|
164
|
+
'--timeout=180s',
|
|
165
|
+
], { timeout: names_1.INSTALL_TIMEOUT, own: (0, names_1.isOurs)(context) });
|
|
166
|
+
}
|
|
167
|
+
// And the CRD, which is what "can this cluster issue a Certificate" actually means.
|
|
168
|
+
let crds = false;
|
|
169
|
+
for (let attempt = 0; attempt < names_1.tuning.CERT_MANAGER_TRIES; attempt += 1) {
|
|
170
|
+
if (await certManagerInstalled(context)) {
|
|
171
|
+
crds = true;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
if (attempt < names_1.tuning.CERT_MANAGER_TRIES - 1)
|
|
175
|
+
await sleep(exports.CERT_MANAGER_INTERVAL);
|
|
176
|
+
}
|
|
177
|
+
if (!crds) {
|
|
178
|
+
throw new errors_1.CreateFailedError(`cert-manager was applied to '${context}' but its CRDs never appeared, so nothing can ` +
|
|
179
|
+
`issue a Certificate there. \`kubectl -n ${monitoring_1.CERT_MANAGER_NAMESPACE} get pods\` and ` +
|
|
180
|
+
'`kubectl get crd | grep cert-manager`.');
|
|
181
|
+
}
|
|
182
|
+
await waitForTheWebhook(context, sleep);
|
|
183
|
+
(0, events_1.info)(emit, 'cert-manager: installed and answering', { phase: 'tls' });
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* ANSWERING, which a Ready webhook pod is not yet: prove it with the object that is next.
|
|
187
|
+
*
|
|
188
|
+
* The webhook pod rolls out Ready as soon as it serves, but the API server calls it with the
|
|
189
|
+
* CA bundle cainjector copies into its webhook configurations, and on a fresh install that
|
|
190
|
+
* copy lands some seconds LATER. Until it does, every create of a cert-manager object fails
|
|
191
|
+
* with `failed calling webhook "webhook.cert-manager.io" ... x509: certificate signed by
|
|
192
|
+
* unknown authority`. MEASURED on a k3s playground: the apply straight after "installed and
|
|
193
|
+
* answering" failed that way (exit 7), in both implementations, including a run that met
|
|
194
|
+
* cert-manager's images already cached; an install that pulled its images had simply been
|
|
195
|
+
* slow enough to miss the window.
|
|
196
|
+
*
|
|
197
|
+
* So the wait asks the webhook itself: a server-side dry-run of the ClusterIssuer that
|
|
198
|
+
* `ensureCaIssuer` creates next goes through the same admission call and persists nothing.
|
|
199
|
+
*
|
|
200
|
+
* Bounded, but by its OWN bound, `tuning.CERT_MANAGER_WEBHOOK_TRIES` (60 x 3 s = 180 s, the
|
|
201
|
+
* rollout waits' `--timeout=180s`), not the CRD wait's 60 s. cainjector injects the bundle
|
|
202
|
+
* only once it holds its leader lease, and cert-manager's two Leases,
|
|
203
|
+
* `kube-system/cert-manager-cainjector-leader-election` and
|
|
204
|
+
* `kube-system/cert-manager-controller`, are created at run time, are not in the manifest,
|
|
205
|
+
* and OUTLIVE `kubectl delete -f` of it. A new candidate that finds a lease it does not hold
|
|
206
|
+
* waits a full lease duration (60 s) from when it first sees it, plus its retry period,
|
|
207
|
+
* however long ago the old holder died. MEASURED on a k3s playground after a
|
|
208
|
+
* fresh apply of the pinned v1.21.1 manifest on a cluster that had had cert-manager: the
|
|
209
|
+
* three Deployments rolled out at +12 s, cainjector logged "Attempting to acquire leader
|
|
210
|
+
* lease" at 05:51:48 and "Successfully acquired lease" at 05:53:07, and the webhook first
|
|
211
|
+
* accepted this dry-run at +89 s. At 60 s the wait refused every such cluster, in the
|
|
212
|
+
* previous implementation as here (the third run, exit 7); the first run's first install
|
|
213
|
+
* passed only because its cluster had never had cert-manager.
|
|
214
|
+
*/
|
|
215
|
+
async function waitForTheWebhook(context, sleep) {
|
|
216
|
+
let res;
|
|
217
|
+
for (let attempt = 0; attempt < names_1.tuning.CERT_MANAGER_WEBHOOK_TRIES; attempt += 1) {
|
|
218
|
+
res = await exec_1.kube.run(['kubectl', '--context', context, 'apply', '--dry-run=server', '-f', '-'], { input: caClusterIssuerManifest(), own: (0, names_1.isOurs)(context) });
|
|
219
|
+
if (res.returncode === 0)
|
|
220
|
+
return;
|
|
221
|
+
if (attempt < names_1.tuning.CERT_MANAGER_WEBHOOK_TRIES - 1)
|
|
222
|
+
await sleep(exports.CERT_MANAGER_INTERVAL);
|
|
223
|
+
}
|
|
224
|
+
throw new errors_1.CreateFailedError(`cert-manager's webhook in '${context}' never accepted an object, so nothing can ` +
|
|
225
|
+
`create an issuer or a Certificate there: ${(0, ask_1.why)(res)}` +
|
|
226
|
+
`. \`kubectl --context ${context} -n ${monitoring_1.CERT_MANAGER_NAMESPACE} logs ` +
|
|
227
|
+
`deploy/cert-manager-webhook\`, and \`kubectl --context ${context} get ` +
|
|
228
|
+
'validatingwebhookconfiguration cert-manager-webhook -o yaml` for its caBundle.');
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Adopt cert-manager if the cluster has it, install it if not.
|
|
232
|
+
*
|
|
233
|
+
* Installed exactly as the guide installs it -- by kubectl, not helm -- and that choice is
|
|
234
|
+
* load-bearing rather than stylistic: the static manifest contains no `startupapicheck` and
|
|
235
|
+
* no Job at all, so nothing can fail a post-install hook.
|
|
236
|
+
*
|
|
237
|
+
* Only on a cluster that is on this machine, UNLESS INVITED. Six CRDs and an admission
|
|
238
|
+
* webhook are a change to what a cluster IS, for every workload in it -- not something to do
|
|
239
|
+
* to somebody else's ON THE WAY TO BOOTING A REPRO. That last clause is the whole of the
|
|
240
|
+
* rule, and locality was standing in for it: what makes an implicit install wrong is that
|
|
241
|
+
* nobody asked, not where the cluster is.
|
|
242
|
+
*
|
|
243
|
+
* Never removed. `kubectl delete -f` takes the CRDs, and removing the CRDs garbage-collects
|
|
244
|
+
* every Certificate and Issuer in the cluster -- the user's included.
|
|
245
|
+
*/
|
|
246
|
+
async function ensureCertManager({ context, distribution = '', invited = false, emit = events_1.nullEmit, sleep = realSleep, }) {
|
|
247
|
+
if (await certManagerInstalled(context)) {
|
|
248
|
+
(0, events_1.info)(emit, 'cert-manager: already in this cluster', { phase: 'tls' });
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
if (!invited &&
|
|
252
|
+
!(await (0, context_1.isLocalCluster)(distribution || (await (0, context_1.distributionOf)(context)), context))) {
|
|
253
|
+
throw new errors_1.PreflightError(`cluster '${context}' has no cert-manager, and it is not on this machine, so houston ` +
|
|
254
|
+
'will not install one: six CRDs and an admission webhook change what that cluster ' +
|
|
255
|
+
'is, for every workload in it. The official Rocket.Chat guide installs it as a ' +
|
|
256
|
+
`prerequisite:\n ${certManagerInstallHint()}\n houston adopts it as soon as it ` +
|
|
257
|
+
'is there.');
|
|
258
|
+
}
|
|
259
|
+
(0, events_1.info)(emit, `no cert-manager in '${context}' — installing ${exports.CERT_MANAGER_VERSION} (once per ` +
|
|
260
|
+
"cluster, the guide's own command)", { phase: 'tls', pct: 10 });
|
|
261
|
+
const res = await exec_1.kube.run(['kubectl', '--context', context, 'apply', '-f', exports.CERT_MANAGER_MANIFEST], { timeout: names_1.INSTALL_TIMEOUT, own: (0, names_1.isOurs)(context) });
|
|
262
|
+
if (res.returncode !== 0) {
|
|
263
|
+
throw new errors_1.CreateFailedError(`could not install cert-manager into '${context}': ${(0, ask_1.why)(res)} — it is one command ` +
|
|
264
|
+
`if you would rather run it yourself: ${certManagerInstallHint()}`);
|
|
265
|
+
}
|
|
266
|
+
await waitForCertManager(context, emit, sleep);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* The CA Secret and the ClusterIssuer that signs from it.
|
|
270
|
+
*
|
|
271
|
+
* `stringData`, so Kubernetes does the base64 -- the PEM never has to be re-encoded
|
|
272
|
+
* correctly here.
|
|
273
|
+
*
|
|
274
|
+
* A `ca` issuer rather than an `acme` one is what makes `--https` and `--domain` the same
|
|
275
|
+
* values.yaml with one field different.
|
|
276
|
+
*/
|
|
277
|
+
function caIssuerManifest(certPem, keyPem) {
|
|
278
|
+
const indent = (pem) => pem
|
|
279
|
+
.trim()
|
|
280
|
+
.split('\n')
|
|
281
|
+
.map((line) => ` ${line}`)
|
|
282
|
+
.join('\n');
|
|
283
|
+
return (`---\napiVersion: v1\nkind: Secret\nmetadata:\n` +
|
|
284
|
+
` name: ${exports.CA_ISSUER_SECRET}\n namespace: ${monitoring_1.CERT_MANAGER_NAMESPACE}\n` +
|
|
285
|
+
` labels:\n ${names_1.OWNER_LABEL_KEY}: ${names_1.OWNER_LABEL_VALUE}\n` +
|
|
286
|
+
`type: kubernetes.io/tls\nstringData:\n` +
|
|
287
|
+
` tls.crt: |\n${indent(certPem)}\n` +
|
|
288
|
+
` tls.key: |\n${indent(keyPem)}\n` +
|
|
289
|
+
caClusterIssuerManifest());
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* The ClusterIssuer half of `caIssuerManifest`, on its own: it carries no key, so
|
|
293
|
+
* `waitForTheWebhook` can dry-run it before anything is created.
|
|
294
|
+
*/
|
|
295
|
+
function caClusterIssuerManifest() {
|
|
296
|
+
return (`---\napiVersion: cert-manager.io/v1\nkind: ClusterIssuer\nmetadata:\n` +
|
|
297
|
+
` name: ${exports.CA_ISSUER}\n` +
|
|
298
|
+
` labels:\n ${names_1.OWNER_LABEL_KEY}: ${names_1.OWNER_LABEL_VALUE}\n` +
|
|
299
|
+
`spec:\n ca:\n secretName: ${exports.CA_ISSUER_SECRET}\n`);
|
|
300
|
+
}
|
|
301
|
+
/** Whether an issuer answer carries a Ready=True condition, and what it said. */
|
|
302
|
+
function readyCondition(doc) {
|
|
303
|
+
const status = doc.status;
|
|
304
|
+
const conditions = status !== null && typeof status === 'object'
|
|
305
|
+
? (status.conditions ?? [])
|
|
306
|
+
: [];
|
|
307
|
+
for (const condition of conditions) {
|
|
308
|
+
if (condition.type === 'Ready' && String(condition.status) === 'True') {
|
|
309
|
+
return String(condition.message ?? '');
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Put houston's CA in the cluster as a `ca` ClusterIssuer, and wait for it.
|
|
316
|
+
*
|
|
317
|
+
* THE WAIT IS THE POINT: a ClusterIssuer created before cert-manager is ready is ACCEPTED
|
|
318
|
+
* and then never reconciled -- no `.status` at all, so no Certificate ever issues and
|
|
319
|
+
* nothing says why. Waiting for `Ready=True` here means a workspace either has a working
|
|
320
|
+
* issuer or a refusal, and never the silent third thing.
|
|
321
|
+
*/
|
|
322
|
+
async function ensureCaIssuer({ context, emit = events_1.nullEmit, sleep = realSleep, }) {
|
|
323
|
+
const [keyPath, crtPath] = await (0, tls_local_1.ensureCa)();
|
|
324
|
+
(0, events_1.info)(emit, `issuer ${exports.CA_ISSUER} from houston's own CA (once per cluster)`, { phase: 'tls' });
|
|
325
|
+
await (0, release_1.apply)(caIssuerManifest(fs.readFileSync(crtPath, 'utf8'), fs.readFileSync(keyPath, 'utf8')), { namespace: monitoring_1.CERT_MANAGER_NAMESPACE, context });
|
|
326
|
+
for (let attempt = 0; attempt < names_1.tuning.ISSUER_WAIT_TRIES; attempt += 1) {
|
|
327
|
+
const seen = await (0, ask_1.askObject)('clusterissuer', exports.CA_ISSUER, { context });
|
|
328
|
+
if ((0, ask_1.present)(seen)) {
|
|
329
|
+
const message = readyCondition(seen.doc);
|
|
330
|
+
if (message !== null) {
|
|
331
|
+
(0, events_1.info)(emit, `issuer ${exports.CA_ISSUER} ready — ${message || 'signing CA verified'}`, {
|
|
332
|
+
phase: 'tls',
|
|
333
|
+
});
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (attempt < names_1.tuning.ISSUER_WAIT_TRIES - 1)
|
|
338
|
+
await sleep(exports.ISSUER_WAIT_INTERVAL);
|
|
339
|
+
}
|
|
340
|
+
throw new errors_1.PreflightError(`the ClusterIssuer ${exports.CA_ISSUER} did not become ready in cluster '${context}'. ` +
|
|
341
|
+
'cert-manager accepts an issuer it is not yet able to reconcile and then says ' +
|
|
342
|
+
'nothing, so a workspace built on it would never get a certificate. `kubectl ' +
|
|
343
|
+
`describe clusterissuer ${exports.CA_ISSUER}\`, then try again.`);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* The official guide's own ClusterIssuer, with houston's name on it.
|
|
347
|
+
*
|
|
348
|
+
* `ingressClassName` rather than the guide's `class`, which is the deprecated spelling of
|
|
349
|
+
* the same field -- cert-manager 1.21 accepts both, and naming the current field is what
|
|
350
|
+
* stops this being a deprecation warning later.
|
|
351
|
+
*
|
|
352
|
+
* http01, and NOT tls-alpn, because cert-manager does not implement tls-alpn at all. That is
|
|
353
|
+
* worth stating where the choice is made: the Compose path defaults to TLS-ALPN and this one
|
|
354
|
+
* cannot.
|
|
355
|
+
*
|
|
356
|
+
* BUILT AS A DOCUMENT, NOT A STRING. This was string interpolation, and `acmeEmail` is
|
|
357
|
+
* caller-supplied -- so an address carrying newlines added its own keys to `spec.acme` and
|
|
358
|
+
* the result was valid YAML cert-manager accepts. A ClusterIssuer is CLUSTER-SCOPED and
|
|
359
|
+
* shared by every workspace on the box, so `skipTLSVerify: true` injected here would apply
|
|
360
|
+
* to all of them.
|
|
361
|
+
*/
|
|
362
|
+
function acmeIssuerManifest(spec, { ingressClass }) {
|
|
363
|
+
const doc = {
|
|
364
|
+
apiVersion: 'cert-manager.io/v1',
|
|
365
|
+
kind: 'ClusterIssuer',
|
|
366
|
+
metadata: { name: issuerName(spec), labels: { [names_1.OWNER_LABEL_KEY]: names_1.OWNER_LABEL_VALUE } },
|
|
367
|
+
spec: {
|
|
368
|
+
acme: {
|
|
369
|
+
server: issuerDirectory(spec),
|
|
370
|
+
email: spec.acmeEmail ?? '',
|
|
371
|
+
privateKeySecretRef: { name: `${issuerName(spec)}-account-key` },
|
|
372
|
+
solvers: [{ http01: { ingress: { ingressClassName: ingressClass } } }],
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
// `---` and key order preserved: the document is written into the workspace directory for
|
|
377
|
+
// a human to read, and reordering it would make every diff noise.
|
|
378
|
+
return `---\n${YAML.stringify(doc, { compat: 'yaml-1.1', indentSeq: false, lineWidth: 0 })}`;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Register an ACME account in the cluster and wait for it. Idempotent.
|
|
382
|
+
*
|
|
383
|
+
* The wait is the same one `ensureCaIssuer` makes, but the failure it catches is different
|
|
384
|
+
* and more common: this issuer makes a real network call to Let's Encrypt to register an
|
|
385
|
+
* account, so a cluster with no egress, a wrong email or a rate-limited account fails HERE
|
|
386
|
+
* -- once, with a reason -- rather than silently per Certificate afterwards.
|
|
387
|
+
*/
|
|
388
|
+
async function ensureAcmeIssuer(spec, { context, ingressClass, emit = events_1.nullEmit, sleep = realSleep, }) {
|
|
389
|
+
const which = spec.acmeStaging === true ? 'staging' : 'production';
|
|
390
|
+
const name = issuerName(spec);
|
|
391
|
+
(0, events_1.info)(emit, `issuer ${name} — Let's Encrypt ${which}, http-01 via ${ingressClass} (once per cluster)`, { phase: 'tls' });
|
|
392
|
+
await (0, release_1.apply)(acmeIssuerManifest(spec, { ingressClass }), {
|
|
393
|
+
namespace: monitoring_1.CERT_MANAGER_NAMESPACE,
|
|
394
|
+
context,
|
|
395
|
+
});
|
|
396
|
+
for (let attempt = 0; attempt < names_1.tuning.ISSUER_WAIT_TRIES; attempt += 1) {
|
|
397
|
+
const seen = await (0, ask_1.askObject)('clusterissuer', name, { context });
|
|
398
|
+
if ((0, ask_1.present)(seen)) {
|
|
399
|
+
const message = readyCondition(seen.doc);
|
|
400
|
+
if (message !== null) {
|
|
401
|
+
(0, events_1.info)(emit, `issuer ${name} ready — ${message || 'ACME account registered'}`, {
|
|
402
|
+
phase: 'tls',
|
|
403
|
+
});
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (attempt < names_1.tuning.ISSUER_WAIT_TRIES - 1)
|
|
408
|
+
await sleep(exports.ISSUER_WAIT_INTERVAL);
|
|
409
|
+
}
|
|
410
|
+
throw new errors_1.PreflightError(`the ClusterIssuer ${name} did not become ready in cluster '${context}'. Registering an ` +
|
|
411
|
+
`ACME account is a real call to ${issuerDirectory(spec)} from inside the cluster, so ` +
|
|
412
|
+
'this is usually no egress from the pods, or a rejected contact address. `kubectl ' +
|
|
413
|
+
`describe clusterissuer ${name}\` says which.`);
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Make the issuer this workspace's Ingress is about to name.
|
|
417
|
+
*
|
|
418
|
+
* One call site, two mechanisms, chosen by the spec rather than by a branch at the caller --
|
|
419
|
+
* which is what keeps `--https` and `--domain` the same code path with a different issuer.
|
|
420
|
+
*/
|
|
421
|
+
async function ensureIssuer(spec, { context, ingressClass, emit = events_1.nullEmit, }) {
|
|
422
|
+
if (spec.mode === 'acme') {
|
|
423
|
+
await ensureAcmeIssuer(spec, { context, ingressClass, emit });
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
await ensureCaIssuer({ context, emit });
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Wait for cert-manager to issue `name`. Returns whether it did.
|
|
431
|
+
*
|
|
432
|
+
* NOT fatal, and deliberately: the workspace itself is up and reachable on its port-forward
|
|
433
|
+
* whatever the certificate does, so a certificate that has not arrived is a thing to SAY
|
|
434
|
+
* rather than a reason to destroy a workspace somebody waited minutes for.
|
|
435
|
+
*/
|
|
436
|
+
async function waitForCertificate(name, { namespace, context, emit = events_1.nullEmit, sleep = realSleep, }) {
|
|
437
|
+
for (let attempt = 0; attempt < exports.CERT_WAIT_TRIES; attempt += 1) {
|
|
438
|
+
const seen = await (0, ask_1.askObject)('certificate', name, { namespace, context });
|
|
439
|
+
if ((0, ask_1.present)(seen) && readyCondition(seen.doc) !== null)
|
|
440
|
+
return true;
|
|
441
|
+
if (attempt < exports.CERT_WAIT_TRIES - 1)
|
|
442
|
+
await sleep(exports.CERT_WAIT_INTERVAL);
|
|
443
|
+
}
|
|
444
|
+
(0, events_1.warn)(emit, `the certificate ${name} in ${namespace} is not Ready yet — the workspace is up either ` +
|
|
445
|
+
`way. \`kubectl -n ${namespace} describe certificate ${name}\` says what cert-manager ` +
|
|
446
|
+
'is waiting for.', { phase: 'tls' });
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
/** The Secret cert-manager fills for a workspace's Ingress. */
|
|
450
|
+
function tlsSecretFor(name) {
|
|
451
|
+
return `${name}-tls`;
|
|
452
|
+
}
|