Skip to content

Commit

Permalink
charts: properly truncate labels for long release names (#973)
Browse files Browse the repository at this point in the history
Properly truncate "app.kubernetes.io/managed-by" and "app.kubernetes.io/instance" labels for long release names.
Apply limit of 63 chars for all truncated labels.

This is a follow-up to cd6921b
  • Loading branch information
zekker6 committed Apr 23, 2024
1 parent cd44539 commit aaada4f
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 30 deletions.
3 changes: 2 additions & 1 deletion charts/victoria-logs-single/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## Next release

- TODO
- properly truncate value of `app.kubernetes.io/managed-by` and `app.kubernetes.io/instance` labels in case release name exceeds 63 characters.


## 0.3.7

Expand Down
4 changes: 2 additions & 2 deletions charts/victoria-logs-single/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ Create unified labels for victoria-logs components
*/}}
{{- define "victoria-logs.common.matchLabels" -}}
app.kubernetes.io/name: {{ include "victoria-logs.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/instance: {{ .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{- define "victoria-logs.common.metaLabels" -}}
helm.sh/chart: {{ include "victoria-logs.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/managed-by: {{ .Release.Service | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{- define "victoria-logs.server.labels" -}}
Expand Down
2 changes: 1 addition & 1 deletion charts/victoria-metrics-agent/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Next release

- TODO
- properly truncate value of `app.kubernetes.io/managed-by` and `app.kubernetes.io/instance` labels in case release name exceeds 63 characters.

## 0.10.5

Expand Down
4 changes: 2 additions & 2 deletions charts/victoria-metrics-agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ helm.sh/chart: {{ include "chart.chart" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/managed-by: {{ .Release.Service | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{/*
Selector labels
*/}}
{{- define "chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/instance: {{ .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{/*
Expand Down
2 changes: 1 addition & 1 deletion charts/victoria-metrics-alert/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Next release

- TODO
- properly truncate value of `app.kubernetes.io/managed-by` and `app.kubernetes.io/instance` labels in case release name exceeds 63 characters.

## 0.9.5

Expand Down
4 changes: 2 additions & 2 deletions charts/victoria-metrics-alert/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ Create unified labels for vmalert components
*/}}
{{- define "vmalert.common.matchLabels" -}}
app.kubernetes.io/name: {{ include "vmalert.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/instance: {{ .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{- define "vmalert.common.metaLabels" -}}
helm.sh/chart: {{ include "vmalert.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/managed-by: {{ .Release.Service | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{- define "vmalert.server.labels" -}}
Expand Down
4 changes: 2 additions & 2 deletions charts/victoria-metrics-anomaly/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ helm.sh/chart: {{ include "chart.chart" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/managed-by: {{ .Release.Service | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/instance: {{ .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}


Expand Down
2 changes: 1 addition & 1 deletion charts/victoria-metrics-auth/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Next release

- TODO
- properly truncate value of `app.kubernetes.io/managed-by` and `app.kubernetes.io/instance` labels in case release name exceeds 63 characters.

## 0.4.9

Expand Down
4 changes: 2 additions & 2 deletions charts/victoria-metrics-auth/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ helm.sh/chart: {{ include "chart.chart" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/managed-by: {{ .Release.Service | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{/*
Selector labels
*/}}
{{- define "chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/instance: {{ .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{/*
Expand Down
2 changes: 1 addition & 1 deletion charts/victoria-metrics-cluster/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Next release

- TODO
- properly truncate value of `app.kubernetes.io/managed-by` and `app.kubernetes.io/instance` labels in case release name exceeds 63 characters. See [this issue](https://github.com/VictoriaMetrics/helm-charts/issues/931) and [this PR](https://github.com/VictoriaMetrics/helm-charts/pull/936).

## 0.11.15

Expand Down
16 changes: 8 additions & 8 deletions charts/victoria-metrics-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ Create the name of the service account
Create unified labels for victoria-metrics components
*/}}
{{- define "victoria-metrics.common.matchLabels" -}}
app.kubernetes.io/name: {{ include "victoria-metrics.name" . | trunc 60 }}
app.kubernetes.io/instance: {{ .Release.Name | trunc 60 }}
app.kubernetes.io/name: {{ include "victoria-metrics.name" . }}
app.kubernetes.io/instance: {{ .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{- define "victoria-metrics.common.metaLabels" -}}
helm.sh/chart: {{ include "victoria-metrics.chart" . | trunc 60 }}
app.kubernetes.io/managed-by: {{ .Release.Service | trunc 60 }}
helm.sh/chart: {{ include "victoria-metrics.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{- define "victoria-metrics.common.podLabels" -}}
app.kubernetes.io/managed-by: {{ .Release.Service | trunc 60}}
app.kubernetes.io/managed-by: {{ .Release.Service | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{- define "victoria-metrics.vmstorage.labels" -}}
Expand Down Expand Up @@ -110,13 +110,13 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
*/}}
{{- define "victoria-metrics.vmstorage.fullname" -}}
{{- if .Values.vmstorage.fullnameOverride -}}
{{- .Values.vmstorage.fullnameOverride | trunc 60 | trimSuffix "-" -}}
{{- .Values.vmstorage.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- printf "%s-%s" .Release.Name .Values.vmstorage.name | trunc 60 | trimSuffix "-" -}}
{{- printf "%s-%s" .Release.Name .Values.vmstorage.name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s-%s" .Release.Name $name .Values.vmstorage.name | trunc 60 | trimSuffix "-" -}}
{{- printf "%s-%s-%s" .Release.Name $name .Values.vmstorage.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
Expand Down
4 changes: 2 additions & 2 deletions charts/victoria-metrics-gateway/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ helm.sh/chart: {{ include "chart.chart" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/managed-by: {{ .Release.Service | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{/*
Selector labels
*/}}
{{- define "chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/instance: {{ .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{/*
Expand Down
1 change: 1 addition & 0 deletions charts/victoria-metrics-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

- updates operator to v0.43.0-0 version
- adds `events` create permission
- properly truncate value of `app.kubernetes.io/managed-by` and `app.kubernetes.io/instance` labels in case release name exceeds 63 characters.

## 0.29.6

Expand Down
4 changes: 2 additions & 2 deletions charts/victoria-metrics-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Selector labels
*/}}
{{- define "vm-operator.selectorLabels" -}}
app.kubernetes.io/name: {{ include "vm-operator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/instance: {{ .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{/*
Expand All @@ -56,7 +56,7 @@ Create unified labels for vm-operator components
{{- define "vm-operator.labels" -}}
{{- include "vm-operator.selectorLabels" . }}
helm.sh/chart: {{ include "vm-operator.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/managed-by: {{ .Release.Service | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{/*
Expand Down
2 changes: 1 addition & 1 deletion charts/victoria-metrics-single/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Next release

- TODO
- properly truncate value of `app.kubernetes.io/managed-by` and `app.kubernetes.io/instance` labels in case release name exceeds 63 characters.

## 0.9.18

Expand Down
4 changes: 2 additions & 2 deletions charts/victoria-metrics-single/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ Create unified labels for victoria-metrics components
*/}}
{{- define "victoria-metrics.common.matchLabels" -}}
app.kubernetes.io/name: {{ include "victoria-metrics.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/instance: {{ .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{- define "victoria-metrics.common.metaLabels" -}}
helm.sh/chart: {{ include "victoria-metrics.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/managed-by: {{ .Release.Service | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{- define "victoria-metrics.server.labels" -}}
Expand Down

0 comments on commit aaada4f

Please sign in to comment.