Skip to content

Commit da6b911

Browse files
committed
fix: enforcing safe release name lenghts
1 parent c88fff9 commit da6b911

8 files changed

Lines changed: 29 additions & 29 deletions

charts/graylog/templates/_helpers.tpl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ app.kubernetes.io/instance: {{ .Release.Name }}
5757
Init script ConfigMap name
5858
*/}}
5959
{{- define "graylog.cm.init.name" }}
60-
{{- include "graylog.fullname" . | printf "%s-init-cm" }}
60+
{{- include "graylog.fullname" . | printf "%s-init-cm" | trunc 63 | trimSuffix "-" }}
6161
{{- end }}
6262

6363
{{/*
@@ -66,7 +66,7 @@ Service account name
6666
{{- define "graylog.serviceAccountName" }}
6767
{{- $defaultName := "default" }}
6868
{{- if .Values.serviceAccount.create }}
69-
{{- $defaultName = include "graylog.fullname" . | printf "%s-sa" }}
69+
{{- $defaultName = include "graylog.fullname" . | printf "%s-sa" | trunc 63 | trimSuffix "-" }}
7070
{{- end }}
7171
{{- .Values.serviceAccount.nameOverride | default $defaultName }}
7272
{{- end }}
@@ -77,7 +77,7 @@ MongoDB service account name
7777
{{- define "graylog.mongodb.serviceAccountName" }}
7878
{{- $defaultName := "default" }}
7979
{{- if .Values.mongodb.serviceAccount.create }}
80-
{{- $defaultName = include "graylog.fullname" . | printf "%s-mongo-sa" }}
80+
{{- $defaultName = include "graylog.fullname" . | printf "%s-mongo-sa" | trunc 63 | trimSuffix "-" }}
8181
{{- end }}
8282
{{- .Values.mongodb.serviceAccount.nameOverride | default $defaultName }}
8383
{{- end }}
@@ -166,7 +166,7 @@ Graylog secret pepper
166166
Graylog secret name
167167
*/}}
168168
{{- define "graylog.secretsName" -}}
169-
{{- $defaultName := include "graylog.fullname" . | printf "%s-secrets" }}
169+
{{- $defaultName := include "graylog.fullname" . | printf "%s-secrets" | trunc 63 | trimSuffix "-" }}
170170
{{- if .Values.global.existingSecretName }}
171171
{{- $defaultName = .Values.global.existingSecretName }}
172172
{{- end }}
@@ -177,21 +177,21 @@ Graylog secret name
177177
Graylog Datanode secret name
178178
*/}}
179179
{{- define "graylog.datanode.secretsName" -}}
180-
{{- include "graylog.secretsName" . | printf "%s-datanode" }}
180+
{{- include "graylog.secretsName" . | printf "%s-datanode" | trunc 63 | trimSuffix "-" }}
181181
{{- end }}
182182

183183
{{/*
184184
Graylog backup-secret name
185185
*/}}
186186
{{- define "graylog.backupSecretName" -}}
187-
{{- include "graylog.fullname" . | printf "%s-backup-secret" }}
187+
{{- include "graylog.fullname" . | printf "%s-backup-secret" | trunc 63 | trimSuffix "-" }}
188188
{{- end }}
189189

190190
{{/*
191191
MongoDB Community Resource name
192192
*/}}
193193
{{- define "graylog.mongodb.crName" -}}
194-
{{- include "graylog.fullname" . | printf "%s-mongo-rs" }}
194+
{{- include "graylog.fullname" . | printf "%s-mongo-rs" | trunc 63 | trimSuffix "-" }}
195195
{{- end }}
196196

197197
{{/*
@@ -222,7 +222,7 @@ MongoDB Community Resource Secret name
222222
Graylog service name
223223
*/}}
224224
{{- define "graylog.service.name" -}}
225-
{{- $defaultName := include "graylog.fullname" . | printf "%s-svc" }}
225+
{{- $defaultName := include "graylog.fullname" . | printf "%s-svc" | trunc 63 | trimSuffix "-" }}
226226
{{- .Values.graylog.service.nameOverride | default $defaultName }}
227227
{{- end }}
228228

@@ -237,29 +237,29 @@ Graylog service app port
237237
Graylog configmap name
238238
*/}}
239239
{{- define "graylog.configmap.name" -}}
240-
{{- include "graylog.fullname" . | printf "%s-config" }}
240+
{{- include "graylog.fullname" . | printf "%s-config" | trunc 63 | trimSuffix "-" }}
241241
{{- end }}
242242

243243
{{/*
244244
Graylog data PVC/volume name
245245
*/}}
246246
{{- define "graylog.volume.name" -}}
247-
{{- $defaultName := include "graylog.fullname" . | printf "%s-data" }}
247+
{{- $defaultName := include "graylog.fullname" . | printf "%s-data" | trunc 63 | trimSuffix "-" }}
248248
{{- .Values.graylog.persistence.volumeNameOverride | default $defaultName }}
249249
{{- end }}
250250

251251
{{/*
252252
Graylog Datanode pod prefix
253253
*/}}
254254
{{- define "graylog.datanode.name" -}}
255-
{{- include "graylog.fullname" . | printf "%s-datanode" }}
255+
{{- include "graylog.fullname" . | printf "%s-datanode" | trunc 63 | trimSuffix "-" }}
256256
{{- end }}
257257

258258
{{/*
259259
Graylog Datanode service name
260260
*/}}
261261
{{- define "graylog.datanode.service.name" -}}
262-
{{- include "graylog.fullname" . | printf "%s-datanode-svc" }}
262+
{{- include "graylog.fullname" . | printf "%s-datanode-svc" | trunc 63 | trimSuffix "-" }}
263263
{{- end }}
264264

265265
{{/*
@@ -277,15 +277,15 @@ Graylog Datanode hosts
277277
Datanode configmap name
278278
*/}}
279279
{{- define "graylog.datanode.configmap.name" -}}
280-
{{- include "graylog.fullname" . | printf "%s-datanode-config" }}
280+
{{- include "graylog.fullname" . | printf "%s-datanode-config" | trunc 63 | trimSuffix "-" }}
281281
{{- end }}
282282

283283
{{/*
284284
Provider-defined Storage Class name
285285
*/}}
286286
{{- define "graylog.provider.storageClassName" }}
287287
{{- $names := dict }}
288-
{{- $_ := include "graylog.fullname" . | printf "%s-gp3" | set $names "aws" -}}
288+
{{- $_ := include "graylog.fullname" . | printf "%s-gp3" | trunc 63 | trimSuffix "-" | set $names "aws" -}}
289289
{{/* add more entries here */}}
290290
{{- .Values.provider | default "" | get $names }}
291291
{{- end }}
@@ -469,14 +469,14 @@ Graylog Java Options
469469
Ingress name
470470
*/}}
471471
{{- define "graylog.ingress.web.name" }}
472-
{{- include "graylog.fullname" . | printf "%s-web" }}
472+
{{- include "graylog.fullname" . | printf "%s-web" | trunc 63 | trimSuffix "-" }}
473473
{{- end }}
474474

475475
{{/*
476476
Cert-manager issuer name
477477
*/}}
478478
{{- define "graylog.cert-manager.issuer.name" }}
479-
{{- include "graylog.fullname" . | printf "%s-letsencrypt" }}
479+
{{- include "graylog.fullname" . | printf "%s-letsencrypt" | trunc 63 | trimSuffix "-" }}
480480
{{- end }}
481481

