-
Notifications
You must be signed in to change notification settings - Fork 10.2k
[bitnami/redis] Ensure that Redis resources are less than 63 chars #34803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
fb593f2
bd19204
cab28d1
39363e8
e80ff34
a7b29a1
48502e0
c9e6a1a
565f5d5
44358bd
829ba85
576afd9
7bed5db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,6 +5,45 @@ SPDX-License-Identifier: APACHE-2.0 | |||||||||||||||||||||||||
|
||||||||||||||||||||||||||
{{/* vim: set filetype=mustache: */}} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
{{/* | ||||||||||||||||||||||||||
Return the proper Redis master fullname. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
The 0000000000 is to take into account the 10-charaters hash that the StatefulSet | ||||||||||||||||||||||||||
appends to the name of the StatefulSet in the pod's controller-revision-hash label. | ||||||||||||||||||||||||||
A label value can only have 63 characters. | ||||||||||||||||||||||||||
*/}} | ||||||||||||||||||||||||||
{{- define "redis.master.fullname" -}} | ||||||||||||||||||||||||||
{{- printf "%s-%s" ((include "common.names.fullname" .) | trunc ((sub 63 ("-master-0000000000" | len)) | int) | trimSuffix "-") "master" -}} | ||||||||||||||||||||||||||
{{- end -}} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
{{/* | ||||||||||||||||||||||||||
Return the proper Redis replicas fullname | ||||||||||||||||||||||||||
*/}} | ||||||||||||||||||||||||||
{{- define "redis.replicas.fullname" -}} | ||||||||||||||||||||||||||
{{- printf "%s-%s" ((include "common.names.fullname" .) | trunc ((sub 63 ("-replicas-0000000000" | len)) | int) | trimSuffix "-") "replicas" -}} | ||||||||||||||||||||||||||
{{- end -}} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
{{/* | ||||||||||||||||||||||||||
Return the proper Redis sentinel fullname | ||||||||||||||||||||||||||
*/}} | ||||||||||||||||||||||||||
{{- define "redis.sentinel.fullname" -}} | ||||||||||||||||||||||||||
{{- printf "%s-%s" ((include "common.names.fullname" .) | trunc ((sub 63 ("-node-0000000000" | len)) | int) | trimSuffix "-") "node" -}} | ||||||||||||||||||||||||||
{{- end -}} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
{{/* | ||||||||||||||||||||||||||
Return the proper Redis headless fullname | ||||||||||||||||||||||||||
*/}} | ||||||||||||||||||||||||||
{{- define "redis.headless.fullname" -}} | ||||||||||||||||||||||||||
{{- printf "%s-%s" ((include "common.names.fullname" .) | trunc ((sub 63 ("-headless" | len)) | int) | trimSuffix "-") "headless" -}} | ||||||||||||||||||||||||||
{{- end -}} | ||||||||||||||||||||||||||
Comment on lines
+33
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the idea and see it as a good improvement. However, all our solutions use a simpler method
Suggested change
I'd follow that approach here (and the other methods) too. However, the common.names.fullname function can be improve to truncate the strings the way you are suggesting. https://github.com/bitnami/charts/blob/main/bitnami/common/templates/_names.tpl#L26 You can update that function to accept another string to perform the "sub" method. That way, that function can be added to other charts as well and the whole community will benefit from that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although I think it's a good idea, it would also change the signature of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I simply suggested to improve the function to accept a new parameter to perform the "sub" method. The function won't do anything unless you set that new parameter. You can later update the function in the Redis' chart and increase the version to a new major so we avoid issues when updating between minor versions. Sounds good? |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
{{/* | ||||||||||||||||||||||||||
Return the proper Redis metrics fullname | ||||||||||||||||||||||||||
*/}} | ||||||||||||||||||||||||||
{{- define "redis.metrics.fullname" -}} | ||||||||||||||||||||||||||
{{- printf "%s-%s" ((include "common.names.fullname" .) | trunc ((sub 63 ("-metrics" | len)) | int) | trimSuffix "-") "metrics" -}} | ||||||||||||||||||||||||||
{{- end -}} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
{{/* | ||||||||||||||||||||||||||
Return the proper Redis image name | ||||||||||||||||||||||||||
*/}} | ||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the
Service
also uses this helper, it could result in it being recreated for some users. Truncating the equivalent of0000000000
is only strictly needed for theStatefulset
in reality.