@intentius/chant 0.124.101 → 0.124.103
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/dist/ci-evidence-claims.d.ts +12 -0
- package/dist/ci-evidence-claims.js +12 -0
- package/dist/cli/commands/onboard.js +8 -8
- package/dist/cli/handlers/release-init.js +53 -19
- package/dist/cli/handlers/release.d.ts +1 -1
- package/dist/cli/handlers/release.js +12 -9
- package/dist/cli/main.js +13 -2
- package/dist/cli/parse-args.js +5 -0
- package/dist/cli/registry.d.ts +2 -0
- package/dist/cli/release-commands/cut.js +4 -3
- package/dist/cli/release-commands/init.js +4 -1
- package/dist/cli/release-commands/workflow.js +4 -2
- package/dist/cloud-lister/index.d.ts +4 -1
- package/dist/cloud-lister/index.js +2 -1
- package/dist/cloud-lister/kubernetes-components.d.ts +56 -0
- package/dist/cloud-lister/kubernetes-components.js +641 -0
- package/dist/cloud-lister/kubernetes.d.ts +18 -0
- package/dist/cloud-lister/kubernetes.js +26 -1
- package/dist/cloud-lister/mask.d.ts +5 -1
- package/dist/cloud-lister/mask.js +14 -5
- package/dist/config-import.d.ts +1 -1
- package/dist/config-import.js +6 -2
- package/dist/config-sandbox.d.ts +1 -1
- package/dist/config-sandbox.js +3 -3
- package/dist/config.d.ts +75 -1
- package/dist/config.js +27 -2
- package/dist/deep-observation.js +9 -3
- package/dist/floor-table.data.js +13 -6
- package/dist/lexicon.d.ts +4 -2
- package/dist/lifecycle/__fixtures__/package-files.d.ts +32 -0
- package/dist/lifecycle/__fixtures__/package-files.js +72 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.js +5 -0
- package/dist/lifecycle/publish-credentials.d.ts +1 -1
- package/dist/lifecycle/publish-credentials.js +5 -0
- package/dist/lifecycle/publish-declaration.d.ts +123 -0
- package/dist/lifecycle/publish-declaration.js +141 -2
- package/dist/lifecycle/publish-helm.d.ts +83 -0
- package/dist/lifecycle/publish-helm.js +451 -0
- package/dist/lifecycle/publish-maven.d.ts +79 -0
- package/dist/lifecycle/publish-maven.js +363 -0
- package/dist/lifecycle/publish-mcp-registry.js +1 -2
- package/dist/lifecycle/publish-npm.d.ts +27 -1
- package/dist/lifecycle/publish-npm.js +52 -2
- package/dist/lifecycle/publish-nuget.d.ts +93 -0
- package/dist/lifecycle/publish-nuget.js +376 -0
- package/dist/lifecycle/publish-oci.d.ts +57 -1
- package/dist/lifecycle/publish-oci.js +1 -1
- package/dist/lifecycle/publish-package-files.d.ts +16 -0
- package/dist/lifecycle/publish-package-files.js +39 -0
- package/dist/lifecycle/publish-pypi.d.ts +2 -0
- package/dist/lifecycle/publish-pypi.js +1 -1
- package/dist/lifecycle/publish-rubygems.d.ts +84 -0
- package/dist/lifecycle/publish-rubygems.js +365 -0
- package/dist/lifecycle/publish-targets.d.ts +10 -0
- package/dist/lifecycle/publish-targets.js +22 -0
- package/dist/lifecycle/publish-train-names.d.ts +4 -1
- package/dist/lifecycle/publish-train-names.js +5 -0
- package/dist/lifecycle/release-artifacts.d.ts +80 -2
- package/dist/lifecycle/release-artifacts.js +241 -5
- package/dist/lifecycle/release-cut.d.ts +6 -1
- package/dist/lifecycle/release-cut.js +15 -0
- package/dist/lifecycle/release-doctor.js +208 -6
- package/dist/lifecycle/release-init-registries.d.ts +48 -0
- package/dist/lifecycle/release-init-registries.js +97 -0
- package/dist/lifecycle/release-init.d.ts +22 -2
- package/dist/lifecycle/release-init.js +139 -13
- package/dist/lifecycle/release-next.js +1 -2
- package/dist/lifecycle/release-publish.d.ts +1 -1
- package/dist/lifecycle/release-publish.js +1 -1
- package/dist/lifecycle/release-tag.js +1 -2
- package/dist/op/local-executor.d.ts +1 -1
- package/dist/op/local-executor.js +2 -2
- package/dist/op/op-waves-evidence.js +9 -2
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/sensitive-key.d.ts +12 -0
- package/dist/sensitive-key.js +52 -0
- package/dist/tool-pins.d.ts +2 -0
- package/dist/tool-pins.js +12 -0
- package/dist/ts-loader.d.ts +8 -0
- package/dist/ts-loader.js +19 -0
- package/dist/wave-runtime.mjs +325 -325
- package/dist/workspace/lexicon-outputs.d.ts +1 -1
- package/dist/workspace/lexicon-outputs.js +1 -1
- package/dist/workspace/release-steps/index.js +4 -0
- package/dist/workspace/release-steps/nfpm.d.ts +13 -0
- package/dist/workspace/release-steps/nfpm.js +29 -0
- package/dist/workspace/release-steps/nuget.d.ts +14 -0
- package/dist/workspace/release-steps/nuget.js +16 -0
- package/dist/workspace/release-steps/targets.d.ts +2 -2
- package/dist/workspace/release-steps/targets.js +3 -3
- package/dist/workspace/release-train-workflow.d.ts +27 -2
- package/dist/workspace/release-train-workflow.js +171 -14
- package/dist/workspace/release-train.js +5 -1
- package/dist/workspace/release-workflow.d.ts +39 -3
- package/dist/workspace/release-workflow.js +80 -24
- package/dist/workspace/train-artifacts.d.ts +107 -0
- package/dist/workspace/train-artifacts.js +239 -0
- package/dist/workspace/train-cut.d.ts +14 -2
- package/dist/workspace/train-cut.js +49 -7
- package/dist/workspace/train-prepare.d.ts +6 -3
- package/dist/workspace/train-prepare.js +54 -8
- package/dist/workspace/train-publish.d.ts +9 -0
- package/dist/workspace/train-publish.js +29 -4
- package/dist/workspace/train-shell.d.ts +5 -0
- package/dist/workspace/train-shell.js +17 -0
- package/dist/workspace/trust/check-evidence-report.d.ts +3 -7
- package/dist/workspace/trust/check-evidence-report.js +3 -7
- package/package.json +1 -1
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* chant#5252: the applications in a live Kubernetes read, inferred from the
|
|
3
|
+
* objects and drawn as chant components.
|
|
4
|
+
*
|
|
5
|
+
* A cluster read (`listCloud` through `indexCloud`, ../lifecycle/cloud-index.ts)
|
|
6
|
+
* gives every object and the references between them, and nothing declares
|
|
7
|
+
* an application. {@link inferK8sComponents} draws one from each top-level
|
|
8
|
+
* workload and what it reaches, and writes them in the shape `chant graph
|
|
9
|
+
* --components --format ir` writes (../cli/handlers/graph.ts): one
|
|
10
|
+
* `Component` node per application with `attrs.wave` and `attrs.liveNames`,
|
|
11
|
+
* a `dependsOn` edge from consumer to producer, and `groups.byWave`. A reader
|
|
12
|
+
* of the declared component graph reads this one with no new code.
|
|
13
|
+
*
|
|
14
|
+
* Seeds. A workload (Deployment, StatefulSet, DaemonSet, CronJob, Job,
|
|
15
|
+
* ReplicaSet, Pod) that no other workload controls, so a Job, ReplicaSet or
|
|
16
|
+
* Pod with no workload owner seeds as well and nothing running is left out.
|
|
17
|
+
* Owner references are followed by uid, and by kind and name in the
|
|
18
|
+
* namespace when the uid is not in the read.
|
|
19
|
+
*
|
|
20
|
+
* Boundaries. The first of these on a seed's own labels and annotations
|
|
21
|
+
* names its unit, and seeds of one namespace with the same unit are one
|
|
22
|
+
* application: `app.kubernetes.io/part-of`, `argocd.argoproj.io/instance`,
|
|
23
|
+
* the `meta.helm.sh/release-name` annotation, `app.kubernetes.io/instance`,
|
|
24
|
+
* and `app.kubernetes.io/name` on an object a k8s composite made
|
|
25
|
+
* (`app.kubernetes.io/managed-by: chant`). A seed with none stands alone.
|
|
26
|
+
* An Argo CD instance is one application across every namespace it deploys
|
|
27
|
+
* into, since one Application can name several.
|
|
28
|
+
*
|
|
29
|
+
* Names. An application is named by its unit's value, or by its workload's
|
|
30
|
+
* name when it has no unit. Inside one namespace a second unit with a taken
|
|
31
|
+
* name is told apart by its kind (`cronjob-web`) or its label
|
|
32
|
+
* (`instance-web`). When two namespaces in one read give the same name, each
|
|
33
|
+
* is written `<namespace>/<name>`; an Argo CD instance keeps its plain name.
|
|
34
|
+
* A read of one namespace never qualifies a name.
|
|
35
|
+
*
|
|
36
|
+
* Membership. An application takes in its seeds' runtime children, the
|
|
37
|
+
* Services that select their pods (with those Services' Endpoints and
|
|
38
|
+
* EndpointSlices), the Ingresses and HTTPRoutes that reach those Services,
|
|
39
|
+
* the autoscalers, disruption budgets and network policies that target them,
|
|
40
|
+
* and the ConfigMaps, Secrets, claims and ServiceAccount the pod template
|
|
41
|
+
* and the running Pods name, with any ExternalSecret that writes one of those
|
|
42
|
+
* Secrets. An object two or more applications take in is shared: it is in no
|
|
43
|
+
* application's members, and {@link InferredK8sComponents.shared} lists it.
|
|
44
|
+
*
|
|
45
|
+
* dependsOn. An env value in a seed's pod template, or a value in a
|
|
46
|
+
* ConfigMap the application uses, that names another application's Service
|
|
47
|
+
* by its cluster DNS name (`svc.ns.svc`, `svc.ns.svc.cluster.local`), or by
|
|
48
|
+
* its bare name inside the reader's namespace when that is the whole value or
|
|
49
|
+
* a URL's host.
|
|
50
|
+
*
|
|
51
|
+
* Health. Each application's `attrs.status` sums the lister's
|
|
52
|
+
* `workloadStatus` views (./kubernetes.ts): ready over desired replicas for
|
|
53
|
+
* its workloads, and the restarts of every Pod they run.
|
|
54
|
+
*
|
|
55
|
+
* Secrets. The lister keeps a pod spec's Secret names readable and masks the
|
|
56
|
+
* rest (`podSecretNameView`, ../sensitive-key.ts), so a mounted Secret is
|
|
57
|
+
* taken in. A reference that still reads as masked (a read by an older
|
|
58
|
+
* lister) is left out, and a note says so. Pure, and it reads only
|
|
59
|
+
* each node's listed type, location, native id, attributes and uid, so a
|
|
60
|
+
* graph typed without the k8s lexicon gives the same answer.
|
|
61
|
+
*/
|
|
62
|
+
import { MASKED as TYPED_MASKED } from "../deep-observation.js";
|
|
63
|
+
import { MASKED as LISTED_MASKED } from "./mask.js";
|
|
64
|
+
/** The first chant with `inferK8sComponents`, the applications of a live Kubernetes read as a component graph (#5252). */
|
|
65
|
+
export const K8S_COMPONENTS_FLOOR = "0.124.102";
|
|
66
|
+
const WORKLOAD_KINDS = new Set(["Deployment", "StatefulSet", "DaemonSet", "CronJob", "Job", "ReplicaSet", "Pod"]);
|
|
67
|
+
const WORKLOAD_GROUPS = new Set(["", "apps", "batch"]);
|
|
68
|
+
const ROLE_OF_KIND = {
|
|
69
|
+
Service: "service",
|
|
70
|
+
Endpoints: "bookkeeping",
|
|
71
|
+
EndpointSlice: "bookkeeping",
|
|
72
|
+
Ingress: "route",
|
|
73
|
+
HTTPRoute: "route",
|
|
74
|
+
HorizontalPodAutoscaler: "policy",
|
|
75
|
+
PodDisruptionBudget: "policy",
|
|
76
|
+
NetworkPolicy: "policy",
|
|
77
|
+
ConfigMap: "config",
|
|
78
|
+
Secret: "config",
|
|
79
|
+
ExternalSecret: "config",
|
|
80
|
+
PersistentVolumeClaim: "storage",
|
|
81
|
+
ServiceAccount: "identity",
|
|
82
|
+
};
|
|
83
|
+
const OUTSIDE_ANNOTATIONS = ["eks.amazonaws.com/role-arn", "iam.gke.io/gcp-service-account", "azure.workload.identity/client-id"];
|
|
84
|
+
const SERVICE_NAME_LABEL = "kubernetes.io/service-name";
|
|
85
|
+
const HELM_RELEASE = "meta.helm.sh/release-name";
|
|
86
|
+
const isRec = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
87
|
+
const rec = (v) => (isRec(v) ? v : {});
|
|
88
|
+
const arr = (v) => (Array.isArray(v) ? v : []);
|
|
89
|
+
const str = (v) => (typeof v === "string" && v.length > 0 ? v : undefined);
|
|
90
|
+
const isMasked = (v) => v === LISTED_MASKED || v === TYPED_MASKED;
|
|
91
|
+
const byString = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
92
|
+
function readObj(n) {
|
|
93
|
+
const type = (n.listedType ?? "").split("/");
|
|
94
|
+
if (type.length < 2)
|
|
95
|
+
return undefined;
|
|
96
|
+
const kind = type[type.length - 1];
|
|
97
|
+
const group = type.length === 3 ? type[0] : "";
|
|
98
|
+
const attrs = rec(n.attrs);
|
|
99
|
+
const meta = rec(attrs.metadata);
|
|
100
|
+
const native = n.nativeId ?? "";
|
|
101
|
+
const name = str(meta.name) ?? native.split("/").pop() ?? "";
|
|
102
|
+
if (!name)
|
|
103
|
+
return undefined;
|
|
104
|
+
const ns = n.location && n.location !== "cluster" ? n.location : "";
|
|
105
|
+
const labels = {};
|
|
106
|
+
for (const [k, v] of Object.entries({ ...rec(meta.labels), ...(n.tags ?? {}) }))
|
|
107
|
+
if (typeof v === "string")
|
|
108
|
+
labels[k] = v;
|
|
109
|
+
const annotations = {};
|
|
110
|
+
for (const [k, v] of Object.entries(rec(meta.annotations)))
|
|
111
|
+
if (typeof v === "string")
|
|
112
|
+
annotations[k] = v;
|
|
113
|
+
const uid = n.facts?.cloudIds?.find((c) => c.kind === "k8s-uid")?.value ?? str(meta.uid);
|
|
114
|
+
return { id: n.id, kind, group, ns, name, attrs, labels, annotations, ...(uid ? { uid } : {}) };
|
|
115
|
+
}
|
|
116
|
+
const isWorkload = (o) => WORKLOAD_KINDS.has(o.kind) && WORKLOAD_GROUPS.has(o.group);
|
|
117
|
+
/** The pod template of a workload (the Pod itself for a Pod): its labels and its pod spec. */
|
|
118
|
+
function podTemplate(o) {
|
|
119
|
+
if (o.kind === "Pod")
|
|
120
|
+
return { labels: o.labels, spec: rec(o.attrs.spec) };
|
|
121
|
+
const spec = rec(o.attrs.spec);
|
|
122
|
+
const template = o.kind === "CronJob" ? rec(rec(rec(spec.jobTemplate).spec).template) : rec(spec.template);
|
|
123
|
+
if (!isRec(spec.template) && !isRec(rec(spec.jobTemplate).spec))
|
|
124
|
+
return undefined;
|
|
125
|
+
const labels = {};
|
|
126
|
+
for (const [k, v] of Object.entries(rec(rec(template.metadata).labels)))
|
|
127
|
+
if (typeof v === "string")
|
|
128
|
+
labels[k] = v;
|
|
129
|
+
return { labels, spec: rec(template.spec) };
|
|
130
|
+
}
|
|
131
|
+
/** A label selector (`matchLabels`, `matchExpressions`) against a label set. `plain` is a Service's map selector. */
|
|
132
|
+
function selects(selector, labels, opts = {}) {
|
|
133
|
+
const sel = rec(selector);
|
|
134
|
+
if (opts.plain) {
|
|
135
|
+
const pairs = Object.entries(sel).filter(([, v]) => typeof v === "string");
|
|
136
|
+
return pairs.length > 0 && pairs.every(([k, v]) => labels[k] === v);
|
|
137
|
+
}
|
|
138
|
+
const matchLabels = Object.entries(rec(sel.matchLabels)).filter(([, v]) => typeof v === "string");
|
|
139
|
+
const expressions = arr(sel.matchExpressions).filter(isRec);
|
|
140
|
+
if (matchLabels.length === 0 && expressions.length === 0)
|
|
141
|
+
return opts.emptyMatchesAll === true;
|
|
142
|
+
if (!matchLabels.every(([k, v]) => labels[k] === v))
|
|
143
|
+
return false;
|
|
144
|
+
return expressions.every((e) => {
|
|
145
|
+
const key = str(e.key);
|
|
146
|
+
if (!key)
|
|
147
|
+
return false;
|
|
148
|
+
const values = arr(e.values).filter((v) => typeof v === "string");
|
|
149
|
+
switch (e.operator) {
|
|
150
|
+
case "In":
|
|
151
|
+
return key in labels && values.includes(labels[key]);
|
|
152
|
+
case "NotIn":
|
|
153
|
+
return !(key in labels) || !values.includes(labels[key]);
|
|
154
|
+
case "Exists":
|
|
155
|
+
return key in labels;
|
|
156
|
+
case "DoesNotExist":
|
|
157
|
+
return !(key in labels);
|
|
158
|
+
default:
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/** The objects a pod spec names, and how many references the read masked. */
|
|
164
|
+
function podRefs(spec, into) {
|
|
165
|
+
const out = into ?? { configMaps: new Set(), secrets: new Set(), claims: new Set(), serviceAccount: "", masked: new Set() };
|
|
166
|
+
const name = (at, v, field = "name") => {
|
|
167
|
+
const n = isMasked(v) ? v : rec(v)[field];
|
|
168
|
+
if (isMasked(n)) {
|
|
169
|
+
out.masked.add(at);
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
return str(n);
|
|
173
|
+
};
|
|
174
|
+
const add = (set, n) => n && set.add(n);
|
|
175
|
+
const sa = str(spec.serviceAccountName) ?? str(spec.serviceAccount);
|
|
176
|
+
if (!out.serviceAccount)
|
|
177
|
+
out.serviceAccount = sa ?? "default";
|
|
178
|
+
for (const v of arr(spec.volumes).filter(isRec)) {
|
|
179
|
+
const at = `volume ${String(v.name)}`;
|
|
180
|
+
if ("configMap" in v)
|
|
181
|
+
add(out.configMaps, name(at, v.configMap));
|
|
182
|
+
if ("secret" in v)
|
|
183
|
+
add(out.secrets, name(at, v.secret, "secretName"));
|
|
184
|
+
if ("persistentVolumeClaim" in v)
|
|
185
|
+
add(out.claims, name(at, v.persistentVolumeClaim, "claimName"));
|
|
186
|
+
arr(rec(v.projected).sources).filter(isRec).forEach((s, i) => {
|
|
187
|
+
if ("configMap" in s)
|
|
188
|
+
add(out.configMaps, name(`${at} ${i}`, s.configMap));
|
|
189
|
+
if ("secret" in s)
|
|
190
|
+
add(out.secrets, name(`${at} ${i}`, s.secret));
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
const ips = spec.imagePullSecrets;
|
|
194
|
+
if (isMasked(ips))
|
|
195
|
+
out.masked.add("imagePullSecrets");
|
|
196
|
+
arr(ips).forEach((p, i) => add(out.secrets, name(`imagePullSecrets ${i}`, p)));
|
|
197
|
+
for (const c of [...arr(spec.containers), ...arr(spec.initContainers)].filter(isRec)) {
|
|
198
|
+
for (const e of arr(c.env).filter(isRec)) {
|
|
199
|
+
const from = rec(e.valueFrom);
|
|
200
|
+
const at = `env ${String(c.name)} ${String(e.name)}`;
|
|
201
|
+
if ("configMapKeyRef" in from)
|
|
202
|
+
add(out.configMaps, name(at, from.configMapKeyRef));
|
|
203
|
+
if ("secretKeyRef" in from)
|
|
204
|
+
add(out.secrets, name(at, from.secretKeyRef));
|
|
205
|
+
}
|
|
206
|
+
arr(c.envFrom).filter(isRec).forEach((e, i) => {
|
|
207
|
+
const at = `envFrom ${String(c.name)} ${i}`;
|
|
208
|
+
if ("configMapRef" in e)
|
|
209
|
+
add(out.configMaps, name(at, e.configMapRef));
|
|
210
|
+
if ("secretRef" in e)
|
|
211
|
+
add(out.secrets, name(at, e.secretRef));
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
return out;
|
|
215
|
+
}
|
|
216
|
+
/** `(name, value)` for each plain env value in a pod spec's containers. */
|
|
217
|
+
function envValues(spec) {
|
|
218
|
+
const out = [];
|
|
219
|
+
for (const c of [...arr(spec.containers), ...arr(spec.initContainers)].filter(isRec)) {
|
|
220
|
+
for (const e of arr(c.env).filter(isRec)) {
|
|
221
|
+
const n = str(e.name);
|
|
222
|
+
const v = e.value;
|
|
223
|
+
if (n && typeof v === "string" && !isMasked(v))
|
|
224
|
+
out.push([n, v]);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return out;
|
|
228
|
+
}
|
|
229
|
+
const DNS_NAME = /(?:^|[^a-z0-9.-])([a-z0-9](?:[-a-z0-9]*[a-z0-9])?)\.([a-z0-9](?:[-a-z0-9]*[a-z0-9])?)\.svc(?:\.cluster\.local)?(?!\.?[a-z0-9-])/g;
|
|
230
|
+
const BARE_NAME = /^(?:[a-z][a-z0-9+.-]*:\/\/)?([a-z0-9](?:[-a-z0-9]*[a-z0-9])?)(?::\d+)?(?:\/\S*)?$/;
|
|
231
|
+
/**
|
|
232
|
+
* The Services a string names: `[namespace, name]` for each cluster DNS name
|
|
233
|
+
* in it, and the bare name in `ns` when the whole string is a name, a
|
|
234
|
+
* `name:port` or a URL whose host is the name. Exported for tests.
|
|
235
|
+
*/
|
|
236
|
+
export function serviceNamesIn(value, ns) {
|
|
237
|
+
const v = value.trim().toLowerCase();
|
|
238
|
+
const out = [];
|
|
239
|
+
for (const m of v.matchAll(DNS_NAME))
|
|
240
|
+
out.push([m[2], m[1]]);
|
|
241
|
+
if (out.length === 0) {
|
|
242
|
+
const bare = BARE_NAME.exec(v);
|
|
243
|
+
if (bare)
|
|
244
|
+
out.push([ns, bare[1]]);
|
|
245
|
+
}
|
|
246
|
+
return out;
|
|
247
|
+
}
|
|
248
|
+
function unitOf(o) {
|
|
249
|
+
const l = o.labels;
|
|
250
|
+
if (l["app.kubernetes.io/part-of"])
|
|
251
|
+
return { by: "part-of", value: l["app.kubernetes.io/part-of"] };
|
|
252
|
+
if (l["argocd.argoproj.io/instance"])
|
|
253
|
+
return { by: "argocd", value: l["argocd.argoproj.io/instance"] };
|
|
254
|
+
if (o.annotations[HELM_RELEASE])
|
|
255
|
+
return { by: "helm", value: o.annotations[HELM_RELEASE] };
|
|
256
|
+
if (l["app.kubernetes.io/instance"])
|
|
257
|
+
return { by: "instance", value: l["app.kubernetes.io/instance"] };
|
|
258
|
+
if (l["app.kubernetes.io/managed-by"] === "chant" && l["app.kubernetes.io/name"])
|
|
259
|
+
return { by: "chant", value: l["app.kubernetes.io/name"] };
|
|
260
|
+
return { by: "workload", value: o.name };
|
|
261
|
+
}
|
|
262
|
+
/** Infer the applications of a live Kubernetes read (an `IndexDocument`'s `graph`). */
|
|
263
|
+
export function inferK8sComponents(graph) {
|
|
264
|
+
const notes = [];
|
|
265
|
+
const objs = graph.nodes.map(readObj).filter((o) => o !== undefined);
|
|
266
|
+
const byId = new Map(objs.map((o) => [o.id, o]));
|
|
267
|
+
const byUid = new Map();
|
|
268
|
+
for (const o of objs)
|
|
269
|
+
if (o.uid)
|
|
270
|
+
byUid.set(o.uid, o);
|
|
271
|
+
const keyOf = (ns, kind, name) => `${ns}\u0000${kind}\u0000${name}`;
|
|
272
|
+
const byKey = new Map();
|
|
273
|
+
for (const o of objs) {
|
|
274
|
+
const k = keyOf(o.ns, o.kind, o.name);
|
|
275
|
+
if (!byKey.has(k) || o.group === "" || WORKLOAD_GROUPS.has(o.group))
|
|
276
|
+
byKey.set(k, o);
|
|
277
|
+
}
|
|
278
|
+
const find = (ns, kind, name) => (name ? byKey.get(keyOf(ns, kind, name)) : undefined);
|
|
279
|
+
// The controlling owner of each object, when the read holds it.
|
|
280
|
+
const ownerOf = (o) => {
|
|
281
|
+
const refs = arr(rec(o.attrs.metadata).ownerReferences).filter(isRec);
|
|
282
|
+
const ref = refs.find((r) => r.controller === true) ?? refs[0];
|
|
283
|
+
if (!ref)
|
|
284
|
+
return undefined;
|
|
285
|
+
const uid = str(ref.uid);
|
|
286
|
+
return (uid ? byUid.get(uid) : undefined) ?? find(o.ns, String(ref.kind ?? ""), str(ref.name));
|
|
287
|
+
};
|
|
288
|
+
// Seeds: workloads no workload controls.
|
|
289
|
+
const seeds = objs.filter((o) => {
|
|
290
|
+
if (!isWorkload(o) || !o.ns)
|
|
291
|
+
return false;
|
|
292
|
+
const owner = ownerOf(o);
|
|
293
|
+
return !owner || !isWorkload(owner);
|
|
294
|
+
});
|
|
295
|
+
// Units, then their names. An Argo CD instance is one unit whatever namespaces it deploys into.
|
|
296
|
+
const units = new Map();
|
|
297
|
+
for (const s of seeds) {
|
|
298
|
+
const boundary = unitOf(s);
|
|
299
|
+
const key = boundary.by === "workload"
|
|
300
|
+
? `${s.ns}\u0000workload\u0000${s.kind}\u0000${s.name}`
|
|
301
|
+
: boundary.by === "argocd"
|
|
302
|
+
? `\u0000argocd\u0000${boundary.value}`
|
|
303
|
+
: `${s.ns}\u0000${boundary.by}\u0000${boundary.value}`;
|
|
304
|
+
const u = units.get(key) ?? { key, ns: s.ns, namespaces: [], boundary, seeds: [], name: "" };
|
|
305
|
+
u.seeds.push(s);
|
|
306
|
+
if (!u.namespaces.includes(s.ns))
|
|
307
|
+
u.namespaces = [...u.namespaces, s.ns].sort(byString);
|
|
308
|
+
u.ns = u.namespaces[0];
|
|
309
|
+
units.set(key, u);
|
|
310
|
+
}
|
|
311
|
+
const ordered = [...units.values()].sort((a, b) => {
|
|
312
|
+
const wa = a.boundary.by === "workload" ? 1 : 0;
|
|
313
|
+
const wb = b.boundary.by === "workload" ? 1 : 0;
|
|
314
|
+
return wa - wb || byString(a.ns, b.ns) || byString(a.key, b.key);
|
|
315
|
+
});
|
|
316
|
+
// Inside one namespace a second unit with a taken name is told apart by its kind or its label.
|
|
317
|
+
const taken = new Set();
|
|
318
|
+
for (const u of ordered) {
|
|
319
|
+
const plain = u.boundary.value;
|
|
320
|
+
const clash = u.namespaces.some((ns) => taken.has(`${ns}\u0000${plain}`));
|
|
321
|
+
u.name = clash ? (u.boundary.by === "workload" ? `${u.seeds[0].kind.toLowerCase()}-${plain}` : `${u.boundary.by}-${plain}`) : plain;
|
|
322
|
+
for (const ns of u.namespaces)
|
|
323
|
+
taken.add(`${ns}\u0000${u.name}`);
|
|
324
|
+
}
|
|
325
|
+
// Across namespaces a name two units give is written <namespace>/<name>; an Argo CD instance keeps its plain name.
|
|
326
|
+
const unitsOfName = new Map();
|
|
327
|
+
for (const u of ordered)
|
|
328
|
+
(unitsOfName.get(u.name) ?? unitsOfName.set(u.name, []).get(u.name)).push(u);
|
|
329
|
+
for (const group of unitsOfName.values()) {
|
|
330
|
+
if (group.length < 2)
|
|
331
|
+
continue;
|
|
332
|
+
for (const u of group)
|
|
333
|
+
if (u.namespaces.length === 1)
|
|
334
|
+
u.name = `${u.ns}/${u.name}`;
|
|
335
|
+
}
|
|
336
|
+
const unitOfSeed = new Map();
|
|
337
|
+
for (const u of ordered)
|
|
338
|
+
for (const s of u.seeds)
|
|
339
|
+
unitOfSeed.set(s.id, u);
|
|
340
|
+
// What each application takes in: object id -> the applications and the role.
|
|
341
|
+
const usedBy = new Map();
|
|
342
|
+
const roleOf = new Map();
|
|
343
|
+
const take = (o, component, role) => {
|
|
344
|
+
if (!o)
|
|
345
|
+
return;
|
|
346
|
+
(usedBy.get(o.id) ?? usedBy.set(o.id, new Set()).get(o.id)).add(component);
|
|
347
|
+
if (!roleOf.has(o.id))
|
|
348
|
+
roleOf.set(o.id, role ?? ROLE_OF_KIND[o.kind] ?? "config");
|
|
349
|
+
};
|
|
350
|
+
const users = (o) => usedBy.get(o.id) ?? new Set();
|
|
351
|
+
for (const s of seeds)
|
|
352
|
+
take(s, unitOfSeed.get(s.id).name, "workload");
|
|
353
|
+
// Runtime children: an owner chain that ends at a seed.
|
|
354
|
+
const seedIds = new Set(seeds.map((s) => s.id));
|
|
355
|
+
const seedOfChain = (o) => {
|
|
356
|
+
const seen = new Set();
|
|
357
|
+
let cur = o;
|
|
358
|
+
while (cur && !seen.has(cur.id)) {
|
|
359
|
+
seen.add(cur.id);
|
|
360
|
+
if (seedIds.has(cur.id))
|
|
361
|
+
return cur;
|
|
362
|
+
cur = ownerOf(cur);
|
|
363
|
+
}
|
|
364
|
+
return undefined;
|
|
365
|
+
};
|
|
366
|
+
const runtimePods = new Map();
|
|
367
|
+
for (const o of objs) {
|
|
368
|
+
if (seedIds.has(o.id))
|
|
369
|
+
continue;
|
|
370
|
+
const seed = seedOfChain(o);
|
|
371
|
+
if (!seed)
|
|
372
|
+
continue;
|
|
373
|
+
take(o, unitOfSeed.get(seed.id).name, "runtime");
|
|
374
|
+
if (o.kind === "Pod")
|
|
375
|
+
(runtimePods.get(seed.id) ?? runtimePods.set(seed.id, []).get(seed.id)).push(o);
|
|
376
|
+
}
|
|
377
|
+
const templates = new Map();
|
|
378
|
+
for (const s of seeds) {
|
|
379
|
+
const t = podTemplate(s);
|
|
380
|
+
if (t)
|
|
381
|
+
templates.set(s.id, t);
|
|
382
|
+
}
|
|
383
|
+
const ofKind = (kind) => objs.filter((o) => o.kind === kind && o.ns);
|
|
384
|
+
// Services that select a seed's pods, and their bookkeeping.
|
|
385
|
+
const services = ofKind("Service");
|
|
386
|
+
for (const svc of services) {
|
|
387
|
+
for (const s of seeds) {
|
|
388
|
+
const t = templates.get(s.id);
|
|
389
|
+
if (s.ns === svc.ns && t && selects(rec(svc.attrs.spec).selector, t.labels, { plain: true }))
|
|
390
|
+
take(svc, unitOfSeed.get(s.id).name);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
for (const svc of services) {
|
|
394
|
+
for (const c of users(svc)) {
|
|
395
|
+
take(find(svc.ns, "Endpoints", svc.name), c);
|
|
396
|
+
for (const es of ofKind("EndpointSlice"))
|
|
397
|
+
if (es.ns === svc.ns && es.labels[SERVICE_NAME_LABEL] === svc.name)
|
|
398
|
+
take(es, c);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
// Routes to those Services.
|
|
402
|
+
for (const ing of ofKind("Ingress")) {
|
|
403
|
+
const spec = rec(ing.attrs.spec);
|
|
404
|
+
const names = new Set();
|
|
405
|
+
const backend = (b) => {
|
|
406
|
+
const n = str(rec(rec(b).service).name) ?? str(rec(b).serviceName);
|
|
407
|
+
if (n)
|
|
408
|
+
names.add(n);
|
|
409
|
+
};
|
|
410
|
+
backend(spec.defaultBackend ?? spec.backend);
|
|
411
|
+
for (const r of arr(spec.rules).filter(isRec))
|
|
412
|
+
for (const p of arr(rec(r.http).paths).filter(isRec))
|
|
413
|
+
backend(p.backend);
|
|
414
|
+
for (const n of names) {
|
|
415
|
+
const svc = find(ing.ns, "Service", n);
|
|
416
|
+
if (svc)
|
|
417
|
+
for (const c of users(svc))
|
|
418
|
+
take(ing, c);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
for (const route of ofKind("HTTPRoute")) {
|
|
422
|
+
for (const r of arr(rec(route.attrs.spec).rules).filter(isRec)) {
|
|
423
|
+
for (const b of arr(r.backendRefs).filter(isRec)) {
|
|
424
|
+
if (b.kind !== undefined && b.kind !== "Service")
|
|
425
|
+
continue;
|
|
426
|
+
const svc = find(str(b.namespace) ?? route.ns, "Service", str(b.name));
|
|
427
|
+
if (svc)
|
|
428
|
+
for (const c of users(svc))
|
|
429
|
+
take(route, c);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
// Policies that target the seeds.
|
|
434
|
+
for (const hpa of ofKind("HorizontalPodAutoscaler")) {
|
|
435
|
+
const ref = rec(rec(hpa.attrs.spec).scaleTargetRef);
|
|
436
|
+
const target = find(hpa.ns, String(ref.kind ?? ""), str(ref.name));
|
|
437
|
+
if (target && unitOfSeed.has(target.id))
|
|
438
|
+
take(hpa, unitOfSeed.get(target.id).name);
|
|
439
|
+
}
|
|
440
|
+
for (const [kind, field, all] of [["PodDisruptionBudget", "selector", false], ["NetworkPolicy", "podSelector", true]]) {
|
|
441
|
+
for (const p of ofKind(kind)) {
|
|
442
|
+
for (const s of seeds) {
|
|
443
|
+
const t = templates.get(s.id);
|
|
444
|
+
if (s.ns === p.ns && t && selects(rec(p.attrs.spec)[field], t.labels, { emptyMatchesAll: all }))
|
|
445
|
+
take(p, unitOfSeed.get(s.id).name);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
// What the pod template and the running Pods name.
|
|
450
|
+
const maskedBy = new Map();
|
|
451
|
+
for (const s of seeds) {
|
|
452
|
+
const c = unitOfSeed.get(s.id).name;
|
|
453
|
+
const t = templates.get(s.id);
|
|
454
|
+
const refs = podRefs(t?.spec ?? {});
|
|
455
|
+
for (const pod of runtimePods.get(s.id) ?? [])
|
|
456
|
+
podRefs(rec(pod.attrs.spec), refs);
|
|
457
|
+
for (const n of refs.configMaps)
|
|
458
|
+
take(find(s.ns, "ConfigMap", n), c);
|
|
459
|
+
for (const n of refs.secrets)
|
|
460
|
+
take(find(s.ns, "Secret", n), c);
|
|
461
|
+
for (const n of refs.claims)
|
|
462
|
+
take(find(s.ns, "PersistentVolumeClaim", n), c);
|
|
463
|
+
take(find(s.ns, "ServiceAccount", refs.serviceAccount), c);
|
|
464
|
+
if (refs.masked.size > 0)
|
|
465
|
+
maskedBy.set(c, (maskedBy.get(c) ?? 0) + refs.masked.size);
|
|
466
|
+
}
|
|
467
|
+
for (const es of objs.filter((o) => o.kind === "ExternalSecret" && o.ns)) {
|
|
468
|
+
const target = find(es.ns, "Secret", str(rec(rec(es.attrs.spec).target).name) ?? es.name);
|
|
469
|
+
if (target)
|
|
470
|
+
for (const c of users(target))
|
|
471
|
+
take(es, c);
|
|
472
|
+
}
|
|
473
|
+
// Bookkeeping roles, and what members name outside the cluster.
|
|
474
|
+
for (const [id] of usedBy) {
|
|
475
|
+
const o = byId.get(id);
|
|
476
|
+
if ((o.kind === "ConfigMap" && o.name === "kube-root-ca.crt") || (o.kind === "ServiceAccount" && o.name === "default"))
|
|
477
|
+
roleOf.set(id, "bookkeeping");
|
|
478
|
+
}
|
|
479
|
+
const outsideOf = (o) => {
|
|
480
|
+
const out = [];
|
|
481
|
+
if (o.kind === "ServiceAccount") {
|
|
482
|
+
for (const key of OUTSIDE_ANNOTATIONS)
|
|
483
|
+
if (o.annotations[key] && !isMasked(o.annotations[key]))
|
|
484
|
+
out.push({ from: o.id, key, value: o.annotations[key] });
|
|
485
|
+
}
|
|
486
|
+
if (o.kind === "ExternalSecret") {
|
|
487
|
+
const spec = rec(o.attrs.spec);
|
|
488
|
+
for (const d of arr(spec.data).filter(isRec)) {
|
|
489
|
+
const k = str(rec(d.remoteRef).key);
|
|
490
|
+
if (k && !isMasked(k))
|
|
491
|
+
out.push({ from: o.id, key: "remoteRef.key", value: k });
|
|
492
|
+
}
|
|
493
|
+
for (const d of arr(spec.dataFrom).filter(isRec)) {
|
|
494
|
+
const k = str(rec(d.extract).key);
|
|
495
|
+
if (k && !isMasked(k))
|
|
496
|
+
out.push({ from: o.id, key: "remoteRef.key", value: k });
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return out;
|
|
500
|
+
};
|
|
501
|
+
// Members and shared objects.
|
|
502
|
+
const members = new Map();
|
|
503
|
+
const shares = new Map();
|
|
504
|
+
const outside = new Map();
|
|
505
|
+
const shared = [];
|
|
506
|
+
for (const [id, set] of [...usedBy.entries()].sort(([a], [b]) => byString(a, b))) {
|
|
507
|
+
const role = roleOf.get(id);
|
|
508
|
+
const o = byId.get(id);
|
|
509
|
+
const names = outsideOf(o);
|
|
510
|
+
if (set.size === 1) {
|
|
511
|
+
const c = [...set][0];
|
|
512
|
+
(members.get(c) ?? members.set(c, []).get(c)).push({ id, role });
|
|
513
|
+
if (names.length)
|
|
514
|
+
(outside.get(c) ?? outside.set(c, []).get(c)).push(...names);
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
const usedByList = [...set].sort(byString);
|
|
518
|
+
shared.push({ id, role, usedBy: usedByList, ...(names.length ? { outside: names } : {}) });
|
|
519
|
+
for (const c of usedByList)
|
|
520
|
+
(shares.get(c) ?? shares.set(c, []).get(c)).push(id);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
// dependsOn from Service names in env values and ConfigMap data.
|
|
524
|
+
const serviceOwner = (ns, name) => {
|
|
525
|
+
const svc = find(ns, "Service", name);
|
|
526
|
+
const set = svc ? users(svc) : undefined;
|
|
527
|
+
return set && set.size === 1 ? [...set][0] : undefined;
|
|
528
|
+
};
|
|
529
|
+
const deps = new Map();
|
|
530
|
+
const depend = (from, ns, value, via) => {
|
|
531
|
+
for (const [tns, tname] of serviceNamesIn(value, ns)) {
|
|
532
|
+
const to = serviceOwner(tns, tname);
|
|
533
|
+
if (!to || to === from)
|
|
534
|
+
continue;
|
|
535
|
+
const m = deps.get(from) ?? deps.set(from, new Map()).get(from);
|
|
536
|
+
const list = m.get(to) ?? m.set(to, []).get(to);
|
|
537
|
+
if (!list.includes(via))
|
|
538
|
+
list.push(via);
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
for (const s of seeds) {
|
|
542
|
+
const c = unitOfSeed.get(s.id).name;
|
|
543
|
+
for (const [n, v] of envValues(templates.get(s.id)?.spec ?? {}))
|
|
544
|
+
depend(c, s.ns, v, `${s.kind} ${s.name} env ${n}`);
|
|
545
|
+
}
|
|
546
|
+
for (const [id, set] of usedBy) {
|
|
547
|
+
const o = byId.get(id);
|
|
548
|
+
if (o.kind !== "ConfigMap")
|
|
549
|
+
continue;
|
|
550
|
+
for (const [k, v] of Object.entries(rec(o.attrs.data))) {
|
|
551
|
+
if (typeof v !== "string" || isMasked(v))
|
|
552
|
+
continue;
|
|
553
|
+
for (const c of set)
|
|
554
|
+
depend(c, o.ns, v, `ConfigMap ${o.name} data.${k}`);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
// Waves: Kahn layers, with any cycle in one last wave.
|
|
558
|
+
const names = ordered.map((u) => u.name);
|
|
559
|
+
const remaining = new Set(names);
|
|
560
|
+
const waves = [];
|
|
561
|
+
while (remaining.size > 0) {
|
|
562
|
+
let wave = [...remaining].filter((n) => [...(deps.get(n)?.keys() ?? [])].every((d) => !remaining.has(d))).sort(byString);
|
|
563
|
+
if (wave.length === 0) {
|
|
564
|
+
wave = [...remaining].sort(byString);
|
|
565
|
+
notes.push(`these applications name each other's Services in a cycle and share the last wave: ${wave.join(", ")}`);
|
|
566
|
+
}
|
|
567
|
+
for (const n of wave)
|
|
568
|
+
remaining.delete(n);
|
|
569
|
+
waves.push(wave);
|
|
570
|
+
}
|
|
571
|
+
const waveOf = new Map();
|
|
572
|
+
waves.forEach((w, i) => w.forEach((n) => waveOf.set(n, i + 1)));
|
|
573
|
+
for (const [c, n] of [...maskedBy.entries()].sort(([a], [b]) => byString(a, b))) {
|
|
574
|
+
notes.push(`${c}: ${n} Secret reference${n === 1 ? " is" : "s are"} masked by the live read, so ${n === 1 ? "that Secret is" : "those Secrets are"} not taken in`);
|
|
575
|
+
}
|
|
576
|
+
// Health: ready over desired for the workloads, and restarts over every Pod they run.
|
|
577
|
+
const statusOf = (u) => {
|
|
578
|
+
let ready = 0;
|
|
579
|
+
let desired = 0;
|
|
580
|
+
let counted = false;
|
|
581
|
+
let restarts = 0;
|
|
582
|
+
let pods = 0;
|
|
583
|
+
for (const seed of u.seeds) {
|
|
584
|
+
const view = rec(seed.attrs.workloadStatus);
|
|
585
|
+
if (typeof view.desiredReplicas === "number") {
|
|
586
|
+
ready += typeof view.readyReplicas === "number" ? view.readyReplicas : 0;
|
|
587
|
+
desired += view.desiredReplicas;
|
|
588
|
+
counted = true;
|
|
589
|
+
}
|
|
590
|
+
else if (seed.kind === "Pod" && typeof view.ready === "boolean") {
|
|
591
|
+
ready += view.ready ? 1 : 0;
|
|
592
|
+
desired += 1;
|
|
593
|
+
counted = true;
|
|
594
|
+
}
|
|
595
|
+
for (const pod of [...(seed.kind === "Pod" ? [seed] : []), ...(runtimePods.get(seed.id) ?? [])]) {
|
|
596
|
+
const pv = rec(pod.attrs.workloadStatus);
|
|
597
|
+
if (typeof pv.restarts === "number") {
|
|
598
|
+
restarts += pv.restarts;
|
|
599
|
+
pods++;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
if (!counted && pods === 0)
|
|
604
|
+
return undefined;
|
|
605
|
+
return { ...(counted ? { readyReplicas: ready, desiredReplicas: desired } : {}), restarts };
|
|
606
|
+
};
|
|
607
|
+
const unitByName = new Map(ordered.map((u) => [u.name, u]));
|
|
608
|
+
const nodes = waves.flat().map((name) => {
|
|
609
|
+
const u = unitByName.get(name);
|
|
610
|
+
const mine = members.get(name) ?? [];
|
|
611
|
+
return {
|
|
612
|
+
id: name,
|
|
613
|
+
kind: "Component",
|
|
614
|
+
lexicon: "chant",
|
|
615
|
+
attrs: {
|
|
616
|
+
wave: waveOf.get(name) ?? null,
|
|
617
|
+
liveNames: mine.map((m) => m.id),
|
|
618
|
+
members: mine,
|
|
619
|
+
...(u.namespaces.length === 1 ? { namespace: u.ns } : { namespaces: u.namespaces }),
|
|
620
|
+
boundary: u.boundary,
|
|
621
|
+
...(statusOf(u) ? { status: statusOf(u) } : {}),
|
|
622
|
+
inferredFrom: "kubernetes",
|
|
623
|
+
...(shares.get(name)?.length ? { shares: shares.get(name) } : {}),
|
|
624
|
+
...(outside.get(name)?.length ? { outside: outside.get(name) } : {}),
|
|
625
|
+
},
|
|
626
|
+
};
|
|
627
|
+
});
|
|
628
|
+
const edges = [];
|
|
629
|
+
for (const from of [...deps.keys()].sort(byString)) {
|
|
630
|
+
for (const [to, via] of [...deps.get(from).entries()].sort(([a], [b]) => byString(a, b))) {
|
|
631
|
+
edges.push({ from, to, kind: "ref", origin: "derived", rule: "k8s:service-dns", viaAttr: via.sort(byString).join("; ") });
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
const ir = {
|
|
635
|
+
version: 1,
|
|
636
|
+
nodes,
|
|
637
|
+
edges,
|
|
638
|
+
groups: { byWave: Object.fromEntries(waves.map((w, i) => [`wave-${i + 1}`, [...w]])) },
|
|
639
|
+
};
|
|
640
|
+
return { ir, shared, notes };
|
|
641
|
+
}
|
|
@@ -48,6 +48,24 @@ export declare function discover(ctx: ListerContext, target: KubernetesTarget, r
|
|
|
48
48
|
/** `labelSelector` for a tag filter, or undefined. Exported for tests. */
|
|
49
49
|
export declare function labelSelector(filter: Readonly<Record<string, string>> | undefined): string | undefined;
|
|
50
50
|
export declare function listKubernetes(ctx: ListerContext, target: KubernetesTarget, retryDelays?: readonly number[]): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* What a workload's or a Pod's `status` says about its health (chant#5252),
|
|
53
|
+
* kept beside the object as `workloadStatus` because typing prunes `status`
|
|
54
|
+
* whole. A Deployment, StatefulSet or ReplicaSet gives ready and desired
|
|
55
|
+
* replicas (desired is `spec.replicas`, 1 when absent); a DaemonSet its ready
|
|
56
|
+
* and desired scheduled pods; a Pod its phase, the restarts summed over its
|
|
57
|
+
* containers, and whether its `Ready` condition is true. Other kinds, and an
|
|
58
|
+
* object with no `status`, get none.
|
|
59
|
+
*/
|
|
60
|
+
export type WorkloadStatus = {
|
|
61
|
+
readyReplicas: number;
|
|
62
|
+
desiredReplicas: number;
|
|
63
|
+
} | {
|
|
64
|
+
phase?: string;
|
|
65
|
+
restarts: number;
|
|
66
|
+
ready: boolean;
|
|
67
|
+
};
|
|
68
|
+
export declare function workloadStatusView(obj: Record<string, unknown>, group: string, kind: string): WorkloadStatus | undefined;
|
|
51
69
|
/**
|
|
52
70
|
* A {@link KubernetesTarget} from a kubeconfig the caller names (its text,
|
|
53
71
|
* and the directory relative file paths resolve against). Static credentials
|