@intentius/chant-lexicon-helm 0.124.31 → 0.124.32
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/archive-render.js +76 -0
- package/dist/codegen/docs-cli.js +3 -0
- package/dist/codegen/docs.js +113 -0
- package/dist/codegen/generate-cli.js +19 -0
- package/dist/codegen/generate.js +210 -0
- package/dist/codegen/naming.js +29 -0
- package/dist/codegen/package.js +44 -0
- package/dist/codegen/values-type.js +87 -0
- package/dist/commands.js +413 -0
- package/dist/components/builders.js +9 -0
- package/dist/components/capability-plugin.js +17 -0
- package/dist/components/helm-upgrade.js +109 -0
- package/dist/components/index.js +11 -0
- package/dist/composites/catalog.js +1119 -0
- package/dist/composites/helm-batch-job.js +148 -0
- package/dist/composites/helm-crd-lifecycle.js +145 -0
- package/dist/composites/helm-cron-job.js +130 -0
- package/dist/composites/helm-daemon-set.js +125 -0
- package/dist/composites/helm-external-secret.js +63 -0
- package/dist/composites/helm-library.js +24 -0
- package/dist/composites/helm-microservice.js +260 -0
- package/dist/composites/helm-monitored-service.js +188 -0
- package/dist/composites/helm-namespace-env.js +116 -0
- package/dist/composites/helm-secure-ingress.js +86 -0
- package/dist/composites/helm-stateful-service.js +160 -0
- package/dist/composites/helm-web-app.js +201 -0
- package/dist/composites/helm-worker.js +164 -0
- package/dist/composites/index.js +13 -0
- package/dist/config.js +161 -0
- package/dist/coverage.js +37 -0
- package/dist/deep-observe-hooks.js +19 -0
- package/dist/deep-observe.js +55 -0
- package/dist/describe-resources.js +119 -0
- package/dist/describe-stack-status.js +66 -0
- package/dist/detect.js +11 -0
- package/dist/generated/index.js +11 -0
- package/dist/helpers.js +84 -0
- package/dist/import/generator.js +292 -0
- package/dist/import/parser.js +141 -0
- package/dist/import/template-stripper.js +86 -0
- package/dist/index.js +55 -0
- package/dist/integrity.json +2 -2
- package/dist/intrinsics.js +482 -0
- package/dist/lint/audit-catalog.js +33 -0
- package/dist/lint/audit-lineage.js +53 -0
- package/dist/lint/post-synth/helm-helpers.js +60 -0
- package/dist/lint/post-synth/index.js +48 -0
- package/dist/lint/post-synth/whm005-no-empty-wrapper.js +47 -0
- package/dist/lint/post-synth/whm101.js +38 -0
- package/dist/lint/post-synth/whm102.js +26 -0
- package/dist/lint/post-synth/whm103.js +51 -0
- package/dist/lint/post-synth/whm104.js +29 -0
- package/dist/lint/post-synth/whm105.js +23 -0
- package/dist/lint/post-synth/whm201.js +29 -0
- package/dist/lint/post-synth/whm202.js +42 -0
- package/dist/lint/post-synth/whm203.js +32 -0
- package/dist/lint/post-synth/whm204.js +51 -0
- package/dist/lint/post-synth/whm301.js +31 -0
- package/dist/lint/post-synth/whm302.js +33 -0
- package/dist/lint/post-synth/whm401.js +52 -0
- package/dist/lint/post-synth/whm402.js +38 -0
- package/dist/lint/post-synth/whm403.js +38 -0
- package/dist/lint/post-synth/whm404.js +30 -0
- package/dist/lint/post-synth/whm405.js +47 -0
- package/dist/lint/post-synth/whm406.js +27 -0
- package/dist/lint/post-synth/whm407.js +72 -0
- package/dist/lint/post-synth/whm501.js +89 -0
- package/dist/lint/post-synth/whm502.js +85 -0
- package/dist/lint/post-synth/whm503.js +82 -0
- package/dist/lint/post-synth/whm504.js +47 -0
- package/dist/lint/rules/chart-metadata.js +53 -0
- package/dist/lint/rules/no-hardcoded-image.js +50 -0
- package/dist/lint/rules/values-no-helm-tpl.js +78 -0
- package/dist/lint/rules/values-no-secrets.js +65 -0
- package/dist/list-artifacts.js +134 -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 +40 -0
- package/dist/manifest.json +1 -1
- package/dist/op/activities/cluster-probe.js +116 -0
- package/dist/op/activities/helm.js +449 -0
- package/dist/op/activities/index.js +10 -0
- package/dist/op/builders.js +45 -0
- package/dist/package-cli.js +21 -0
- package/dist/pinnability/actions.js +207 -0
- package/dist/pinnability/classify.js +416 -0
- package/dist/pinnability/conditions.js +0 -0
- package/dist/pinnability/index.js +16 -0
- package/dist/pinnability/localize.js +518 -0
- package/dist/pinnability/render-stream.js +53 -0
- package/dist/pinnability/values.js +151 -0
- package/dist/plugin.js +458 -0
- package/dist/project-codegen.js +215 -0
- package/dist/release-observe.js +287 -0
- package/dist/render-diff.js +279 -0
- package/dist/render-digest.js +0 -0
- package/dist/render-records.js +29 -0
- package/dist/render-store.js +401 -0
- package/dist/render-wrapper.js +164 -0
- package/dist/render.js +394 -0
- package/dist/resources.js +109 -0
- package/dist/serializer.js +903 -0
- package/dist/validate-cli.js +17 -0
- package/dist/validate.js +30 -0
- package/dist/values-probe.js +504 -0
- package/dist/wrapper-chart.js +95 -0
- package/package.json +11 -11
- package/src/codegen/package.ts +2 -2
- package/src/lsp/completions.ts +2 -1
- package/src/lsp/hover.ts +2 -1
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HelmMicroservice composite — Deployment + Service + Ingress + HPA + PDB + ServiceAccount + ConfigMap.
|
|
3
|
+
*
|
|
4
|
+
* Full microservice pattern with all common production resources.
|
|
5
|
+
*/
|
|
6
|
+
import { Composite, mergeDefaults } from "@intentius/chant";
|
|
7
|
+
import { Chart, Values, Deployment, Service, ServiceAccount, ConfigMap, Ingress, HPA, PDB } from "../resources.js";
|
|
8
|
+
import { values, include, printf, toYaml, With } from "../intrinsics.js";
|
|
9
|
+
export const HelmMicroservice = Composite((props) => {
|
|
10
|
+
const { name, imageRepository = "nginx", imageTag = "", port = 8080, replicas = 2, serviceType = "ClusterIP", ingress = true, autoscaling = true, pdb = true, configMap = true, appVersion = "1.0.0", defaults: defs, } = props;
|
|
11
|
+
const chart = new Chart(mergeDefaults({
|
|
12
|
+
apiVersion: "v2",
|
|
13
|
+
name,
|
|
14
|
+
version: "0.1.0",
|
|
15
|
+
appVersion,
|
|
16
|
+
type: "application",
|
|
17
|
+
description: `A Helm chart for ${name} microservice`,
|
|
18
|
+
}, defs?.chart));
|
|
19
|
+
const valuesObj = {
|
|
20
|
+
replicaCount: replicas,
|
|
21
|
+
image: {
|
|
22
|
+
repository: imageRepository,
|
|
23
|
+
tag: imageTag,
|
|
24
|
+
pullPolicy: "IfNotPresent",
|
|
25
|
+
},
|
|
26
|
+
service: {
|
|
27
|
+
type: serviceType,
|
|
28
|
+
port,
|
|
29
|
+
},
|
|
30
|
+
serviceAccount: {
|
|
31
|
+
create: true,
|
|
32
|
+
name: "",
|
|
33
|
+
annotations: {},
|
|
34
|
+
},
|
|
35
|
+
resources: {
|
|
36
|
+
limits: { cpu: "500m", memory: "256Mi" },
|
|
37
|
+
requests: { cpu: "100m", memory: "128Mi" },
|
|
38
|
+
},
|
|
39
|
+
livenessProbe: {
|
|
40
|
+
httpGet: { path: "/healthz", port: "http" },
|
|
41
|
+
initialDelaySeconds: 15,
|
|
42
|
+
periodSeconds: 20,
|
|
43
|
+
},
|
|
44
|
+
readinessProbe: {
|
|
45
|
+
httpGet: { path: "/readyz", port: "http" },
|
|
46
|
+
initialDelaySeconds: 5,
|
|
47
|
+
periodSeconds: 10,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
if (props.podSecurityContext)
|
|
51
|
+
valuesObj.podSecurityContext = props.podSecurityContext;
|
|
52
|
+
if (props.securityContext)
|
|
53
|
+
valuesObj.securityContext = props.securityContext;
|
|
54
|
+
if (props.nodeSelector)
|
|
55
|
+
valuesObj.nodeSelector = props.nodeSelector;
|
|
56
|
+
if (props.tolerations)
|
|
57
|
+
valuesObj.tolerations = props.tolerations;
|
|
58
|
+
if (props.affinity)
|
|
59
|
+
valuesObj.affinity = props.affinity;
|
|
60
|
+
if (props.podAnnotations)
|
|
61
|
+
valuesObj.podAnnotations = props.podAnnotations;
|
|
62
|
+
if (props.strategy)
|
|
63
|
+
valuesObj.strategy = props.strategy;
|
|
64
|
+
if (configMap) {
|
|
65
|
+
valuesObj.config = {};
|
|
66
|
+
}
|
|
67
|
+
if (ingress) {
|
|
68
|
+
valuesObj.ingress = {
|
|
69
|
+
enabled: false,
|
|
70
|
+
className: "",
|
|
71
|
+
annotations: {},
|
|
72
|
+
hosts: [{ host: `${name}.local`, paths: [{ path: "/", pathType: "Prefix" }] }],
|
|
73
|
+
tls: [],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (autoscaling) {
|
|
77
|
+
valuesObj.autoscaling = {
|
|
78
|
+
enabled: false,
|
|
79
|
+
minReplicas: replicas,
|
|
80
|
+
maxReplicas: 10,
|
|
81
|
+
targetCPUUtilizationPercentage: 80,
|
|
82
|
+
targetMemoryUtilizationPercentage: 80,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
if (pdb) {
|
|
86
|
+
valuesObj.podDisruptionBudget = {
|
|
87
|
+
enabled: true,
|
|
88
|
+
minAvailable: 1,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const valuesRes = new Values(mergeDefaults(valuesObj, defs?.values));
|
|
92
|
+
const containerSpec = {
|
|
93
|
+
name,
|
|
94
|
+
image: printf("%s:%s", values.image.repository, values.image.tag),
|
|
95
|
+
imagePullPolicy: values.image.pullPolicy,
|
|
96
|
+
ports: [{ containerPort: values.service.port, name: "http" }],
|
|
97
|
+
resources: toYaml(values.resources),
|
|
98
|
+
livenessProbe: toYaml(values.livenessProbe),
|
|
99
|
+
readinessProbe: toYaml(values.readinessProbe),
|
|
100
|
+
};
|
|
101
|
+
if (props.securityContext)
|
|
102
|
+
containerSpec.securityContext = toYaml(values.securityContext);
|
|
103
|
+
const podSpec = {
|
|
104
|
+
serviceAccountName: include(`${name}.serviceAccountName`),
|
|
105
|
+
containers: [containerSpec],
|
|
106
|
+
};
|
|
107
|
+
if (props.podSecurityContext)
|
|
108
|
+
podSpec.securityContext = toYaml(values.podSecurityContext);
|
|
109
|
+
if (props.nodeSelector)
|
|
110
|
+
podSpec.nodeSelector = With(values.nodeSelector, toYaml(values.nodeSelector));
|
|
111
|
+
if (props.tolerations)
|
|
112
|
+
podSpec.tolerations = With(values.tolerations, toYaml(values.tolerations));
|
|
113
|
+
if (props.affinity)
|
|
114
|
+
podSpec.affinity = With(values.affinity, toYaml(values.affinity));
|
|
115
|
+
const templateMetadata = {
|
|
116
|
+
labels: include(`${name}.selectorLabels`),
|
|
117
|
+
};
|
|
118
|
+
if (props.podAnnotations)
|
|
119
|
+
templateMetadata.annotations = toYaml(values.podAnnotations);
|
|
120
|
+
const deploymentSpec = {
|
|
121
|
+
replicas: values.replicaCount,
|
|
122
|
+
selector: {
|
|
123
|
+
matchLabels: include(`${name}.selectorLabels`),
|
|
124
|
+
},
|
|
125
|
+
template: {
|
|
126
|
+
metadata: templateMetadata,
|
|
127
|
+
spec: podSpec,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
if (props.strategy)
|
|
131
|
+
deploymentSpec.strategy = toYaml(values.strategy);
|
|
132
|
+
const deployment = new Deployment(mergeDefaults({
|
|
133
|
+
apiVersion: "apps/v1",
|
|
134
|
+
kind: "Deployment",
|
|
135
|
+
metadata: {
|
|
136
|
+
name: include(`${name}.fullname`),
|
|
137
|
+
labels: include(`${name}.labels`),
|
|
138
|
+
},
|
|
139
|
+
spec: deploymentSpec,
|
|
140
|
+
}, defs?.deployment));
|
|
141
|
+
const service = new Service(mergeDefaults({
|
|
142
|
+
apiVersion: "v1",
|
|
143
|
+
kind: "Service",
|
|
144
|
+
metadata: {
|
|
145
|
+
name: include(`${name}.fullname`),
|
|
146
|
+
labels: include(`${name}.labels`),
|
|
147
|
+
},
|
|
148
|
+
spec: {
|
|
149
|
+
type: values.service.type,
|
|
150
|
+
ports: [{
|
|
151
|
+
port: values.service.port,
|
|
152
|
+
targetPort: "http",
|
|
153
|
+
protocol: "TCP",
|
|
154
|
+
name: "http",
|
|
155
|
+
}],
|
|
156
|
+
selector: include(`${name}.selectorLabels`),
|
|
157
|
+
},
|
|
158
|
+
}, defs?.service));
|
|
159
|
+
const serviceAccount = new ServiceAccount(mergeDefaults({
|
|
160
|
+
apiVersion: "v1",
|
|
161
|
+
kind: "ServiceAccount",
|
|
162
|
+
metadata: {
|
|
163
|
+
name: include(`${name}.serviceAccountName`),
|
|
164
|
+
labels: include(`${name}.labels`),
|
|
165
|
+
annotations: toYaml(values.serviceAccount.annotations),
|
|
166
|
+
},
|
|
167
|
+
}, defs?.serviceAccount));
|
|
168
|
+
const result = {
|
|
169
|
+
chart,
|
|
170
|
+
values: valuesRes,
|
|
171
|
+
deployment,
|
|
172
|
+
service,
|
|
173
|
+
serviceAccount,
|
|
174
|
+
};
|
|
175
|
+
if (configMap) {
|
|
176
|
+
result.configMap = new ConfigMap(mergeDefaults({
|
|
177
|
+
apiVersion: "v1",
|
|
178
|
+
kind: "ConfigMap",
|
|
179
|
+
metadata: {
|
|
180
|
+
name: include(`${name}.fullname`),
|
|
181
|
+
labels: include(`${name}.labels`),
|
|
182
|
+
},
|
|
183
|
+
data: values.config,
|
|
184
|
+
}, defs?.configMap));
|
|
185
|
+
}
|
|
186
|
+
if (ingress) {
|
|
187
|
+
result.ingress = new Ingress(mergeDefaults({
|
|
188
|
+
apiVersion: "networking.k8s.io/v1",
|
|
189
|
+
kind: "Ingress",
|
|
190
|
+
metadata: {
|
|
191
|
+
name: include(`${name}.fullname`),
|
|
192
|
+
labels: include(`${name}.labels`),
|
|
193
|
+
annotations: toYaml(values.ingress.annotations),
|
|
194
|
+
},
|
|
195
|
+
spec: {
|
|
196
|
+
ingressClassName: values.ingress.className,
|
|
197
|
+
rules: values.ingress.hosts,
|
|
198
|
+
tls: values.ingress.tls,
|
|
199
|
+
},
|
|
200
|
+
}, defs?.ingress));
|
|
201
|
+
}
|
|
202
|
+
if (autoscaling) {
|
|
203
|
+
result.hpa = new HPA(mergeDefaults({
|
|
204
|
+
apiVersion: "autoscaling/v2",
|
|
205
|
+
kind: "HorizontalPodAutoscaler",
|
|
206
|
+
metadata: {
|
|
207
|
+
name: include(`${name}.fullname`),
|
|
208
|
+
labels: include(`${name}.labels`),
|
|
209
|
+
},
|
|
210
|
+
spec: {
|
|
211
|
+
scaleTargetRef: {
|
|
212
|
+
apiVersion: "apps/v1",
|
|
213
|
+
kind: "Deployment",
|
|
214
|
+
name: include(`${name}.fullname`),
|
|
215
|
+
},
|
|
216
|
+
minReplicas: values.autoscaling.minReplicas,
|
|
217
|
+
maxReplicas: values.autoscaling.maxReplicas,
|
|
218
|
+
metrics: [
|
|
219
|
+
{
|
|
220
|
+
type: "Resource",
|
|
221
|
+
resource: {
|
|
222
|
+
name: "cpu",
|
|
223
|
+
target: {
|
|
224
|
+
type: "Utilization",
|
|
225
|
+
averageUtilization: values.autoscaling.targetCPUUtilizationPercentage,
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
type: "Resource",
|
|
231
|
+
resource: {
|
|
232
|
+
name: "memory",
|
|
233
|
+
target: {
|
|
234
|
+
type: "Utilization",
|
|
235
|
+
averageUtilization: values.autoscaling.targetMemoryUtilizationPercentage,
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
},
|
|
241
|
+
}, defs?.hpa));
|
|
242
|
+
}
|
|
243
|
+
if (pdb) {
|
|
244
|
+
result.pdb = new PDB(mergeDefaults({
|
|
245
|
+
apiVersion: "policy/v1",
|
|
246
|
+
kind: "PodDisruptionBudget",
|
|
247
|
+
metadata: {
|
|
248
|
+
name: include(`${name}.fullname`),
|
|
249
|
+
labels: include(`${name}.labels`),
|
|
250
|
+
},
|
|
251
|
+
spec: {
|
|
252
|
+
minAvailable: values.podDisruptionBudget.minAvailable,
|
|
253
|
+
selector: {
|
|
254
|
+
matchLabels: include(`${name}.selectorLabels`),
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
}, defs?.pdb));
|
|
258
|
+
}
|
|
259
|
+
return result;
|
|
260
|
+
}, "HelmMicroservice");
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HelmMonitoredService composite — Deployment + Service + ServiceMonitor + optional PrometheusRule.
|
|
3
|
+
*
|
|
4
|
+
* Full observability pattern for services monitored by Prometheus Operator.
|
|
5
|
+
* Uses fallback GVK for CRD resources (ServiceMonitor, PrometheusRule).
|
|
6
|
+
*/
|
|
7
|
+
import { Composite, mergeDefaults } from "@intentius/chant";
|
|
8
|
+
import { Chart, Values, Deployment, Service, ServiceAccount, ServiceMonitor as ServiceMonitorRes, PrometheusRule as PrometheusRuleRes, } from "../resources.js";
|
|
9
|
+
import { values, include, printf, toYaml, If, With } from "../intrinsics.js";
|
|
10
|
+
export const HelmMonitoredService = Composite((props) => {
|
|
11
|
+
const { name, imageRepository = "nginx", imageTag = "", port = 8080, metricsPort = 9090, metricsPath = "/metrics", scrapeInterval = "30s", replicas = 2, serviceType = "ClusterIP", serviceAccount = true, alertRules = false, appVersion = "1.0.0", defaults: defs, } = props;
|
|
12
|
+
const chart = new Chart(mergeDefaults({
|
|
13
|
+
apiVersion: "v2",
|
|
14
|
+
name,
|
|
15
|
+
version: "0.1.0",
|
|
16
|
+
appVersion,
|
|
17
|
+
type: "application",
|
|
18
|
+
description: `A Helm chart for ${name} with monitoring`,
|
|
19
|
+
}, defs?.chart));
|
|
20
|
+
const valuesObj = {
|
|
21
|
+
replicaCount: replicas,
|
|
22
|
+
image: {
|
|
23
|
+
repository: imageRepository,
|
|
24
|
+
tag: imageTag,
|
|
25
|
+
pullPolicy: "IfNotPresent",
|
|
26
|
+
},
|
|
27
|
+
service: {
|
|
28
|
+
type: serviceType,
|
|
29
|
+
port,
|
|
30
|
+
},
|
|
31
|
+
resources: {},
|
|
32
|
+
monitoring: {
|
|
33
|
+
enabled: true,
|
|
34
|
+
metricsPort,
|
|
35
|
+
metricsPath,
|
|
36
|
+
scrapeInterval,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
if (alertRules) {
|
|
40
|
+
valuesObj.alerting = {
|
|
41
|
+
enabled: false,
|
|
42
|
+
rules: [],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (props.podSecurityContext)
|
|
46
|
+
valuesObj.podSecurityContext = props.podSecurityContext;
|
|
47
|
+
if (props.securityContext)
|
|
48
|
+
valuesObj.securityContext = props.securityContext;
|
|
49
|
+
if (props.nodeSelector)
|
|
50
|
+
valuesObj.nodeSelector = props.nodeSelector;
|
|
51
|
+
if (props.tolerations)
|
|
52
|
+
valuesObj.tolerations = props.tolerations;
|
|
53
|
+
if (props.affinity)
|
|
54
|
+
valuesObj.affinity = props.affinity;
|
|
55
|
+
if (serviceAccount) {
|
|
56
|
+
valuesObj.serviceAccount = {
|
|
57
|
+
create: true,
|
|
58
|
+
name: "",
|
|
59
|
+
annotations: {},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const valuesRes = new Values(mergeDefaults(valuesObj, defs?.values));
|
|
63
|
+
const containerSpec = {
|
|
64
|
+
name,
|
|
65
|
+
image: printf("%s:%s", values.image.repository, values.image.tag),
|
|
66
|
+
imagePullPolicy: values.image.pullPolicy,
|
|
67
|
+
ports: [
|
|
68
|
+
{ containerPort: values.service.port, name: "http" },
|
|
69
|
+
{ containerPort: values.monitoring.metricsPort, name: "metrics" },
|
|
70
|
+
],
|
|
71
|
+
resources: toYaml(values.resources),
|
|
72
|
+
};
|
|
73
|
+
if (props.securityContext)
|
|
74
|
+
containerSpec.securityContext = toYaml(values.securityContext);
|
|
75
|
+
const podSpec = {
|
|
76
|
+
containers: [containerSpec],
|
|
77
|
+
};
|
|
78
|
+
if (props.podSecurityContext)
|
|
79
|
+
podSpec.securityContext = toYaml(values.podSecurityContext);
|
|
80
|
+
if (props.nodeSelector)
|
|
81
|
+
podSpec.nodeSelector = With(values.nodeSelector, toYaml(values.nodeSelector));
|
|
82
|
+
if (props.tolerations)
|
|
83
|
+
podSpec.tolerations = With(values.tolerations, toYaml(values.tolerations));
|
|
84
|
+
if (props.affinity)
|
|
85
|
+
podSpec.affinity = With(values.affinity, toYaml(values.affinity));
|
|
86
|
+
if (serviceAccount)
|
|
87
|
+
podSpec.serviceAccountName = include(`${name}.serviceAccountName`);
|
|
88
|
+
const deployment = new Deployment(mergeDefaults({
|
|
89
|
+
apiVersion: "apps/v1",
|
|
90
|
+
kind: "Deployment",
|
|
91
|
+
metadata: {
|
|
92
|
+
name: include(`${name}.fullname`),
|
|
93
|
+
labels: include(`${name}.labels`),
|
|
94
|
+
},
|
|
95
|
+
spec: {
|
|
96
|
+
replicas: values.replicaCount,
|
|
97
|
+
selector: {
|
|
98
|
+
matchLabels: include(`${name}.selectorLabels`),
|
|
99
|
+
},
|
|
100
|
+
template: {
|
|
101
|
+
metadata: {
|
|
102
|
+
labels: include(`${name}.selectorLabels`),
|
|
103
|
+
},
|
|
104
|
+
spec: podSpec,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
}, defs?.deployment));
|
|
108
|
+
const service = new Service(mergeDefaults({
|
|
109
|
+
apiVersion: "v1",
|
|
110
|
+
kind: "Service",
|
|
111
|
+
metadata: {
|
|
112
|
+
name: include(`${name}.fullname`),
|
|
113
|
+
labels: include(`${name}.labels`),
|
|
114
|
+
},
|
|
115
|
+
spec: {
|
|
116
|
+
type: values.service.type,
|
|
117
|
+
ports: [
|
|
118
|
+
{
|
|
119
|
+
port: values.service.port,
|
|
120
|
+
targetPort: "http",
|
|
121
|
+
protocol: "TCP",
|
|
122
|
+
name: "http",
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
port: values.monitoring.metricsPort,
|
|
126
|
+
targetPort: "metrics",
|
|
127
|
+
protocol: "TCP",
|
|
128
|
+
name: "metrics",
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
selector: include(`${name}.selectorLabels`),
|
|
132
|
+
},
|
|
133
|
+
}, defs?.service));
|
|
134
|
+
// ServiceMonitor CRD (monitoring.coreos.com/v1) — gated on Capabilities check
|
|
135
|
+
const serviceMonitor = new ServiceMonitorRes(mergeDefaults(If(`and .Values.monitoring.enabled (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1")`, {
|
|
136
|
+
apiVersion: "monitoring.coreos.com/v1",
|
|
137
|
+
kind: "ServiceMonitor",
|
|
138
|
+
metadata: {
|
|
139
|
+
name: include(`${name}.fullname`),
|
|
140
|
+
labels: include(`${name}.labels`),
|
|
141
|
+
},
|
|
142
|
+
spec: {
|
|
143
|
+
selector: {
|
|
144
|
+
matchLabels: include(`${name}.selectorLabels`),
|
|
145
|
+
},
|
|
146
|
+
endpoints: [{
|
|
147
|
+
port: "metrics",
|
|
148
|
+
path: values.monitoring.metricsPath,
|
|
149
|
+
interval: values.monitoring.scrapeInterval,
|
|
150
|
+
}],
|
|
151
|
+
},
|
|
152
|
+
}), defs?.serviceMonitor));
|
|
153
|
+
const result = {
|
|
154
|
+
chart,
|
|
155
|
+
values: valuesRes,
|
|
156
|
+
deployment,
|
|
157
|
+
service,
|
|
158
|
+
serviceMonitor,
|
|
159
|
+
};
|
|
160
|
+
if (serviceAccount) {
|
|
161
|
+
result.serviceAccount = new ServiceAccount(mergeDefaults({
|
|
162
|
+
apiVersion: "v1",
|
|
163
|
+
kind: "ServiceAccount",
|
|
164
|
+
metadata: {
|
|
165
|
+
name: include(`${name}.serviceAccountName`),
|
|
166
|
+
labels: include(`${name}.labels`),
|
|
167
|
+
annotations: toYaml(values.serviceAccount.annotations),
|
|
168
|
+
},
|
|
169
|
+
}, defs?.serviceAccount));
|
|
170
|
+
}
|
|
171
|
+
if (alertRules) {
|
|
172
|
+
result.prometheusRule = new PrometheusRuleRes(mergeDefaults(If(`and .Values.alerting.enabled (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1")`, {
|
|
173
|
+
apiVersion: "monitoring.coreos.com/v1",
|
|
174
|
+
kind: "PrometheusRule",
|
|
175
|
+
metadata: {
|
|
176
|
+
name: include(`${name}.fullname`),
|
|
177
|
+
labels: include(`${name}.labels`),
|
|
178
|
+
},
|
|
179
|
+
spec: {
|
|
180
|
+
groups: [{
|
|
181
|
+
name: printf("%s.rules", name),
|
|
182
|
+
rules: toYaml(values.alerting.rules),
|
|
183
|
+
}],
|
|
184
|
+
},
|
|
185
|
+
}), defs?.prometheusRule));
|
|
186
|
+
}
|
|
187
|
+
return result;
|
|
188
|
+
}, "HelmMonitoredService");
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HelmNamespaceEnv composite — Namespace + ResourceQuota + LimitRange + NetworkPolicy.
|
|
3
|
+
*
|
|
4
|
+
* Environment namespace pattern with optional resource governance and
|
|
5
|
+
* network isolation.
|
|
6
|
+
*/
|
|
7
|
+
import { Composite, mergeDefaults } from "@intentius/chant";
|
|
8
|
+
import { Chart, Values, Namespace, ResourceQuota as ResourceQuotaRes, LimitRange as LimitRangeRes, NetworkPolicy as NetworkPolicyRes, } from "../resources.js";
|
|
9
|
+
import { values, include, toYaml, If } from "../intrinsics.js";
|
|
10
|
+
export const HelmNamespaceEnv = Composite((props) => {
|
|
11
|
+
const { name, resourceQuota = true, limitRange = true, networkPolicy = true, appVersion = "1.0.0", defaults: defs, } = props;
|
|
12
|
+
const chart = new Chart(mergeDefaults({
|
|
13
|
+
apiVersion: "v2",
|
|
14
|
+
name,
|
|
15
|
+
version: "0.1.0",
|
|
16
|
+
appVersion,
|
|
17
|
+
type: "application",
|
|
18
|
+
description: `A Helm chart for ${name} namespace environment`,
|
|
19
|
+
}, defs?.chart));
|
|
20
|
+
const valuesObj = {
|
|
21
|
+
namespace: {
|
|
22
|
+
labels: {},
|
|
23
|
+
annotations: {},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
if (resourceQuota) {
|
|
27
|
+
valuesObj.resourceQuota = {
|
|
28
|
+
enabled: true,
|
|
29
|
+
hard: {
|
|
30
|
+
cpu: "10",
|
|
31
|
+
memory: "20Gi",
|
|
32
|
+
pods: "50",
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (limitRange) {
|
|
37
|
+
valuesObj.limitRange = {
|
|
38
|
+
enabled: true,
|
|
39
|
+
default: {
|
|
40
|
+
cpu: "500m",
|
|
41
|
+
memory: "256Mi",
|
|
42
|
+
},
|
|
43
|
+
defaultRequest: {
|
|
44
|
+
cpu: "100m",
|
|
45
|
+
memory: "128Mi",
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (networkPolicy) {
|
|
50
|
+
valuesObj.networkPolicy = {
|
|
51
|
+
enabled: true,
|
|
52
|
+
denyIngress: true,
|
|
53
|
+
denyEgress: false,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const valuesRes = new Values(mergeDefaults(valuesObj, defs?.values));
|
|
57
|
+
const ns = new Namespace(mergeDefaults({
|
|
58
|
+
apiVersion: "v1",
|
|
59
|
+
kind: "Namespace",
|
|
60
|
+
metadata: {
|
|
61
|
+
name: include(`${name}.fullname`),
|
|
62
|
+
labels: toYaml(values.namespace.labels),
|
|
63
|
+
annotations: toYaml(values.namespace.annotations),
|
|
64
|
+
},
|
|
65
|
+
}, defs?.namespace));
|
|
66
|
+
const result = {
|
|
67
|
+
chart,
|
|
68
|
+
values: valuesRes,
|
|
69
|
+
namespace: ns,
|
|
70
|
+
};
|
|
71
|
+
if (resourceQuota) {
|
|
72
|
+
result.resourceQuota = new ResourceQuotaRes(mergeDefaults(If(values.resourceQuota.enabled, {
|
|
73
|
+
apiVersion: "v1",
|
|
74
|
+
kind: "ResourceQuota",
|
|
75
|
+
metadata: {
|
|
76
|
+
name: include(`${name}.fullname`),
|
|
77
|
+
labels: include(`${name}.labels`),
|
|
78
|
+
},
|
|
79
|
+
spec: {
|
|
80
|
+
hard: toYaml(values.resourceQuota.hard),
|
|
81
|
+
},
|
|
82
|
+
}), defs?.resourceQuota));
|
|
83
|
+
}
|
|
84
|
+
if (limitRange) {
|
|
85
|
+
result.limitRange = new LimitRangeRes(mergeDefaults(If(values.limitRange.enabled, {
|
|
86
|
+
apiVersion: "v1",
|
|
87
|
+
kind: "LimitRange",
|
|
88
|
+
metadata: {
|
|
89
|
+
name: include(`${name}.fullname`),
|
|
90
|
+
labels: include(`${name}.labels`),
|
|
91
|
+
},
|
|
92
|
+
spec: {
|
|
93
|
+
limits: [{
|
|
94
|
+
type: "Container",
|
|
95
|
+
default: toYaml(values.limitRange.default),
|
|
96
|
+
defaultRequest: toYaml(values.limitRange.defaultRequest),
|
|
97
|
+
}],
|
|
98
|
+
},
|
|
99
|
+
}), defs?.limitRange));
|
|
100
|
+
}
|
|
101
|
+
if (networkPolicy) {
|
|
102
|
+
result.networkPolicy = new NetworkPolicyRes(mergeDefaults(If(values.networkPolicy.enabled, {
|
|
103
|
+
apiVersion: "networking.k8s.io/v1",
|
|
104
|
+
kind: "NetworkPolicy",
|
|
105
|
+
metadata: {
|
|
106
|
+
name: include(`${name}.fullname`),
|
|
107
|
+
labels: include(`${name}.labels`),
|
|
108
|
+
},
|
|
109
|
+
spec: {
|
|
110
|
+
podSelector: {},
|
|
111
|
+
policyTypes: ["Ingress", "Egress"],
|
|
112
|
+
},
|
|
113
|
+
}), defs?.networkPolicy));
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
}, "HelmNamespaceEnv");
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HelmSecureIngress composite — Ingress + optional cert-manager Certificate.
|
|
3
|
+
*
|
|
4
|
+
* TLS-enabled ingress pattern with optional cert-manager integration
|
|
5
|
+
* for automatic certificate provisioning.
|
|
6
|
+
*/
|
|
7
|
+
import { Composite, mergeDefaults } from "@intentius/chant";
|
|
8
|
+
import { Chart, Values, Ingress, Certificate } from "../resources.js";
|
|
9
|
+
import { values, include, toYaml, If, Range } from "../intrinsics.js";
|
|
10
|
+
export const HelmSecureIngress = Composite((props) => {
|
|
11
|
+
const { name, ingressClassName = "", clusterIssuer = "letsencrypt-prod", appVersion = "1.0.0", defaults: defs, } = props;
|
|
12
|
+
const chart = new Chart(mergeDefaults({
|
|
13
|
+
apiVersion: "v2",
|
|
14
|
+
name,
|
|
15
|
+
version: "0.1.0",
|
|
16
|
+
appVersion,
|
|
17
|
+
type: "application",
|
|
18
|
+
description: `A Helm chart for ${name} secure ingress`,
|
|
19
|
+
}, defs?.chart));
|
|
20
|
+
const valuesRes = new Values(mergeDefaults({
|
|
21
|
+
ingress: {
|
|
22
|
+
enabled: true,
|
|
23
|
+
className: ingressClassName,
|
|
24
|
+
annotations: {},
|
|
25
|
+
hosts: [
|
|
26
|
+
{
|
|
27
|
+
host: `${name}.example.com`,
|
|
28
|
+
paths: [{ path: "/", pathType: "Prefix" }],
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
tls: {
|
|
32
|
+
enabled: true,
|
|
33
|
+
secretName: `${name}-tls`,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
certManager: {
|
|
37
|
+
enabled: true,
|
|
38
|
+
clusterIssuer,
|
|
39
|
+
},
|
|
40
|
+
}, defs?.values));
|
|
41
|
+
const ingress = new Ingress(mergeDefaults(If(values.ingress.enabled, {
|
|
42
|
+
apiVersion: "networking.k8s.io/v1",
|
|
43
|
+
kind: "Ingress",
|
|
44
|
+
metadata: {
|
|
45
|
+
name: include(`${name}.fullname`),
|
|
46
|
+
labels: include(`${name}.labels`),
|
|
47
|
+
annotations: toYaml(values.ingress.annotations),
|
|
48
|
+
},
|
|
49
|
+
spec: {
|
|
50
|
+
ingressClassName: values.ingress.className,
|
|
51
|
+
tls: [{
|
|
52
|
+
secretName: values.ingress.tls.secretName,
|
|
53
|
+
hosts: Range(values.ingress.hosts, values.ingress.hosts),
|
|
54
|
+
}],
|
|
55
|
+
rules: Range(values.ingress.hosts, {
|
|
56
|
+
host: values.ingress.hosts,
|
|
57
|
+
http: {
|
|
58
|
+
paths: values.ingress.hosts,
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
},
|
|
62
|
+
}), defs?.ingress));
|
|
63
|
+
// cert-manager Certificate CRD (cert-manager.io/v1)
|
|
64
|
+
const certificate = new Certificate(mergeDefaults(If(values.certManager.enabled, {
|
|
65
|
+
apiVersion: "cert-manager.io/v1",
|
|
66
|
+
kind: "Certificate",
|
|
67
|
+
metadata: {
|
|
68
|
+
name: include(`${name}.fullname`),
|
|
69
|
+
labels: include(`${name}.labels`),
|
|
70
|
+
},
|
|
71
|
+
spec: {
|
|
72
|
+
secretName: values.ingress.tls.secretName,
|
|
73
|
+
issuerRef: {
|
|
74
|
+
name: values.certManager.clusterIssuer,
|
|
75
|
+
kind: "ClusterIssuer",
|
|
76
|
+
},
|
|
77
|
+
dnsNames: values.ingress.hosts,
|
|
78
|
+
},
|
|
79
|
+
}), defs?.certificate));
|
|
80
|
+
return {
|
|
81
|
+
chart,
|
|
82
|
+
values: valuesRes,
|
|
83
|
+
ingress,
|
|
84
|
+
certificate,
|
|
85
|
+
};
|
|
86
|
+
}, "HelmSecureIngress");
|