@intentius/chant-lexicon-k8s 0.124.31 → 0.124.33
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/actions/apps.js +18 -0
- package/dist/actions/batch.js +6 -0
- package/dist/actions/core.js +48 -0
- package/dist/actions/index.js +13 -0
- package/dist/actions/networking.js +11 -0
- package/dist/actions/rbac.js +8 -0
- package/dist/api/classify.js +123 -0
- package/dist/api/connect.js +62 -0
- package/dist/api/fake-cluster.js +175 -0
- package/dist/api/operation-surface.d.ts.map +1 -1
- package/dist/api/operation-surface.js +109 -0
- package/dist/api/owner-chain.js +100 -0
- package/dist/api/sweep-types.js +35 -0
- package/dist/behaviour-kinds.js +82 -0
- package/dist/codegen/docs-cli.js +2 -0
- package/dist/codegen/docs.js +146 -0
- package/dist/codegen/generate-cli.js +30 -0
- package/dist/codegen/generate-lexicon.js +74 -0
- package/dist/codegen/generate-list-map-keys.js +88 -0
- package/dist/codegen/generate-operations.js +53 -0
- package/dist/codegen/generate-typescript.js +124 -0
- package/dist/codegen/generate.js +173 -0
- package/dist/codegen/naming.js +174 -0
- package/dist/codegen/package.js +36 -0
- package/dist/codegen/patches.js +88 -0
- package/dist/codegen/typecheck.js +4 -0
- package/dist/codegen/versions.js +41 -0
- package/dist/components/argo-app.js +51 -0
- package/dist/components/builders.js +22 -0
- package/dist/components/capability-plugin.js +31 -0
- package/dist/components/flux-reconcile.js +61 -0
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +18 -0
- package/dist/components/kubectl-apply.d.ts +83 -1
- package/dist/components/kubectl-apply.d.ts.map +1 -1
- package/dist/components/kubectl-apply.js +274 -0
- package/dist/components/kustomize-apply.js +25 -0
- package/dist/composites/adot-collector.js +184 -0
- package/dist/composites/agic-ingress.js +85 -0
- package/dist/composites/aks-external-dns-agent.js +146 -0
- package/dist/composites/alb-ingress.js +86 -0
- package/dist/composites/argo-app.js +199 -0
- package/dist/composites/autoscaled-service.js +174 -0
- package/dist/composites/azure-disk-storage-class.js +47 -0
- package/dist/composites/azure-file-storage-class.js +48 -0
- package/dist/composites/azure-monitor-collector.js +176 -0
- package/dist/composites/batch-job.js +139 -0
- package/dist/composites/catalog.js +4110 -0
- package/dist/composites/cockroachdb-cluster.js +371 -0
- package/dist/composites/cockroachdb-region-stack.js +369 -0
- package/dist/composites/config-connector-context.js +40 -0
- package/dist/composites/configured-app.js +135 -0
- package/dist/composites/cron-schedule.js +38 -0
- package/dist/composites/cron-workload.js +109 -0
- package/dist/composites/ebs-storage-class.js +54 -0
- package/dist/composites/efs-storage-class.js +46 -0
- package/dist/composites/external-dns-agent.js +122 -0
- package/dist/composites/filestore-storage-class.js +49 -0
- package/dist/composites/fluent-bit-agent.js +157 -0
- package/dist/composites/flux-app.js +156 -0
- package/dist/composites/gce-ingress.js +83 -0
- package/dist/composites/gce-pd-storage-class.js +49 -0
- package/dist/composites/gke-external-dns-agent.js +129 -0
- package/dist/composites/gke-fluent-bit-agent.js +165 -0
- package/dist/composites/gke-gateway.js +91 -0
- package/dist/composites/gke-otel-collector.js +94 -0
- package/dist/composites/index.js +51 -0
- package/dist/composites/inference-service.js +76 -0
- package/dist/composites/irsa-service-account.js +77 -0
- package/dist/composites/member-defaults.js +14 -0
- package/dist/composites/metrics-server.js +181 -0
- package/dist/composites/model.js +92 -0
- package/dist/composites/monitored-service.js +152 -0
- package/dist/composites/namespace-env.js +114 -0
- package/dist/composites/network-isolated-app.js +124 -0
- package/dist/composites/node-agent.js +149 -0
- package/dist/composites/operator-stack.js +268 -0
- package/dist/composites/otel-collector-agent.js +142 -0
- package/dist/composites/otel-collector-gateway.js +216 -0
- package/dist/composites/otel-collector-node.js +176 -0
- package/dist/composites/otel-collector-rbac.js +115 -0
- package/dist/composites/otel-collector-shape.js +128 -0
- package/dist/composites/otel-collector.js +115 -0
- package/dist/composites/otel-operator-collector.js +123 -0
- package/dist/composites/ray-cluster.js +378 -0
- package/dist/composites/ray-job.js +136 -0
- package/dist/composites/ray-service.js +178 -0
- package/dist/composites/secure-ingress.js +100 -0
- package/dist/composites/security-context.js +1 -0
- package/dist/composites/sidecar-app.js +105 -0
- package/dist/composites/stateful-app.js +111 -0
- package/dist/composites/vllm-serving-runtime.js +114 -0
- package/dist/composites/web-app.js +157 -0
- package/dist/composites/worker-pool.js +167 -0
- package/dist/composites/workload-identity-sa.js +81 -0
- package/dist/composites/workload-identity-service-account.js +77 -0
- package/dist/config-schema.js +72 -0
- package/dist/config.js +59 -0
- package/dist/coverage.js +27 -0
- package/dist/crd/crd-sources.js +615 -0
- package/dist/crd/loader.js +181 -0
- package/dist/crd/oci-chart.js +144 -0
- package/dist/crd/parser.js +382 -0
- package/dist/crd/project-codegen.js +273 -0
- package/dist/crd/types.js +7 -0
- package/dist/deep-observe-hooks.js +306 -0
- package/dist/deep-observe.js +234 -0
- package/dist/default-labels.js +87 -0
- package/dist/describe-resources.js +699 -0
- package/dist/describe-stack-status.js +99 -0
- package/dist/detect.js +11 -0
- package/dist/effect-receipt-row.js +205 -0
- package/dist/export-resources.js +39 -0
- package/dist/generated/index.js +1092 -0
- package/dist/generated/runtime.js +4 -0
- package/dist/group-namespace.js +96 -0
- package/dist/import/embedded.js +197 -0
- package/dist/import/generator.js +288 -0
- package/dist/import/live-export.js +85 -0
- package/dist/import/parser.js +204 -0
- package/dist/import/testdata/embedded/fixtures.js +60 -0
- package/dist/include/entity.js +78 -0
- package/dist/include/resolve.js +170 -0
- package/dist/index.js +59 -0
- package/dist/integrity.json +3 -3
- package/dist/kube/apply.js +90 -0
- package/dist/kube/connect.js +46 -0
- package/dist/kube/delete.js +138 -0
- package/dist/kube/describe.js +169 -0
- package/dist/kube/events.js +132 -0
- package/dist/kube/flags.js +91 -0
- package/dist/kube/get.js +159 -0
- package/dist/kube/group.js +123 -0
- package/dist/kube/logs.js +82 -0
- package/dist/kube/project.js +94 -0
- package/dist/kube/render.js +227 -0
- package/dist/kube/source.js +122 -0
- package/dist/kube/target.js +63 -0
- package/dist/kube/testing.js +28 -0
- package/dist/kube/top.js +99 -0
- package/dist/kube/verdict.js +72 -0
- package/dist/kube/wait.js +129 -0
- package/dist/kustomize/render.js +73 -0
- package/dist/kustomize/rendered-entity.js +67 -0
- package/dist/kustomize/root.js +68 -0
- package/dist/lint/audit-catalog.js +61 -0
- package/dist/lint/audit-lineage.js +118 -0
- package/dist/lint/post-synth/argo-helpers.js +36 -0
- package/dist/lint/post-synth/argo002.js +31 -0
- package/dist/lint/post-synth/argo003.js +53 -0
- package/dist/lint/post-synth/argo005.js +54 -0
- package/dist/lint/post-synth/crd-schema-helpers.d.ts.map +1 -1
- package/dist/lint/post-synth/crd-schema-helpers.js +214 -0
- package/dist/lint/post-synth/flux002.js +56 -0
- package/dist/lint/post-synth/flux003.js +50 -0
- package/dist/lint/post-synth/index.js +104 -0
- package/dist/lint/post-synth/k8s-helpers.js +186 -0
- package/dist/lint/post-synth/monitoring-selection-helpers.js +163 -0
- package/dist/lint/post-synth/otel-placement-helpers.js +293 -0
- package/dist/lint/post-synth/sops-helpers.js +43 -0
- package/dist/lint/post-synth/wk8005.js +44 -0
- package/dist/lint/post-synth/wk8006.js +56 -0
- package/dist/lint/post-synth/wk8041.js +60 -0
- package/dist/lint/post-synth/wk8042.js +36 -0
- package/dist/lint/post-synth/wk8101.js +52 -0
- package/dist/lint/post-synth/wk8102.js +30 -0
- package/dist/lint/post-synth/wk8103.js +33 -0
- package/dist/lint/post-synth/wk8104.js +58 -0
- package/dist/lint/post-synth/wk8105.js +33 -0
- package/dist/lint/post-synth/wk8201.js +44 -0
- package/dist/lint/post-synth/wk8202.js +34 -0
- package/dist/lint/post-synth/wk8203.js +34 -0
- package/dist/lint/post-synth/wk8204.js +71 -0
- package/dist/lint/post-synth/wk8205.js +38 -0
- package/dist/lint/post-synth/wk8207.js +33 -0
- package/dist/lint/post-synth/wk8208.js +33 -0
- package/dist/lint/post-synth/wk8209.js +33 -0
- package/dist/lint/post-synth/wk8301.js +49 -0
- package/dist/lint/post-synth/wk8302.js +34 -0
- package/dist/lint/post-synth/wk8303.js +68 -0
- package/dist/lint/post-synth/wk8304.js +58 -0
- package/dist/lint/post-synth/wk8305.js +96 -0
- package/dist/lint/post-synth/wk8306.js +38 -0
- package/dist/lint/post-synth/wk8401.js +86 -0
- package/dist/lint/post-synth/wk8402.js +31 -0
- package/dist/lint/post-synth/wk8403.js +49 -0
- package/dist/lint/post-synth/wk8404.js +36 -0
- package/dist/lint/post-synth/wk8405.js +65 -0
- package/dist/lint/post-synth/wk8406.js +50 -0
- package/dist/lint/post-synth/wk8407.js +58 -0
- package/dist/lint/post-synth/wk8501.js +36 -0
- package/dist/lint/post-synth/wk8502.js +35 -0
- package/dist/lint/post-synth/wk8503.js +164 -0
- package/dist/lint/post-synth/wk8504.js +20 -0
- package/dist/lint/post-synth/wk8505.js +31 -0
- package/dist/lint/post-synth/wk8601.js +40 -0
- package/dist/lint/post-synth/wk8602.js +120 -0
- package/dist/lint/post-synth/wk8603.js +63 -0
- package/dist/lint/post-synth/wk8604.js +31 -0
- package/dist/lint/post-synth/wk8605.js +124 -0
- package/dist/lint/post-synth/wk8606.js +22 -0
- package/dist/lint/post-synth/wk8701.js +31 -0
- package/dist/lint/post-synth/wk8702.js +37 -0
- package/dist/lint/post-synth/wk8703.js +31 -0
- package/dist/lint/post-synth/wk8704.js +135 -0
- package/dist/lint/post-synth/wk8705.js +38 -0
- package/dist/lint/rules/argo-appset-single-project.js +56 -0
- package/dist/lint/rules/argo-ast.js +94 -0
- package/dist/lint/rules/argo-automated-prune.js +59 -0
- package/dist/lint/rules/flux-source-ref-pin.js +44 -0
- package/dist/lint/rules/hardcoded-namespace.js +57 -0
- package/dist/lint/rules/latest-image-tag.js +103 -0
- package/dist/lint/rules/missing-resource-limits.js +85 -0
- package/dist/lsp/completions.d.ts.map +1 -1
- package/dist/lsp/completions.js +18 -0
- package/dist/lsp/hover.d.ts.map +1 -1
- package/dist/lsp/hover.js +57 -0
- package/dist/manifest-entity.js +71 -0
- package/dist/manifest.json +1 -1
- package/dist/micro-time.js +49 -0
- package/dist/op/activities/apply-diff.d.ts +31 -0
- package/dist/op/activities/apply-diff.d.ts.map +1 -0
- package/dist/op/activities/apply-diff.js +79 -0
- package/dist/op/activities/argo.js +98 -0
- package/dist/op/activities/ensure-secret.js +38 -0
- package/dist/op/activities/index.js +51 -0
- package/dist/op/activities/kubectl.d.ts +64 -0
- package/dist/op/activities/kubectl.d.ts.map +1 -1
- package/dist/op/activities/kubectl.js +517 -0
- package/dist/op/activities/wait-for-ready.js +229 -0
- package/dist/op/builders.js +68 -0
- package/dist/package-cli.js +21 -0
- package/dist/patch/json-patch.js +187 -0
- package/dist/patch/rendered-patch.js +94 -0
- package/dist/plugin.js +741 -0
- package/dist/project-kinds.js +56 -0
- package/dist/receipt-store.js +216 -0
- package/dist/rules/crd-schema-helpers.ts +2 -1
- package/dist/secret-labels.js +33 -0
- package/dist/secret-store.js +116 -0
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +578 -0
- package/dist/sops/encrypted-secret-file.js +194 -0
- package/dist/sops/entity.js +32 -0
- package/dist/spec/fetch.js +58 -0
- package/dist/spec/parse.js +622 -0
- package/dist/subscribe-changes.js +168 -0
- package/dist/teardown.js +197 -0
- package/dist/telemetry-release.js +86 -0
- package/dist/validate-cli.js +17 -0
- package/dist/validate.js +47 -0
- package/dist/variables.js +34 -0
- package/dist/whoami.js +109 -0
- package/package.json +12 -12
- package/src/api/operation-surface.ts +2 -1
- package/src/codegen/package.ts +2 -2
- package/src/components/index.ts +3 -0
- package/src/components/kubectl-apply-plan.k3d.e2e.test.ts +127 -0
- package/src/components/kubectl-apply.test.ts +262 -0
- package/src/components/kubectl-apply.ts +341 -12
- package/src/deep-observe-hooks.ts +2 -2
- package/src/import/roundtrip-build.test.ts +46 -0
- package/src/lint/post-synth/crd-schema-helpers.ts +2 -1
- package/src/lsp/completions.ts +2 -1
- package/src/lsp/hover.ts +2 -1
- package/src/op/activities/apply-diff.ts +87 -0
- package/src/op/activities/kubectl-plan.test.ts +224 -0
- package/src/op/activities/kubectl.ts +204 -16
- package/src/serializer.ts +2 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BatchJob composite — Job + optional RBAC (ServiceAccount + Role + RoleBinding).
|
|
3
|
+
*
|
|
4
|
+
* A higher-level construct for one-shot batch jobs (data migrations,
|
|
5
|
+
* seed tasks, backups). For scheduled workloads, use CronWorkload instead.
|
|
6
|
+
*/
|
|
7
|
+
import { Composite, mergeDefaults } from "@intentius/chant";
|
|
8
|
+
import { Job, ServiceAccount, Role, RoleBinding } from "../generated/index.js";
|
|
9
|
+
/** Parse a K8s memory string (e.g. "256Mi", "1Gi") to bytes for comparison. */
|
|
10
|
+
function parseMemoryBytes(mem) {
|
|
11
|
+
const match = mem.match(/^(\d+(?:\.\d+)?)\s*(Ki|Mi|Gi|Ti|k|M|G|T|[eE]\d+)?$/);
|
|
12
|
+
if (!match)
|
|
13
|
+
return 0;
|
|
14
|
+
const value = parseFloat(match[1]);
|
|
15
|
+
const unit = match[2] ?? "";
|
|
16
|
+
const multipliers = {
|
|
17
|
+
"": 1, Ki: 1024, Mi: 1024 ** 2, Gi: 1024 ** 3, Ti: 1024 ** 4,
|
|
18
|
+
k: 1e3, M: 1e6, G: 1e9, T: 1e12,
|
|
19
|
+
};
|
|
20
|
+
if (unit.startsWith("e") || unit.startsWith("E"))
|
|
21
|
+
return value * 10 ** parseInt(unit.slice(1));
|
|
22
|
+
return value * (multipliers[unit] ?? 1);
|
|
23
|
+
}
|
|
24
|
+
/** Parse a K8s CPU string (e.g. "500m", "1") to millicores for comparison. */
|
|
25
|
+
function parseCpuMillis(cpu) {
|
|
26
|
+
if (cpu.endsWith("m"))
|
|
27
|
+
return parseFloat(cpu.slice(0, -1));
|
|
28
|
+
return parseFloat(cpu) * 1000;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create a BatchJob composite — returns prop objects for
|
|
32
|
+
* a Job, and optional ServiceAccount, Role, and RoleBinding.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { BatchJob } from "@intentius/chant-lexicon-k8s";
|
|
37
|
+
*
|
|
38
|
+
* const { job, serviceAccount, role, roleBinding } = BatchJob({
|
|
39
|
+
* name: "db-migrate",
|
|
40
|
+
* image: "migrate:1.0",
|
|
41
|
+
* command: ["python", "manage.py", "migrate"],
|
|
42
|
+
* backoffLimit: 3,
|
|
43
|
+
* ttlSecondsAfterFinished: 3600,
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export const BatchJob = Composite((props) => {
|
|
48
|
+
const { name, image, command, args, backoffLimit = 6, ttlSecondsAfterFinished, completions = 1, parallelism = 1, restartPolicy = "OnFailure", rbacRules, labels: extraLabels = {}, namespace, cpuRequest = "100m", memoryRequest: rawMemoryRequest = "128Mi", cpuLimit: rawCpuLimit = "500m", memoryLimit: rawMemoryLimit = "256Mi", env, securityContext, defaults: defs, } = props;
|
|
49
|
+
// Ensure limits >= requests (K8s rejects pods where request > limit).
|
|
50
|
+
const memoryRequest = rawMemoryRequest;
|
|
51
|
+
const memoryLimit = parseMemoryBytes(rawMemoryRequest) > parseMemoryBytes(rawMemoryLimit)
|
|
52
|
+
? rawMemoryRequest : rawMemoryLimit;
|
|
53
|
+
const cpuLimit = parseCpuMillis(cpuRequest) > parseCpuMillis(rawCpuLimit)
|
|
54
|
+
? cpuRequest : rawCpuLimit;
|
|
55
|
+
const saName = `${name}-sa`;
|
|
56
|
+
const roleName = `${name}-role`;
|
|
57
|
+
const bindingName = `${name}-binding`;
|
|
58
|
+
const commonLabels = {
|
|
59
|
+
"app.kubernetes.io/name": name,
|
|
60
|
+
"app.kubernetes.io/managed-by": "chant",
|
|
61
|
+
...extraLabels,
|
|
62
|
+
};
|
|
63
|
+
// undefined → default RBAC rules; explicit [] → no RBAC resources
|
|
64
|
+
const createRbac = rbacRules === undefined || rbacRules.length > 0;
|
|
65
|
+
const effectiveRbacRules = rbacRules === undefined
|
|
66
|
+
? [{ apiGroups: [""], resources: ["pods"], verbs: ["get", "list"] }]
|
|
67
|
+
: rbacRules;
|
|
68
|
+
const container = {
|
|
69
|
+
name,
|
|
70
|
+
image,
|
|
71
|
+
...(command && { command }),
|
|
72
|
+
...(args && { args }),
|
|
73
|
+
resources: {
|
|
74
|
+
limits: { cpu: cpuLimit, memory: memoryLimit },
|
|
75
|
+
requests: { cpu: cpuRequest, memory: memoryRequest },
|
|
76
|
+
},
|
|
77
|
+
...(env && { env }),
|
|
78
|
+
...(securityContext && { securityContext }),
|
|
79
|
+
};
|
|
80
|
+
const job = new Job(mergeDefaults({
|
|
81
|
+
metadata: {
|
|
82
|
+
name,
|
|
83
|
+
...(namespace && { namespace }),
|
|
84
|
+
labels: { ...commonLabels, "app.kubernetes.io/component": "batch" },
|
|
85
|
+
},
|
|
86
|
+
spec: {
|
|
87
|
+
backoffLimit,
|
|
88
|
+
completions,
|
|
89
|
+
parallelism,
|
|
90
|
+
...(ttlSecondsAfterFinished !== undefined && { ttlSecondsAfterFinished }),
|
|
91
|
+
template: {
|
|
92
|
+
metadata: { labels: { "app.kubernetes.io/name": name, ...extraLabels } },
|
|
93
|
+
spec: {
|
|
94
|
+
...(createRbac && { serviceAccountName: saName }),
|
|
95
|
+
restartPolicy,
|
|
96
|
+
containers: [container],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
}, defs?.job));
|
|
101
|
+
const result = { job };
|
|
102
|
+
if (createRbac) {
|
|
103
|
+
result.serviceAccount = new ServiceAccount(mergeDefaults({
|
|
104
|
+
metadata: {
|
|
105
|
+
name: saName,
|
|
106
|
+
...(namespace && { namespace }),
|
|
107
|
+
labels: { ...commonLabels, "app.kubernetes.io/component": "batch" },
|
|
108
|
+
},
|
|
109
|
+
}, defs?.serviceAccount));
|
|
110
|
+
result.role = new Role(mergeDefaults({
|
|
111
|
+
metadata: {
|
|
112
|
+
name: roleName,
|
|
113
|
+
...(namespace && { namespace }),
|
|
114
|
+
labels: { ...commonLabels, "app.kubernetes.io/component": "rbac" },
|
|
115
|
+
},
|
|
116
|
+
rules: effectiveRbacRules,
|
|
117
|
+
}, defs?.role));
|
|
118
|
+
result.roleBinding = new RoleBinding(mergeDefaults({
|
|
119
|
+
metadata: {
|
|
120
|
+
name: bindingName,
|
|
121
|
+
...(namespace && { namespace }),
|
|
122
|
+
labels: { ...commonLabels, "app.kubernetes.io/component": "rbac" },
|
|
123
|
+
},
|
|
124
|
+
roleRef: {
|
|
125
|
+
apiGroup: "rbac.authorization.k8s.io",
|
|
126
|
+
kind: "Role",
|
|
127
|
+
name: roleName,
|
|
128
|
+
},
|
|
129
|
+
subjects: [
|
|
130
|
+
{
|
|
131
|
+
kind: "ServiceAccount",
|
|
132
|
+
name: saName,
|
|
133
|
+
...(namespace && { namespace }),
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
}, defs?.roleBinding));
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
139
|
+
}, "BatchJob");
|