Skip to content

Commit

Permalink
k8s-stack: generate vm components tag from app version by default
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewChubatiuk committed Oct 3, 2024
1 parent 9474517 commit 7fb3861
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion charts/victoria-metrics-k8s-stack/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Next release

- TODO
- Generate VM components tag version from chart app name by default

## 0.27.0

Expand Down
14 changes: 11 additions & 3 deletions charts/victoria-metrics-k8s-stack/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,15 @@ If release name contains chart name it will be used as a full name.
{{- /* VMAlert spec */ -}}
{{- define "vm.alert.spec" -}}
{{- $Values := (.helm).Values | default .Values }}
{{- $Chart := (.helm).Chart | default .Chart }}
{{- $extraArgs := dict "remoteWrite.disablePathAppend" "true" -}}
{{- if $Values.vmalert.templateFiles -}}
{{- $ruleTmpl := (printf "/etc/vm/configs/%s-vmalert-extra-tpl/*.tmpl" (include "victoria-metrics-k8s-stack.fullname" .)) -}}
{{- $_ := set $extraArgs "rule.templates" $ruleTmpl -}}
{{- end -}}
{{- $vmAlertRemotes := (include "vm.alert.remotes" . | fromYaml) -}}
{{- $vmAlertTemplates := (include "vm.alert.templates" . | fromYaml) -}}
{{- $spec := dict "extraArgs" $extraArgs -}}
{{- $spec := dict "extraArgs" $extraArgs "image" (dict "tag" $Chart.AppVersion) -}}
{{- with (include "vm.license.global" .) -}}
{{- $_ := set $spec "license" (fromYaml .) -}}
{{- end -}}
Expand Down Expand Up @@ -276,10 +277,12 @@ If release name contains chart name it will be used as a full name.
{{- /* VMAgent spec */ -}}
{{- define "vm.agent.spec" -}}
{{- $Values := (.helm).Values | default .Values }}
{{- $Chart := (.helm).Chart | default .Chart }}
{{- $spec := (include "vm.agent.remote.write" . | fromYaml) -}}
{{- with (include "vm.license.global" .) -}}
{{- $_ := set $spec "license" (fromYaml .) -}}
{{- end -}}
{{- $_ := set $spec "image" (dict "tag" $Chart.AppVersion) -}}
{{- tpl (deepCopy $Values.vmagent.spec | mergeOverwrite $spec | toYaml) . -}}
{{- end }}

Expand Down Expand Up @@ -344,12 +347,13 @@ If release name contains chart name it will be used as a full name.
{{- /* Single spec */ -}}
{{- define "vm.single.spec" -}}
{{- $Values := (.helm).Values | default .Values }}
{{- $Chart := (.helm).Chart | default .Chart }}
{{- $extraArgs := default dict -}}
{{- if $Values.vmalert.enabled }}
{{- $ctx := dict "helm" . "appKey" "vmalert" -}}
{{- $_ := set $extraArgs "vmalert.proxyURL" (include "vm.url" $ctx) -}}
{{- end -}}
{{- $spec := dict "extraArgs" $extraArgs -}}
{{- $spec := dict "extraArgs" $extraArgs "image" (dict "tag" $Chart.AppVersion) -}}
{{- with (include "vm.license.global" .) -}}
{{- $_ := set $spec "license" (fromYaml .) -}}
{{- end -}}
Expand All @@ -359,18 +363,22 @@ If release name contains chart name it will be used as a full name.
{{- /* Cluster spec */ -}}
{{- define "vm.select.spec" -}}
{{- $Values := (.helm).Values | default .Values }}
{{- $Chart := (.helm).Chart | default .Chart }}
{{- $extraArgs := default dict -}}
{{- if $Values.vmalert.enabled -}}
{{- $ctx := dict "helm" . "appKey" "vmalert" -}}
{{- $_ := set $extraArgs "vmalert.proxyURL" (include "vm.url" $ctx) -}}
{{- end -}}
{{- $spec := dict "extraArgs" $extraArgs -}}
{{- $spec := dict "extraArgs" $extraArgs "image" (dict "tag" (printf "%s-cluster" $Chart.AppVersion)) -}}
{{- toYaml $spec -}}
{{- end -}}

{{- define "vm.cluster.spec" -}}
{{- $Values := (.helm).Values | default .Values }}
{{- $Chart := (.helm).Chart | default .Chart }}
{{- $spec := (include "vm.select.spec" . | fromYaml) -}}
{{- $_ := set $spec.vminsert.image.tag (printf "%s-cluster" $Chart.AppVersion) -}}
{{- $_ := set $spec.vmstorage.image.tag (printf "%s-cluster" $Chart.AppVersion) -}}
{{- $clusterSpec := (deepCopy $Values.vmcluster.spec) -}}
{{- with (include "vm.license.global" .) -}}
{{- $_ := set $clusterSpec "license" (fromYaml .) -}}
Expand Down
12 changes: 0 additions & 12 deletions charts/victoria-metrics-k8s-stack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,6 @@ vmsingle:
# -- Full spec for VMSingle CRD. Allowed values describe [here](https://docs.victoriametrics.com/operator/api#vmsinglespec)
spec:
port: "8429"
image:
tag: v1.104.0
# -- Data retention period. Possible units character: h(ours), d(ays), w(eeks), y(ears), if no unit character specified - month. The minimum retention period is 24h. See these [docs](https://docs.victoriametrics.com/single-server-victoriametrics/#retention)
retentionPeriod: "1"
replicaCount: 1
Expand Down Expand Up @@ -320,8 +318,6 @@ vmcluster:
retentionPeriod: "1"
replicationFactor: 2
vmstorage:
image:
tag: v1.104.0-cluster
replicaCount: 2
storageDataPath: "/vm-data"
storage:
Expand All @@ -337,8 +333,6 @@ vmcluster:
# memory: 1500Mi
vmselect:
port: "8481"
image:
tag: v1.104.0-cluster
replicaCount: 2
cacheMountPath: "/select-cache"
extraArgs: {}
Expand All @@ -358,8 +352,6 @@ vmcluster:
# memory: "500Mi"
vminsert:
port: "8480"
image:
tag: v1.104.0-cluster
replicaCount: 2
extraArgs: {}
resources:
Expand Down Expand Up @@ -667,8 +659,6 @@ vmalert:
spec:
port: "8080"
selectAllByDefault: true
image:
tag: v1.104.0
evaluationInterval: 15s
extraArgs:
http.pathPrefix: "/"
Expand Down Expand Up @@ -748,8 +738,6 @@ vmagent:
spec:
port: "8429"
selectAllByDefault: true
image:
tag: v1.104.0
scrapeInterval: 20s
externalLabels: {}
# For multi-cluster setups it is useful to use "cluster" label to identify the metrics source.
Expand Down

0 comments on commit 7fb3861

Please sign in to comment.