Skip to content

Commit

Permalink
add cost model image tag as env var (#3710)
Browse files Browse the repository at this point in the history
* add cost model image tag as env var

* nit fix
  • Loading branch information
mittal-ishaan authored Oct 15, 2024
1 parent 6522173 commit 49ec3fe
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
25 changes: 24 additions & 1 deletion cost-analyzer/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1525,4 +1525,27 @@ for more information
{{- $checksum = printf "%s%s" $checksum $content | sha256sum -}}
{{- end -}}
{{- $checksum | sha256sum -}}
{{- end -}}
{{- end -}}

{{- define "cost-model.image" }}
{{- if .Values.kubecostModel }}
{{- if .Values.kubecostModel.fullImageName }}
{{ .Values.kubecostModel.fullImageName }}
{{- else if .Values.imageVersion }}
{{ .Values.kubecostModel.image }}:{{ .Values.imageVersion }}
{{- else if eq "development" .Chart.AppVersion }}
gcr.io/kubecost1/cost-model-nightly:latest
{{- else }}
{{ .Values.kubecostModel.image }}:prod-{{ $.Chart.AppVersion }}
{{- end }}
{{- else }}
gcr.io/kubecost1/cost-model:prod-{{ $.Chart.AppVersion }}
{{- end }}
{{- end }}

{{- define "cost-model.imagetag" }}
{{- $image := include "cost-model.image" . }}
{{- $parts := splitList ":" $image }}
{{- $tag := last $parts }}
{{- $tag }}
{{- end }}
16 changes: 3 additions & 13 deletions cost-analyzer/templates/cost-analyzer-deployment-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -577,19 +577,7 @@ spec:
successThreshold: 1
timeoutSeconds: 5
{{- end }}
{{- if .Values.kubecostModel }}
{{- if .Values.kubecostModel.fullImageName }}
- image: {{ .Values.kubecostModel.fullImageName }}
{{- else if .Values.imageVersion }}
- image: {{ .Values.kubecostModel.image }}:{{ .Values.imageVersion }}
{{- else if eq "development" .Chart.AppVersion }}
- image: gcr.io/kubecost1/cost-model-nightly:latest
{{- else }}
- image: {{ .Values.kubecostModel.image }}:prod-{{ $.Chart.AppVersion }}
{{- end }}
{{- else }}
- image: gcr.io/kubecost1/cost-model:prod-{{ $.Chart.AppVersion }}
{{- end }}
- image: {{ include "cost-model.image" . | trim | quote}}
name: cost-model
{{- if .Values.kubecostModel.extraArgs }}
args:
Expand Down Expand Up @@ -746,6 +734,8 @@ spec:
{{- end }}
{{- end }}
env:
- name: CONTAINER_IMAGE_TAG
value: {{ include "cost-model.imagetag" . }}
{{- if .Values.global.grafana }}
- name: GRAFANA_ENABLED
value: "{{ template "cost-analyzer.grafanaEnabled" . }}"
Expand Down

0 comments on commit 49ec3fe

Please sign in to comment.