Repository navigation
cmd/k8s-operator: truncate long StatefulSet name prefixes - #10343
Merged
Merged
Conversation
irbekrm
force-pushed
the
irbekrm/longnames
branch
2 times, most recently
from
November 21, 2023 08:47
f3c412d to
2dd7074
Compare
knyar
approved these changes
Nov 21, 2023
Kubernetes can generate StatefulSet names that are too long and result in invalid Pod revision hash label values. Calculate whether a StatefulSet name generated for a Service or Ingress will be too long and if so, truncate it. Updates #10284 Signed-off-by: Irbe Krumina <[email protected]>
irbekrm
force-pushed
the
irbekrm/longnames
branch
from
November 21, 2023 09:46
2dd7074 to
45869a2
Compare
This was referenced Jan 10, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes a bug where exposing a
Servicewith a name longer than 43 chars fails at StatefulSet creation, due to a Kubernetes bug kubernetes/kubernetes#64023, see #10284 .We use Kubernetes name generation to create a name for Services in front of proxy StatefulSets and use that to name the StatefulSet. (Name generation currently ensures that the generated name is 63 chars max). StatefulSet Pods get a
controller-revision-hashlabel applied with a value of the StatefulSet name + revision hash of (10 chars for the hash + a hyphen). As the max allowed label value lenghth is 63 chars this does not work in cases where the generated StatefulSetNames are longer than 52 chars. The generated name consists of a base that we provide in formts-<name-of-the-exposed-service>-and a suffix of, currently 5 random chars.This PR fixes the issue by pre-calculating the StatefulSet name that will be used and, if it's longer than 52 chars, cutting the excess characters off the base.
This is not a breaking change as the cut only applies to Service names that wouldn't have successfully worked and does not introduce a change in behaviour as we are already using name generation which cuts long names. (We should ensure that in docs we encourage the use of labels to identify child resources).
To verify the fix:
tailscalenamespace.This fix will also work in case of
Ingressresources with very long names./cc @Shaked
Updates #10284