Skip to content

Commit 8d44f9a

Browse files
younslCopilot
andauthored
feat(helm): add extraObjects for arbitrary manifests (#2174)
## Summary Adds an optional top-level `extraObjects` value that renders arbitrary Kubernetes manifests within the kagent chart. It is empty by default so existing installs stay unaffected. Each entry is rendered through `tpl` so values can reference the release context such as `{{ include "kagent.fullname" . }}` or `{{ .Release.Namespace }}`. Both map and multi-line string entries are supported. This lets users manage companion resources like `ExternalSecret` or `HTTPRoute` in the same chart lifecycle. It follows a common pattern used by community charts such as: - grafana - kube-prometheus-stack - external-secrets ## Changes - New template `templates/extra-objects.yaml` ranging over `.Values.extraObjects` (default `[]`). - Documented `extraObjects` in `values.yaml` with an `ExternalSecret` example. - Added helm-unittest suite `tests/extra-objects_test.yaml`. ## Testing `helm unittest helm/kagent` passes. The new suite covers the empty default map entries multiple documents `tpl` evaluation against the release context and multi-line string entries. ## Notes This change was originally intended for #2165 but was split into its own PR at a maintainer request so each concern can be reviewed on its own. --------- Signed-off-by: younsl <cysl@kakao.com> Signed-off-by: Younsung Lee <cysl@kakao.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 54ded51 commit 8d44f9a

3 files changed

Lines changed: 131 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Render arbitrary user-supplied manifests so resources such as ExternalSecret,
2+
# HTTPRoute, or NetworkPolicy can be managed within the same chart lifecycle.
3+
# Each entry is processed through `tpl`, so values may reference the release
4+
# context (e.g. {{ "{{ include \"kagent.fullname\" . }}" }} or {{ "{{ .Release.Namespace }}" }}).
5+
{{- range .Values.extraObjects }}
6+
---
7+
{{- if typeIs "string" . }}
8+
{{ tpl . $ }}
9+
{{- else }}
10+
{{ tpl (toYaml .) $ }}
11+
{{- end }}
12+
{{- end }}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
suite: test extra objects
2+
templates:
3+
- extra-objects.yaml
4+
tests:
5+
- it: should not render anything when extraObjects is empty
6+
asserts:
7+
- hasDocuments:
8+
count: 0
9+
10+
- it: should render a map entry as a manifest
11+
set:
12+
extraObjects:
13+
- apiVersion: v1
14+
kind: ConfigMap
15+
metadata:
16+
name: extra-cm
17+
data:
18+
foo: bar
19+
asserts:
20+
- hasDocuments:
21+
count: 1
22+
- isKind:
23+
of: ConfigMap
24+
- equal:
25+
path: metadata.name
26+
value: extra-cm
27+
- equal:
28+
path: data.foo
29+
value: bar
30+
31+
- it: should render multiple entries as separate documents
32+
set:
33+
extraObjects:
34+
- apiVersion: v1
35+
kind: ConfigMap
36+
metadata:
37+
name: extra-cm-1
38+
- apiVersion: v1
39+
kind: Secret
40+
metadata:
41+
name: extra-secret-1
42+
asserts:
43+
- hasDocuments:
44+
count: 2
45+
46+
- it: should evaluate tpl expressions against the release context in map entries
47+
release:
48+
name: my-release
49+
namespace: my-namespace
50+
set:
51+
extraObjects:
52+
- apiVersion: v1
53+
kind: ConfigMap
54+
metadata:
55+
name: '{{ include "kagent.fullname" . }}-extra'
56+
namespace: '{{ .Release.Namespace }}'
57+
asserts:
58+
- equal:
59+
path: metadata.name
60+
value: my-release-extra
61+
- equal:
62+
path: metadata.namespace
63+
value: my-namespace
64+
65+
- it: should render and template a multi-line string entry
66+
release:
67+
name: my-release
68+
set:
69+
extraObjects:
70+
- |
71+
apiVersion: v1
72+
kind: ConfigMap
73+
metadata:
74+
name: {{ include "kagent.fullname" . }}-str
75+
data:
76+
release: {{ .Release.Name }}
77+
asserts:
78+
- hasDocuments:
79+
count: 1
80+
- isKind:
81+
of: ConfigMap
82+
- equal:
83+
path: metadata.name
84+
value: my-release-str
85+
- equal:
86+
path: data.release
87+
value: my-release

helm/kagent/values.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,3 +932,35 @@ otel:
932932
endpoint: ""
933933
timeout: 15000 # milliseconds
934934
insecure: true
935+
936+
# ==============================================================================
937+
# EXTRA OBJECTS
938+
# ==============================================================================
939+
940+
# -- Additional arbitrary Kubernetes manifests to deploy alongside the chart.
941+
# Each list entry is rendered through `tpl`, so values may reference the release
942+
# context (e.g. `{{ include "kagent.fullname" . }}`, `{{ .Release.Namespace }}`).
943+
# Both map and multi-line string entries are supported. Use this to manage
944+
# resources such as ExternalSecret, HTTPRoute, or NetworkPolicy within the same
945+
# chart lifecycle without maintaining a separate chart.
946+
#
947+
# To use, replace the empty list below with your manifests, e.g.:
948+
# extraObjects:
949+
# - apiVersion: external-secrets.io/v1
950+
# kind: ExternalSecret
951+
# metadata:
952+
# name: '{{ include "kagent.fullname" . }}-openai'
953+
# namespace: '{{ .Release.Namespace }}'
954+
# spec:
955+
# secretStoreRef:
956+
# name: aws-secretsmanager
957+
# kind: ClusterSecretStore
958+
# target:
959+
# name: kagent-openai
960+
# data:
961+
# - secretKey: OPENAI_API_KEY
962+
# remoteRef:
963+
# key: prod/kagent/openai
964+
# property: api_key
965+
# @default -- []
966+
extraObjects: []

0 commit comments

Comments
 (0)