Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions helm/kagent/templates/extra-objects.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Render arbitrary user-supplied manifests so resources such as ExternalSecret,
# HTTPRoute, or NetworkPolicy can be managed within the same chart lifecycle.
# Each entry is processed through `tpl`, so values may reference the release
# context (e.g. {{ "{{ include \"kagent.fullname\" . }}" }} or {{ "{{ .Release.Namespace }}" }}).
{{- range .Values.extraObjects }}
---
{{- if typeIs "string" . }}
{{ tpl . $ }}
{{- else }}
{{ tpl (toYaml .) $ }}
{{- end }}
{{- end }}
87 changes: 87 additions & 0 deletions helm/kagent/tests/extra-objects_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
suite: test extra objects
templates:
- extra-objects.yaml
tests:
- it: should not render anything when extraObjects is empty
asserts:
- hasDocuments:
count: 0

- it: should render a map entry as a manifest
set:
extraObjects:
- apiVersion: v1
kind: ConfigMap
metadata:
name: extra-cm
data:
foo: bar
asserts:
- hasDocuments:
count: 1
- isKind:
of: ConfigMap
- equal:
path: metadata.name
value: extra-cm
- equal:
path: data.foo
value: bar

- it: should render multiple entries as separate documents
set:
extraObjects:
- apiVersion: v1
kind: ConfigMap
metadata:
name: extra-cm-1
- apiVersion: v1
kind: Secret
metadata:
name: extra-secret-1
asserts:
- hasDocuments:
count: 2

- it: should evaluate tpl expressions against the release context in map entries
release:
name: my-release
namespace: my-namespace
set:
extraObjects:
- apiVersion: v1
kind: ConfigMap
metadata:
name: '{{ include "kagent.fullname" . }}-extra'
namespace: '{{ .Release.Namespace }}'
asserts:
- equal:
path: metadata.name
value: my-release-extra
- equal:
path: metadata.namespace
value: my-namespace

- it: should render and template a multi-line string entry
release:
name: my-release
set:
extraObjects:
- |
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "kagent.fullname" . }}-str
data:
release: {{ .Release.Name }}
asserts:
- hasDocuments:
count: 1
- isKind:
of: ConfigMap
- equal:
path: metadata.name
value: my-release-str
- equal:
path: data.release
value: my-release
29 changes: 29 additions & 0 deletions helm/kagent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -854,3 +854,32 @@ otel:
endpoint: ""
timeout: 15000 # milliseconds
insecure: true

# ==============================================================================
# EXTRA OBJECTS
# ==============================================================================

# -- Additional arbitrary Kubernetes manifests to deploy alongside the chart.
# Each list entry is rendered through `tpl`, so values may reference the release
# context (e.g. `{{ include "kagent.fullname" . }}`, `{{ .Release.Namespace }}`).
# Both map and multi-line string entries are supported. Use this to manage
# resources such as ExternalSecret, HTTPRoute, or NetworkPolicy within the same
# chart lifecycle without maintaining a separate chart.
# @default -- []
extraObjects: []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uncommenting the example lines without also changing extraObjects: [] to extraObjects: produces a yaml parse error. two edits are required, but only one is obvious.

# - apiVersion: external-secrets.io/v1
# kind: ExternalSecret
# metadata:
# name: '{{ include "kagent.fullname" . }}-openai'
# namespace: '{{ .Release.Namespace }}'
# spec:
# secretStoreRef:
# name: aws-secretsmanager
# kind: ClusterSecretStore
# target:
# name: kagent-openai
# data:
# - secretKey: OPENAI_API_KEY
# remoteRef:
# key: prod/kagent/openai
# property: api_key