Skip to content

Commit

Permalink
Fix image tag for Antrea and FlowAggregator Helm charts (antrea-io#4141)
Browse files Browse the repository at this point in the history
When installing a released version of a chart (for Antrea or the
FlowAggregator), the image tag was not generated correctly. It was
missing the leading "v".

Fixes antrea-io#4137

Signed-off-by: Antonin Bas <abas@vmware.com>
  • Loading branch information
antoninbas authored Aug 24, 2022
1 parent a9e02d4 commit 04d18cd
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
14 changes: 14 additions & 0 deletions build/charts/antrea/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,17 @@
{{ printf "# %s" $name }}: {{ $default }}
{{- end }}
{{- end -}}

{{- define "antreaImageTag" -}}
{{- if .Values.image.tag }}
{{- .Values.image.tag -}}
{{- else if eq .Chart.AppVersion "latest" }}
{{- print "latest" -}}
{{- else }}
{{- print "v" .Chart.AppVersion -}}
{{- end }}
{{- end -}}

{{- define "antreaImage" -}}
{{- print .Values.image.repository ":" (include "antreaImageTag" .) -}}
{{- end -}}
10 changes: 5 additions & 5 deletions build/charts/antrea/templates/agent/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ spec:
initContainers:
{{- if .Values.whereabouts.enable }}
- name: install-whereabouts-config
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}"
image: {{ include "antreaImage" . | quote }}
resources:
requests:
cpu: "100m"
Expand All @@ -82,7 +82,7 @@ spec:
containers:
{{- end }}
- name: install-cni
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}"
image: {{ include "antreaImage" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources: {{- .Values.agent.installCNI.resources | toYaml | nindent 12 }}
{{- if eq .Values.trafficEncapMode "networkPolicyOnly" }}
Expand Down Expand Up @@ -121,7 +121,7 @@ spec:
containers:
{{- end }}
- name: antrea-agent
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}"
image: {{ include "antreaImage" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if ((.Values.testing).coverage) }}
command: ["/bin/sh"]
Expand Down Expand Up @@ -248,7 +248,7 @@ spec:
{{- toYaml . | trim | nindent 10 }}
{{- end }}
- name: antrea-ovs
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}"
image: {{ include "antreaImage" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources: {{- .Values.agent.antreaOVS.resources | toYaml | nindent 12 }}
command: ["start_ovs"]
Expand Down Expand Up @@ -290,7 +290,7 @@ spec:
subPath: openvswitch
{{- if eq .Values.trafficEncryptionMode "ipsec" }}
- name: antrea-ipsec
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}"
image: {{ include "antreaImage" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources: {{- .Values.agent.antreaIPsec.resources | toYaml | nindent 12 }}
command: ["start_ovs_ipsec"]
Expand Down
2 changes: 1 addition & 1 deletion build/charts/antrea/templates/controller/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ spec:
serviceAccountName: antrea-controller
containers:
- name: antrea-controller
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}"
image: {{ include "antreaImage" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources: {{- .Values.controller.antreaController.resources | toYaml | nindent 12 }}
{{- if ((.Values.testing).coverage) }}
Expand Down
13 changes: 13 additions & 0 deletions build/charts/flow-aggregator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- define "flowAggregatorImageTag" -}}
{{- if .Values.image.tag }}
{{- .Values.image.tag -}}
{{- else if eq .Chart.AppVersion "latest" }}
{{- print "latest" -}}
{{- else }}
{{- print "v" .Chart.AppVersion -}}
{{- end }}
{{- end -}}

{{- define "flowAggregatorImage" -}}
{{- print .Values.image.repository ":" (include "flowAggregatorImageTag" .) -}}
{{- end -}}
2 changes: 1 addition & 1 deletion build/charts/flow-aggregator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
spec:
containers:
- name: flow-aggregator
image: {{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}
image: {{ include "flowAggregatorImage" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.testing.coverage }}
command: [ "/bin/sh" ]
Expand Down

0 comments on commit 04d18cd

Please sign in to comment.