From 3b46c0f87be0bd6406b19a27e4d18dcaded345b4 Mon Sep 17 00:00:00 2001 From: alix-graylog Date: Mon, 20 Jul 2026 11:13:14 -0400 Subject: [PATCH] fix: enforcing safe release name lenghts --- charts/graylog/templates/_helpers.tpl | 32 +++++++++---------- charts/graylog/templates/auth/mongo-sa.yaml | 4 +-- charts/graylog/templates/auth/sa.yaml | 4 +-- .../tests/test-credentials-secret.yaml | 2 +- .../tests/test-datanode-registration.yaml | 6 ++-- .../tests/test-graylog-api-health.yaml | 2 +- .../tests/test-graylog-cluster-status.yaml | 6 ++-- .../tests/test-mongodb-connectivity.yaml | 2 +- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/charts/graylog/templates/_helpers.tpl b/charts/graylog/templates/_helpers.tpl index e64b5f9..81467e4 100644 --- a/charts/graylog/templates/_helpers.tpl +++ b/charts/graylog/templates/_helpers.tpl @@ -57,7 +57,7 @@ app.kubernetes.io/instance: {{ .Release.Name }} Init script ConfigMap name */}} {{- define "graylog.cm.init.name" }} -{{- include "graylog.fullname" . | printf "%s-init-cm" }} +{{- include "graylog.fullname" . | printf "%s-init-cm" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* @@ -66,7 +66,7 @@ Service account name {{- define "graylog.serviceAccountName" }} {{- $defaultName := "default" }} {{- if .Values.serviceAccount.create }} -{{- $defaultName = include "graylog.fullname" . | printf "%s-sa" }} +{{- $defaultName = include "graylog.fullname" . | printf "%s-sa" | trunc 63 | trimSuffix "-" }} {{- end }} {{- .Values.serviceAccount.nameOverride | default $defaultName }} {{- end }} @@ -77,7 +77,7 @@ MongoDB service account name {{- define "graylog.mongodb.serviceAccountName" }} {{- $defaultName := "default" }} {{- if .Values.mongodb.serviceAccount.create }} -{{- $defaultName = include "graylog.fullname" . | printf "%s-mongo-sa" }} +{{- $defaultName = include "graylog.fullname" . | printf "%s-mongo-sa" | trunc 63 | trimSuffix "-" }} {{- end }} {{- .Values.mongodb.serviceAccount.nameOverride | default $defaultName }} {{- end }} @@ -195,7 +195,7 @@ Graylog secret pepper Graylog secret name */}} {{- define "graylog.secretsName" -}} -{{- $defaultName := include "graylog.fullname" . | printf "%s-secrets" }} +{{- $defaultName := include "graylog.fullname" . | printf "%s-secrets" | trunc 63 | trimSuffix "-" }} {{- if .Values.global.existingSecretName }} {{- $defaultName = .Values.global.existingSecretName }} {{- end }} @@ -206,21 +206,21 @@ Graylog secret name Graylog Datanode secret name */}} {{- define "graylog.datanode.secretsName" -}} -{{- include "graylog.secretsName" . | printf "%s-datanode" }} +{{- include "graylog.secretsName" . | printf "%s-datanode" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Graylog backup-secret name */}} {{- define "graylog.backupSecretName" -}} -{{- include "graylog.fullname" . | printf "%s-backup-secret" }} +{{- include "graylog.fullname" . | printf "%s-backup-secret" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* MongoDB Community Resource name */}} {{- define "graylog.mongodb.crName" -}} -{{- include "graylog.fullname" . | printf "%s-mongo-rs" }} +{{- include "graylog.fullname" . | printf "%s-mongo-rs" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* @@ -251,7 +251,7 @@ MongoDB Community Resource Secret name Graylog service name */}} {{- define "graylog.service.name" -}} -{{- $defaultName := include "graylog.fullname" . | printf "%s-svc" }} +{{- $defaultName := include "graylog.fullname" . | printf "%s-svc" | trunc 63 | trimSuffix "-" }} {{- .Values.graylog.service.nameOverride | default $defaultName }} {{- end }} @@ -266,14 +266,14 @@ Graylog service app port Graylog configmap name */}} {{- define "graylog.configmap.name" -}} -{{- include "graylog.fullname" . | printf "%s-config" }} +{{- include "graylog.fullname" . | printf "%s-config" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Graylog data PVC/volume name */}} {{- define "graylog.volume.name" -}} -{{- $defaultName := include "graylog.fullname" . | printf "%s-data" }} +{{- $defaultName := include "graylog.fullname" . | printf "%s-data" | trunc 63 | trimSuffix "-" }} {{- .Values.graylog.persistence.volumeNameOverride | default $defaultName }} {{- end }} @@ -281,14 +281,14 @@ Graylog data PVC/volume name Graylog Datanode pod prefix */}} {{- define "graylog.datanode.name" -}} -{{- include "graylog.fullname" . | printf "%s-datanode" }} +{{- include "graylog.fullname" . | printf "%s-datanode" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Graylog Datanode service name */}} {{- define "graylog.datanode.service.name" -}} -{{- include "graylog.fullname" . | printf "%s-datanode-svc" }} +{{- include "graylog.fullname" . | printf "%s-datanode-svc" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* @@ -306,7 +306,7 @@ Graylog Datanode hosts Datanode configmap name */}} {{- define "graylog.datanode.configmap.name" -}} -{{- include "graylog.fullname" . | printf "%s-datanode-config" }} +{{- include "graylog.fullname" . | printf "%s-datanode-config" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* @@ -314,7 +314,7 @@ Provider-defined Storage Class name */}} {{- define "graylog.provider.storageClassName" }} {{- $names := dict }} -{{- $_ := include "graylog.fullname" . | printf "%s-gp3" | set $names "aws" -}} +{{- $_ := include "graylog.fullname" . | printf "%s-gp3" | trunc 63 | trimSuffix "-" | set $names "aws" -}} {{/* add more entries here */}} {{- .Values.provider | default "" | get $names }} {{- end }} @@ -498,14 +498,14 @@ Graylog Java Options Ingress name */}} {{- define "graylog.ingress.web.name" }} -{{- include "graylog.fullname" . | printf "%s-web" }} +{{- include "graylog.fullname" . | printf "%s-web" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Cert-manager issuer name */}} {{- define "graylog.cert-manager.issuer.name" }} -{{- include "graylog.fullname" . | printf "%s-letsencrypt" }} +{{- include "graylog.fullname" . | printf "%s-letsencrypt" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* diff --git a/charts/graylog/templates/auth/mongo-sa.yaml b/charts/graylog/templates/auth/mongo-sa.yaml index 2b4c7a9..4a8407d 100644 --- a/charts/graylog/templates/auth/mongo-sa.yaml +++ b/charts/graylog/templates/auth/mongo-sa.yaml @@ -11,7 +11,7 @@ metadata: {{- end }} automountServiceAccountToken: {{ if eq (.Values.mongodb.serviceAccount.automount | toString) "false" }}false{{ else }}true{{ end }} {{- if empty .Values.mongodb.serviceAccount.role.rules | not | and .Values.mongodb.serviceAccount.role.create }} -{{- $roleName := include "graylog.mongodb.serviceAccountName" . | printf "%s-role" }} +{{- $roleName := include "graylog.mongodb.serviceAccountName" . | printf "%s-role" | trunc 63 | trimSuffix "-" }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role @@ -22,7 +22,7 @@ rules: {{ .Values.mongodb.serviceAccount.role.rules | toYaml | nindent 2 }} apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: - name: {{ include "graylog.mongodb.serviceAccountName" . | printf "%s-rb" }} + name: {{ include "graylog.mongodb.serviceAccountName" . | printf "%s-rb" | trunc 63 | trimSuffix "-" }} subjects: - kind: ServiceAccount name: {{ include "graylog.mongodb.serviceAccountName" . }} diff --git a/charts/graylog/templates/auth/sa.yaml b/charts/graylog/templates/auth/sa.yaml index 83322bf..7e95cde 100644 --- a/charts/graylog/templates/auth/sa.yaml +++ b/charts/graylog/templates/auth/sa.yaml @@ -11,7 +11,7 @@ metadata: {{- end }} automountServiceAccountToken: {{ dig "automount" true .Values.serviceAccount }} {{- if empty .Values.serviceAccount.role.rules | not | and .Values.serviceAccount.role.create }} -{{- $roleName := include "graylog.serviceAccountName" . | printf "%s-role" }} +{{- $roleName := include "graylog.serviceAccountName" . | printf "%s-role" | trunc 63 | trimSuffix "-" }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role @@ -22,7 +22,7 @@ rules: {{ .Values.serviceAccount.role.rules | toYaml | nindent 2 }} apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: - name: {{ include "graylog.serviceAccountName" . | printf "%s-rb" }} + name: {{ include "graylog.serviceAccountName" . | printf "%s-rb" | trunc 63 | trimSuffix "-" }} subjects: - kind: ServiceAccount name: {{ include "graylog.serviceAccountName" . }} diff --git a/charts/graylog/templates/tests/test-credentials-secret.yaml b/charts/graylog/templates/tests/test-credentials-secret.yaml index 157b33c..b7f4a36 100644 --- a/charts/graylog/templates/tests/test-credentials-secret.yaml +++ b/charts/graylog/templates/tests/test-credentials-secret.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Secret metadata: - name: {{ include "graylog.fullname" . }}-test-credentials + name: {{ include "graylog.fullname" . | printf "%s-test-credentials" | trunc 63 | trimSuffix "-" }} labels: {{- include "graylog.labels" . | nindent 4 }} annotations: diff --git a/charts/graylog/templates/tests/test-datanode-registration.yaml b/charts/graylog/templates/tests/test-datanode-registration.yaml index cd1fc1e..96dfcb5 100644 --- a/charts/graylog/templates/tests/test-datanode-registration.yaml +++ b/charts/graylog/templates/tests/test-datanode-registration.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Pod metadata: - name: {{ include "graylog.fullname" . }}-test-datanode-registration + name: {{ include "graylog.fullname" . | printf "%s-test-datanode-registration" | trunc 63 | trimSuffix "-" }} | trunc 63 | trimSuffix "-" }} labels: {{- include "graylog.labels" . | nindent 4 }} annotations: @@ -58,12 +58,12 @@ spec: - name: GRAYLOG_ROOT_USERNAME valueFrom: secretKeyRef: - name: {{ include "graylog.fullname" . }}-test-credentials + name: {{ include "graylog.fullname" . | printf "%s-test-credentials" | trunc 63 | trimSuffix "-" }} key: GRAYLOG_ROOT_USERNAME - name: GRAYLOG_ROOT_PASSWORD valueFrom: secretKeyRef: - name: {{ include "graylog.fullname" . }}-test-credentials + name: {{ include "graylog.fullname" . | printf "%s-test-credentials" | trunc 63 | trimSuffix "-" }} key: GRAYLOG_ROOT_PASSWORD restartPolicy: Never {{- end }} \ No newline at end of file diff --git a/charts/graylog/templates/tests/test-graylog-api-health.yaml b/charts/graylog/templates/tests/test-graylog-api-health.yaml index b2c079e..24e0221 100644 --- a/charts/graylog/templates/tests/test-graylog-api-health.yaml +++ b/charts/graylog/templates/tests/test-graylog-api-health.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Pod metadata: - name: {{ include "graylog.fullname" . }}-test-api-health + name: {{ include "graylog.fullname" . | printf "%s-test-api-health" | trunc 63 | trimSuffix "-" }} labels: {{- include "graylog.labels" . | nindent 4 }} annotations: diff --git a/charts/graylog/templates/tests/test-graylog-cluster-status.yaml b/charts/graylog/templates/tests/test-graylog-cluster-status.yaml index 9b1734d..1b42add 100644 --- a/charts/graylog/templates/tests/test-graylog-cluster-status.yaml +++ b/charts/graylog/templates/tests/test-graylog-cluster-status.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Pod metadata: - name: {{ include "graylog.fullname" . }}-test-cluster-status + name: {{ include "graylog.fullname" . | printf "%s-test-cluster-status" | trunc 63 | trimSuffix "-" }} | trunc 63 | trimSuffix "-" }} labels: {{- include "graylog.labels" . | nindent 4 }} annotations: @@ -45,12 +45,12 @@ spec: - name: GRAYLOG_ROOT_USERNAME valueFrom: secretKeyRef: - name: {{ include "graylog.fullname" . }}-test-credentials + name: {{ include "graylog.fullname" . | printf "%s-test-credentials" | trunc 63 | trimSuffix "-" }} key: GRAYLOG_ROOT_USERNAME - name: GRAYLOG_ROOT_PASSWORD valueFrom: secretKeyRef: - name: {{ include "graylog.fullname" . }}-test-credentials + name: {{ include "graylog.fullname" . | printf "%s-test-credentials" | trunc 63 | trimSuffix "-" }} key: GRAYLOG_ROOT_PASSWORD restartPolicy: Never {{- end }} \ No newline at end of file diff --git a/charts/graylog/templates/tests/test-mongodb-connectivity.yaml b/charts/graylog/templates/tests/test-mongodb-connectivity.yaml index 53e0e22..8d527e9 100644 --- a/charts/graylog/templates/tests/test-mongodb-connectivity.yaml +++ b/charts/graylog/templates/tests/test-mongodb-connectivity.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Pod metadata: - name: {{ include "graylog.fullname" . }}-test-mongodb + name: {{ include "graylog.fullname" . | printf "%s-test-mongodb" | trunc 63 | trimSuffix "-" }} | trunc 63 | trimSuffix "-" }} labels: {{- include "graylog.labels" . | nindent 4 }} annotations: