From c6f65c242af87256864a9adeb15e9e4c03b8df2b Mon Sep 17 00:00:00 2001 From: Matt Campbell Date: Thu, 23 May 2024 16:43:13 +0000 Subject: [PATCH] BUG: kubernetes-ingress: Replace tpl with default Since `tpl` expects a string, passing an unqouted, fully-numeric image tag value results in a helm templating error, e.g.: ``` INFO[0000] install.go:214: [debug] Original chart version: "" install.go:231: [debug] CHART PATH: /home/mcampbell/github/coreweave/api-gateway/integration_tests Error: template: cloud-integration-tests/charts/cloud-app/charts/api-gateway/charts/kubernetes-ingress/templates/controller-deployment.yaml:91:74: executing "cloud-integration-tests/charts/cloud-app/charts/api-gateway/charts/kubernetes-ingress/templates/controller-deployment.yaml" at <.Values.controller.image.tag>: wrong type for value; expected string; got int64 helm.go:84: [debug] template: cloud-integration-tests/charts/cloud-app/charts/api-gateway/charts/kubernetes-ingress/templates/controller-deployment.yaml:91:74: executing "cloud-integration-tests/charts/cloud-app/charts/api-gateway/charts/kubernetes-ingress/templates/controller-deployment.yaml" at <.Values.controller.image.tag>: wrong type for value; expected string; got int64 subtask=0 task=Render std out err: %!(EXTRA *errors.errorString=install.go:214: [debug] Original chart version: "" install.go:231: [debug] CHART PATH: /home/mcampbell/github/coreweave/api-gateway/integration_tests Error: template: cloud-integration-tests/charts/cloud-app/charts/api-gateway/charts/kubernetes-ingress/templates/controller-deployment.yaml:91:74: executing "cloud-integration-tests/charts/cloud-app/charts/api-gateway/charts/kubernetes-ingress/templates/controller-deployment.yaml" at <.Values.controller.image.tag>: wrong type for value; expected string; got int64 helm.go:84: [debug] template: cloud-integration-tests/charts/cloud-app/charts/api-gateway/charts/kubernetes-ingress/templates/controller-deployment.yaml:91:74: executing "cloud-integration-tests/charts/cloud-app/charts/api-gateway/charts/kubernetes-ingress/templates/controller-deployment.yaml" at <.Values.controller.image.tag>: wrong type for value; expected string; got int64 ``` --- haproxy/templates/NOTES.txt | 2 +- haproxy/templates/daemonset.yaml | 2 +- haproxy/templates/deployment.yaml | 2 +- haproxy/values.yaml | 3 ++- kubernetes-ingress/templates/NOTES.txt | 2 +- kubernetes-ingress/templates/controller-crdjob.yaml | 2 +- kubernetes-ingress/templates/controller-daemonset.yaml | 2 +- kubernetes-ingress/templates/controller-deployment.yaml | 2 +- kubernetes-ingress/values.yaml | 3 ++- 9 files changed, 11 insertions(+), 9 deletions(-) diff --git a/haproxy/templates/NOTES.txt b/haproxy/templates/NOTES.txt index e46f588..50eb679 100644 --- a/haproxy/templates/NOTES.txt +++ b/haproxy/templates/NOTES.txt @@ -1,7 +1,7 @@ HAProxy has been has been successfully installed. This Chart is used to run HAProxy as a regular application, as opposed to HAProxy Ingress Controller Chart. -Controller image deployed is: "{{ .Values.image.repository }}:{{ tpl .Values.image.tag . }}". +Controller image deployed is: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}". Your HAProxy app is of a "{{ .Values.kind }}" kind. Service ports mapped are: diff --git a/haproxy/templates/daemonset.yaml b/haproxy/templates/daemonset.yaml index 9c8eac2..a7d6b99 100644 --- a/haproxy/templates/daemonset.yaml +++ b/haproxy/templates/daemonset.yaml @@ -105,7 +105,7 @@ spec: {{- if .Values.securityContext.enabled }} securityContext: {{- omit .Values.securityContext "enabled" | toYaml | nindent 12 }} {{- end }} - image: "{{ .Values.image.repository }}:{{ tpl .Values.image.tag . }}" + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} {{- if .Values.args.enabled }} args: diff --git a/haproxy/templates/deployment.yaml b/haproxy/templates/deployment.yaml index 444e2bb..2c7d445 100644 --- a/haproxy/templates/deployment.yaml +++ b/haproxy/templates/deployment.yaml @@ -106,7 +106,7 @@ spec: {{- if .Values.securityContext.enabled }} securityContext: {{- omit .Values.securityContext "enabled" | toYaml | nindent 12 }} {{- end }} - image: "{{ .Values.image.repository }}:{{ tpl .Values.image.tag . }}" + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} {{- if .Values.args.enabled }} args: diff --git a/haproxy/values.yaml b/haproxy/values.yaml index 13adc4a..479155c 100644 --- a/haproxy/values.yaml +++ b/haproxy/values.yaml @@ -31,7 +31,8 @@ serviceAccount: ## Default values for image image: repository: haproxytech/haproxy-alpine # can be changed to use CE or EE images - tag: "{{ .Chart.AppVersion }}" + # Overrides the image tag whose default is the chart appVersion + tag: "" pullPolicy: IfNotPresent ## Automatically Roll Deployments diff --git a/kubernetes-ingress/templates/NOTES.txt b/kubernetes-ingress/templates/NOTES.txt index 0c37a87..2461949 100644 --- a/kubernetes-ingress/templates/NOTES.txt +++ b/kubernetes-ingress/templates/NOTES.txt @@ -1,6 +1,6 @@ HAProxy Kubernetes Ingress Controller has been successfully installed. -Controller image deployed is: "{{ .Values.controller.image.repository }}:{{ tpl .Values.controller.image.tag . }}". +Controller image deployed is: "{{ .Values.controller.image.repository }}:{{ .Values.controller.image.tag | default .Chart.AppVersion }}". Your controller is of a "{{ .Values.controller.kind }}" kind. Your controller service is running as a "{{ .Values.controller.service.type }}" type. {{- if .Values.rbac.create}} RBAC authorization is enabled. diff --git a/kubernetes-ingress/templates/controller-crdjob.yaml b/kubernetes-ingress/templates/controller-crdjob.yaml index daf231d..ce3c000 100644 --- a/kubernetes-ingress/templates/controller-crdjob.yaml +++ b/kubernetes-ingress/templates/controller-crdjob.yaml @@ -69,7 +69,7 @@ spec: {{- end }} containers: - name: crd - image: "{{ .Values.controller.image.repository }}:{{ tpl .Values.controller.image.tag . }}" + image: "{{ .Values.controller.image.repository }}:{{ .Values.controller.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.controller.image.pullPolicy }} command: - /haproxy-ingress-controller diff --git a/kubernetes-ingress/templates/controller-daemonset.yaml b/kubernetes-ingress/templates/controller-daemonset.yaml index 2495248..23a8c7b 100644 --- a/kubernetes-ingress/templates/controller-daemonset.yaml +++ b/kubernetes-ingress/templates/controller-daemonset.yaml @@ -88,7 +88,7 @@ spec: {{- end }} containers: - name: {{ include "kubernetes-ingress.name" . }}-{{ .Values.controller.name }} - image: "{{ .Values.controller.image.repository }}:{{ tpl .Values.controller.image.tag . }}" + image: "{{ .Values.controller.image.repository }}:{{ .Values.controller.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.controller.image.pullPolicy }} args: {{- if .Values.controller.defaultTLSSecret.enabled -}} diff --git a/kubernetes-ingress/templates/controller-deployment.yaml b/kubernetes-ingress/templates/controller-deployment.yaml index 12b7242..7024fdd 100644 --- a/kubernetes-ingress/templates/controller-deployment.yaml +++ b/kubernetes-ingress/templates/controller-deployment.yaml @@ -88,7 +88,7 @@ spec: {{- end }} containers: - name: {{ include "kubernetes-ingress.name" . }}-{{ .Values.controller.name }} - image: "{{ .Values.controller.image.repository }}:{{ tpl .Values.controller.image.tag . }}" + image: "{{ .Values.controller.image.repository }}:{{ .Values.controller.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.controller.image.pullPolicy }} args: {{- if .Values.controller.defaultTLSSecret.enabled -}} diff --git a/kubernetes-ingress/values.yaml b/kubernetes-ingress/values.yaml index 3cd4ffd..b6b72ad 100644 --- a/kubernetes-ingress/values.yaml +++ b/kubernetes-ingress/values.yaml @@ -61,7 +61,8 @@ controller: name: controller image: repository: haproxytech/kubernetes-ingress # can be changed to use CE or EE Controller images - tag: "{{ .Chart.AppVersion }}" + # Overrides the image tag whose default is the chart appVersion + tag: "" pullPolicy: IfNotPresent ## Deployment or DaemonSet pod mode