apecloud / kubeblocks

KubeBlocks is an open-source control plane software that runs and manages databases, message queues and other stateful applications on K8s.
https://kubeblocks.io
GNU Affero General Public License v3.0
2.13k stars 176 forks source link

[BUG] service name error, if we create cluster with name starting with numerics. #8017

Closed shanshanying closed 2 days ago

shanshanying commented 2 months ago
Service "2-pea-84d556f4d4-mysql" is invalid: metadata.name: Invalid value: "2-pea-84d556f4d4-mysql": a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name',  or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?')

If we create a new cluster named 2-pea-84d556f4d4, the generated svc name is something like 2-pea-84d556f4d4-<componentName>, fails to meet the validation pattern [a-z]([-a-z0-9]*[a-z0-9])?

nayutah commented 2 months ago

dup with #6312

shanshanying commented 2 months ago

The root cause is : service name in K8s cannot starts with numers. https://github.com/kubernetes/kubernetes/issues/96147

And according the source code of K8s, we found service names must obey rule: DNS1035Lable.

// ValidateServiceName can be used to check whether the given service name is valid.
// Prefix indicates this name will be used as part of generation, in which case
// trailing dashes are allowed.
var ValidateServiceName = apimachineryvalidation.NameIsDNS1035Label

While Cluster names only obey rule: DNS1123Lbel.

The key difference between 1135 and 1123 is, the latter can start with an alphanumeric character, while the former must start with start with an alphabetic character

shanshanying commented 2 months ago

proposed solution: to normalize service name to meet the constraint.

github-actions[bot] commented 1 month ago

This issue has been marked as stale because it has been open for 30 days with no activity