From a6f3960f4017942fe359f3cd60fc975f7bcdeb8f Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Thu, 6 Nov 2025 14:12:50 +0100 Subject: [PATCH 1/2] fix(helm): model config for multiple providers generate **multiple ModelConfig resources** (one per provider) instead of just one for the default provider. Signed-off-by: Nicolas Lamirault --- helm/kagent/templates/modelconfig.yaml | 33 +++++++++++++-------- helm/kagent/tests/modelconfig_test.yaml | 39 +++++++++++++++++++++++-- 2 files changed, 58 insertions(+), 14 deletions(-) diff --git a/helm/kagent/templates/modelconfig.yaml b/helm/kagent/templates/modelconfig.yaml index 4c7651e51..1ca1fe784 100644 --- a/helm/kagent/templates/modelconfig.yaml +++ b/helm/kagent/templates/modelconfig.yaml @@ -1,33 +1,42 @@ {{- $dot := . }} -{{- $defaultProfider := .Values.providers.default | default "openAI" }} -{{- $model := index .Values.providers $defaultProfider }} -{{- if hasKey .Values.providers $defaultProfider | not }} -{{- fail (printf "Provider key=%s is not found under .Values.providers" $defaultProfider) }} +{{- $defaultProvider := .Values.providers.default | default "openAI" }} +{{- if hasKey .Values.providers $defaultProvider | not }} +{{- fail (printf "Provider key=%s is not found under .Values.providers" $defaultProvider) }} {{- end }} +{{- range $providerKey, $model := .Values.providers }} +{{- if ne $providerKey "default" }} --- apiVersion: kagent.dev/v1alpha2 kind: ModelConfig metadata: + {{- if eq $providerKey $defaultProvider }} name: {{ include "kagent.defaultModelConfigName" $dot | quote }} - namespace: {{ include "kagent.namespace" . }} + {{- else }} + name: {{ printf "%s-%s-model-config" (include "kagent.fullname" $dot) $providerKey | trunc 63 | trimSuffix "-" | quote }} + {{- end }} + namespace: {{ include "kagent.namespace" $dot }} labels: {{- include "kagent.labels" $dot | nindent 4 }} + kagent.dev/provider: {{ $providerKey | quote }} + {{- if eq $providerKey $defaultProvider }} + kagent.dev/default: "true" + {{- end }} spec: - {{- with $model }} - provider: {{ .provider | quote }} - model: {{ .model | quote }} + provider: {{ $model.provider | quote }} + model: {{ $model.model | quote }} {{- if $model.apiKeySecretRef }} - apiKeySecret: {{.apiKeySecretRef}} + apiKeySecret: {{ $model.apiKeySecretRef }} {{- end }} {{- if $model.apiKeySecretKey }} - apiKeySecretKey: {{.apiKeySecretKey}} + apiKeySecretKey: {{ $model.apiKeySecretKey }} {{- end }} {{- if hasKey $model "defaultHeaders" }} defaultHeaders: {{- toYaml $model.defaultHeaders | nindent 4 }} {{- end }} {{- if $model.config }} - {{ $dot.Values.providers.default }}: + {{ $providerKey }}: {{- toYaml $model.config | nindent 4 }} {{- end }} - {{- end }} +{{- end }} +{{- end }} diff --git a/helm/kagent/tests/modelconfig_test.yaml b/helm/kagent/tests/modelconfig_test.yaml index 304aa4001..8f5454e4c 100644 --- a/helm/kagent/tests/modelconfig_test.yaml +++ b/helm/kagent/tests/modelconfig_test.yaml @@ -5,79 +5,108 @@ tests: - it: should render modelconfig with default provider asserts: - hasDocuments: - count: 1 + count: 5 - equal: path: metadata.name value: default-model-config + documentIndex: 4 - equal: path: spec.provider value: "OpenAI" + documentIndex: 4 - equal: path: spec.model value: "gpt-4.1-mini" + documentIndex: 4 - it: should use openai configuration by default asserts: - equal: path: spec.provider value: "OpenAI" + documentIndex: 4 - equal: path: spec.model value: "gpt-4.1-mini" + documentIndex: 4 - equal: path: spec.apiKeySecret value: kagent-openai + documentIndex: 4 - equal: path: spec.apiKeySecretKey value: OPENAI_API_KEY + documentIndex: 4 - it: should use anthropic when set as default provider set: providers: default: anthropic asserts: + - equal: + path: metadata.name + value: default-model-config + documentIndex: 0 - equal: path: spec.provider value: "Anthropic" + documentIndex: 0 - equal: path: spec.model value: "claude-3-5-haiku-20241022" + documentIndex: 0 - equal: path: spec.apiKeySecret value: kagent-anthropic + documentIndex: 0 - equal: path: spec.apiKeySecretKey value: ANTHROPIC_API_KEY + documentIndex: 0 - it: should use azure openai when set as default provider set: providers: default: azureOpenAI asserts: + - equal: + path: metadata.name + value: default-model-config + documentIndex: 1 - equal: path: spec.provider value: "AzureOpenAI" + documentIndex: 1 - equal: path: spec.model value: "gpt-4.1-mini" + documentIndex: 1 - equal: path: spec.apiKeySecret value: kagent-azure-openai + documentIndex: 1 - equal: path: spec.apiKeySecretKey value: AZUREOPENAI_API_KEY + documentIndex: 1 - it: should configure ollama provider set: providers: default: ollama asserts: + - equal: + path: metadata.name + value: default-model-config + documentIndex: 3 - equal: path: spec.provider value: "Ollama" + documentIndex: 3 - equal: path: spec.model value: "llama3.2" + documentIndex: 3 - it: should use custom model when configured set: @@ -88,24 +117,29 @@ tests: - equal: path: spec.model value: "gpt-4-turbo" + documentIndex: 4 - it: should have correct labels asserts: - equal: path: metadata.labels["app.kubernetes.io/name"] value: kagent + documentIndex: 4 - equal: path: metadata.labels["app.kubernetes.io/instance"] value: RELEASE-NAME + documentIndex: 4 - equal: path: metadata.labels["app.kubernetes.io/managed-by"] value: Helm + documentIndex: 4 - it: should be in correct namespace asserts: - equal: path: metadata.namespace value: NAMESPACE + documentIndex: 4 - it: should use custom namespace when overridden set: @@ -113,4 +147,5 @@ tests: asserts: - equal: path: metadata.namespace - value: custom-namespace \ No newline at end of file + value: custom-namespace + documentIndex: 4 \ No newline at end of file From 5691968582830cffa1c7fc6461e73324ac208335 Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Thu, 6 Nov 2025 14:16:34 +0100 Subject: [PATCH 2/2] fix(helm): resource naming Signed-off-by: Nicolas Lamirault --- helm/kagent/templates/modelconfig.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/kagent/templates/modelconfig.yaml b/helm/kagent/templates/modelconfig.yaml index 1ca1fe784..840c8f54f 100644 --- a/helm/kagent/templates/modelconfig.yaml +++ b/helm/kagent/templates/modelconfig.yaml @@ -12,7 +12,7 @@ metadata: {{- if eq $providerKey $defaultProvider }} name: {{ include "kagent.defaultModelConfigName" $dot | quote }} {{- else }} - name: {{ printf "%s-%s-model-config" (include "kagent.fullname" $dot) $providerKey | trunc 63 | trimSuffix "-" | quote }} + name: {{ printf "%s-model-config" $providerKey| lower }} {{- end }} namespace: {{ include "kagent.namespace" $dot }} labels: