23

As explained at https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ labels name and value have limit of 63 characters. Does anyone know what drives this limit? I am not looking for code condition but the real reason behind choosing this value.

Prateek Jain
  • 2,738
  • 4
  • 28
  • 42
  • 2
    Hi, They are just following the requirement of [RFC-1123](https://tools.ietf.org/html/rfc1123). In Simple words, it means that they can’t be more than 63 characters in length or include anything other than lower case letters, numbers, and hyphens. – Suresh Vishnoi May 18 '18 at 14:11
  • @SureshVishnoi then I would like to know why this number was chosen in RFC-1123 – Prateek Jain May 18 '18 at 15:09
  • Hi, You could read this paper which was linked to my previous comment. – Suresh Vishnoi May 18 '18 at 15:12
  • 1
    @SureshVishnoi, I just had a quick glance at it but couldn't find any reason mentioned. right now, reading entire paper is not possible for me. I would try to piggy back on community knowledge. – Prateek Jain May 18 '18 at 15:18
  • 2
    hi, https://stackoverflow.com/questions/32290167/what-is-the-maximum-length-of-a-dns-name#32294443 Here you can see explanation. – Suresh Vishnoi May 18 '18 at 15:26
  • 1
    And Here you can see the commit which changed kubernetes to have 63 characters https://github.com/kubernetes/kubernetes/pull/1830 – Suresh Vishnoi May 18 '18 at 15:27
  • Does anyone know a way to increase this limit ? – Milinda Kasun Oct 27 '21 at 06:05

2 Answers2

18

As Suresh Vishnoi wrote, it is a global restriction based on RFC-1123.

Here is a simple explanation of this restriction.

There is a commit in Kubernetes which provides the validation of labels' length.

Community
  • 1
  • 1
Nick Rak
  • 2,629
  • 13
  • 19
  • This still doesn't explain the reason. *Why* do labels need to comply with RFC-1123? – Andrés Mejía Jul 27 '20 at 19:07
  • 8
    Because Kubernets pod, service, and namespace names are used by kube-dns to create DNS records. https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/ – KarlKFI Dec 10 '20 at 22:52
  • 1
    @KarlKFI no questions to pod, service and namespace names: why have **labels** be so short? As per https://github.com/kubernetes/kubernetes/issues/1297 there was no _technical_ reason for that, kubernetes dev team just decided to have it. – zerkms Jun 16 '22 at 06:52
5

Here is design documentation of the kubernetes. The following link provides detail information.

rfc1035/rfc1123 label (DNS_LABEL): An alphanumeric (a-z, and 0-9) string, with a maximum length of 63 characters, with the '-' character allowed anywhere except the first or last character, suitable for use as a hostname or segment in a domain name.

identifiers-and-names-in-kubernetes

Suresh Vishnoi
  • 17,341
  • 8
  • 47
  • 55
  • That means, we cannot have '.' in the hostnames? But I am sure this is allowed: ip-192-168-144-98.ap-southeast-2.compute.internal – Muzammil Jul 14 '22 at 12:31
  • I think Dot is special character in the domain name, its allowed to use, check it out here https://datatracker.ietf.org/doc/html/rfc1035 – Suresh Vishnoi Jul 15 '22 at 05:55