12

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
  • 1,973
  • 2
  • 23
  • 37
  • 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

2 Answers2

6

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.

Nick Rak
  • 2,197
  • 10
  • 16
  • 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
  • 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
3

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
  • 12,639
  • 5
  • 32
  • 44