diff --git a/helm/kagent/templates/controller-deployment.yaml b/helm/kagent/templates/controller-deployment.yaml index 2044c332f..e7e0e6436 100644 --- a/helm/kagent/templates/controller-deployment.yaml +++ b/helm/kagent/templates/controller-deployment.yaml @@ -26,14 +26,18 @@ spec: securityContext: {{- toYaml (.Values.controller.podSecurityContext | default .Values.podSecurityContext) | nindent 8 }} serviceAccountName: {{ include "kagent.fullname" . }}-controller + {{- if or (eq .Values.database.type "sqlite") (gt (len .Values.controller.volumes) 0) }} volumes: + {{- if eq .Values.database.type "sqlite" }} - name: sqlite-volume emptyDir: sizeLimit: 500Mi medium: Memory + {{- end }} {{- with .Values.controller.volumes }} {{- toYaml . | nindent 6 }} {{- end }} + {{- end }} {{- with .Values.controller.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} @@ -127,9 +131,13 @@ spec: path: /health port: http periodSeconds: 30 + {{- if or (eq .Values.database.type "sqlite") (gt (len .Values.controller.volumeMounts) 0) }} volumeMounts: + {{- if eq .Values.database.type "sqlite" }} - name: sqlite-volume mountPath: /sqlite-volume + {{- end }} {{- with .Values.controller.volumeMounts }} {{- toYaml . | nindent 12 }} - {{- end }} \ No newline at end of file + {{- end }} + {{- end }} diff --git a/helm/kagent/tests/controller-deployment_test.yaml b/helm/kagent/tests/controller-deployment_test.yaml index f62fdef9f..9112db6e6 100644 --- a/helm/kagent/tests/controller-deployment_test.yaml +++ b/helm/kagent/tests/controller-deployment_test.yaml @@ -150,4 +150,51 @@ tests: key: role value: AI effect: NoSchedule - operator: Equal \ No newline at end of file + operator: Equal + + - it: should not render sqlite volume and mount when using postgres with extra volumes + template: controller-deployment.yaml + set: + database: + type: postgres + controller: + volumes: + - name: extra-data + emptyDir: {} + volumeMounts: + - name: extra-data + mountPath: /extra + asserts: + # volumes block should exist due to provided extra volumes + - contains: + path: spec.template.spec.volumes + content: + name: extra-data + emptyDir: {} + # sqlite volume must not be present + - notContains: + path: spec.template.spec.volumes + content: + name: sqlite-volume + # volumeMounts block should include our extra mount + - contains: + path: spec.template.spec.containers[0].volumeMounts + content: + name: extra-data + mountPath: /extra + # sqlite volume mount must not be present + - notContains: + path: spec.template.spec.containers[0].volumeMounts + content: + name: sqlite-volume + + - it: should not render volumes or volumeMounts sections when using postgres without extra volumes or mounts + template: controller-deployment.yaml + set: + database: + type: postgres + asserts: + - isNull: + path: spec.template.spec.volumes + - isNull: + path: spec.template.spec.containers[0].volumeMounts \ No newline at end of file diff --git a/helm/kagent/values.yaml b/helm/kagent/values.yaml index bc28e3e98..c5c2e9484 100644 --- a/helm/kagent/values.yaml +++ b/helm/kagent/values.yaml @@ -105,18 +105,18 @@ controller: targetPort: 8083 env: [] -# Additional volumes on the output Deployment definition. + # Additional volumes on the output Deployment definition. volumes: [] -# - name: foo -# secret: -# secretName: mysecret -# optional: false + # - name: foo + # secret: + # secretName: mysecret + # optional: false -# Additional volumeMounts on the output Deployment definition. + # Additional volumeMounts on the output Deployment definition. volumeMounts: [] -# - name: foo -# mountPath: "/etc/foo" -# readOnly: true + # - name: foo + # mountPath: "/etc/foo" + # readOnly: true # ============================================================================== # UI CONFIGURATION