482482
{{/*

charts/graylog/templates/auth/mongo-sa.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ metadata:
1111
{{- end }}
1212
automountServiceAccountToken: {{ if eq (.Values.mongodb.serviceAccount.automount | toString) "false" }}false{{ else }}true{{ end }}
1313
{{- if empty .Values.mongodb.serviceAccount.role.rules | not | and .Values.mongodb.serviceAccount.role.create }}
14-
{{- $roleName := include "graylog.mongodb.serviceAccountName" . | printf "%s-role" }}
14+
{{- $roleName := include "graylog.mongodb.serviceAccountName" . | printf "%s-role" | trunc 63 | trimSuffix "-" }}
1515
---
1616
apiVersion: rbac.authorization.k8s.io/v1
1717
kind: Role
@@ -22,7 +22,7 @@ rules: {{ .Values.mongodb.serviceAccount.role.rules | toYaml | nindent 2 }}
2222
apiVersion: rbac.authorization.k8s.io/v1
2323
kind: RoleBinding
2424
metadata:
25-
name: {{ include "graylog.mongodb.serviceAccountName" . | printf "%s-rb" }}
25+
name: {{ include "graylog.mongodb.serviceAccountName" . | printf "%s-rb" | trunc 63 | trimSuffix "-" }}
2626
subjects:
2727
- kind: ServiceAccount
2828
name: {{ include "graylog.mongodb.serviceAccountName" . }}

charts/graylog/templates/auth/sa.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ metadata:
1111
{{- end }}
1212
automountServiceAccountToken: {{ dig "automount" true .Values.serviceAccount }}
1313
{{- if empty .Values.serviceAccount.role.rules | not | and .Values.serviceAccount.role.create }}
14-
{{- $roleName := include "graylog.serviceAccountName" . | printf "%s-role" }}
14+
{{- $roleName := include "graylog.serviceAccountName" . | printf "%s-role" | trunc 63 | trimSuffix "-" }}
1515
---
1616
apiVersion: rbac.authorization.k8s.io/v1
1717
kind: Role
@@ -22,7 +22,7 @@ rules: {{ .Values.serviceAccount.role.rules | toYaml | nindent 2 }}
2222
apiVersion: rbac.authorization.k8s.io/v1
2323
kind: RoleBinding
2424
metadata:
25-
name: {{ include "graylog.serviceAccountName" . | printf "%s-rb" }}
25+
name: {{ include "graylog.serviceAccountName" . | printf "%s-rb" | trunc 63 | trimSuffix "-" }}
2626
subjects:
2727
- kind: ServiceAccount
2828
name: {{ include "graylog.serviceAccountName" . }}

charts/graylog/templates/tests/test-credentials-secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: v1
33
kind: Secret
44
metadata:
5-
name: {{ include "graylog.fullname" . }}-test-credentials
5+
name: {{ include "graylog.fullname" . | printf "%s-test-credentials" | trunc 63 | trimSuffix "-" }}
66
labels:
77
{{- include "graylog.labels" . | nindent 4 }}
88
annotations:

charts/graylog/templates/tests/test-datanode-registration.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: v1
33
kind: Pod
44
metadata:
5-
name: {{ include "graylog.fullname" . }}-test-datanode-registration
5+
name: {{ include "graylog.fullname" . | printf "%s-test-datanode-registration" | trunc 63 | trimSuffix "-" }} | trunc 63 | trimSuffix "-" }}
66
labels:
77
{{- include "graylog.labels" . | nindent 4 }}
88
annotations:
@@ -58,12 +58,12 @@ spec:
5858
- name: GRAYLOG_ROOT_USERNAME
5959
valueFrom:
6060
secretKeyRef:
61-
name: {{ include "graylog.fullname" . }}-test-credentials
61+
name: {{ include "graylog.fullname" . | printf "%s-test-credentials" | trunc 63 | trimSuffix "-" }}
6262
key: GRAYLOG_ROOT_USERNAME
6363
- name: GRAYLOG_ROOT_PASSWORD
6464
valueFrom:
6565
secretKeyRef:
66-
name: {{ include "graylog.fullname" . }}-test-credentials
66+
name: {{ include "graylog.fullname" . | printf "%s-test-credentials" | trunc 63 | trimSuffix "-" }}
6767
key: GRAYLOG_ROOT_PASSWORD
6868
restartPolicy: Never
6969
{{- end }}

charts/graylog/templates/tests/test-graylog-api-health.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: v1
33
kind: Pod
44
metadata:
5-
name: {{ include "graylog.fullname" . }}-test-api-health
5+
name: {{ include "graylog.fullname" . | printf "%s-test-api-health" | trunc 63 | trimSuffix "-" }}
66
labels:
77
{{- include "graylog.labels" . | nindent 4 }}
88
annotations:

charts/graylog/templates/tests/test-graylog-cluster-status.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: v1
33
kind: Pod
44
metadata:
5-
name: {{ include "graylog.fullname" . }}-test-cluster-status
5+
name: {{ include "graylog.fullname" . | printf "%s-test-cluster-status" | trunc 63 | trimSuffix "-" }} | trunc 63 | trimSuffix "-" }}
66
labels:
77
{{- include "graylog.labels" . | nindent 4 }}
88
annotations:
@@ -45,12 +45,12 @@ spec:
4545
- name: GRAYLOG_ROOT_USERNAME
4646
valueFrom:
4747
secretKeyRef:
48-
name: {{ include "graylog.fullname" . }}-test-credentials
48+
name: {{ include "graylog.fullname" . | printf "%s-test-credentials" | trunc 63 | trimSuffix "-" }}
4949
key: GRAYLOG_ROOT_USERNAME
5050
- name: GRAYLOG_ROOT_PASSWORD
5151
valueFrom:
5252
secretKeyRef:
53-
name: {{ include "graylog.fullname" . }}-test-credentials
53+
name: {{ include "graylog.fullname" . | printf "%s-test-credentials" | trunc 63 | trimSuffix "-" }}
5454
key: GRAYLOG_ROOT_PASSWORD
5555
restartPolicy: Never
5656
{{- end }}

charts/graylog/templates/tests/test-mongodb-connectivity.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: v1
33
kind: Pod
44
metadata:
5-
name: {{ include "graylog.fullname" . }}-test-mongodb
5+
name: {{ include "graylog.fullname" . | printf "%s-test-mongodb" | trunc 63 | trimSuffix "-" }} | trunc 63 | trimSuffix "-" }}
66
labels:
77
{{- include "graylog.labels" . | nindent 4 }}
88
annotations:

0 commit comments

Comments
 (0)