kubernetes: Incorrect max length check on metadata.name
What happened: As far as I know metadata.name can be one or more DNS labels separated by dots (.) with the following constraints on max length: 1) each label has a max length of 63 characters 2) the maximum number of characters for the name (aka DNS subdomain) is 253 characters.
I did a couple of tests using v1.15.0 and max length for label is not respected
What you expected to happen: I was able to successfully create a pod with a name with a single label with 64 and 72 characters. See pod-name-15.pdf for example of manifest YAML file. kubectl responded as follows: pod/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx64 created
The expected outcome is an error.
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Environment:
- Kubernetes version (use
kubectl version): v1.15.0 - Cloud provider or hardware configuration:
- OS (e.g:
cat /etc/os-release): - Kernel (e.g.
uname -a): - Install tools:
- Network plugin and version (if this is a network-related bug):
- Others:
@kubernetes/sig-cli /sig cli
@kubernetes/sig-api-machinery /sig api-machinery
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (9 by maintainers)
Commits related to this issue
- fix 422 invalid value error caused by long k8s pod name K8S pod names follows DNS_SUBDOMAIN naming convention, which can be broken down into one or more DNS_LABEL separated by `.`. While the max len... — committed to houqp/airflow by deleted user 4 years ago
- Fix invalid value error caused by long k8s pod name (#13299) K8S pod names follows DNS_SUBDOMAIN naming convention, which can be broken down into one or more DNS_LABEL separated by `.`. While the... — committed to apache/airflow by deleted user 3 years ago
- Fix invalid value error caused by long k8s pod name (#13299) K8S pod names follows DNS_SUBDOMAIN naming convention, which can be broken down into one or more DNS_LABEL separated by `.`. While the ma... — committed to apache/airflow by deleted user 3 years ago
- Fix invalid value error caused by long k8s pod name (#13299) K8S pod names follows DNS_SUBDOMAIN naming convention, which can be broken down into one or more DNS_LABEL separated by `.`. While the ma... — committed to apache/airflow by deleted user 3 years ago
Let me try to clarify one last time. Yes I understand that metadata.name is a DNS_Sudomain and it has a max length of 253 characters. This is constraint #1. No problem here. So far so good.
However, the DNS _Subdomain is also made of one or more DNS Labels and each DNS Label must have a max length of 63 characters. This is constraint #2. This is the part that k8s is not following.
As far as I know both constraints must be followed.
Do you have a different interpretation? If so, then we should consider updating identifiers.md.
https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names:
DNS-1123 subdomain allows up to 253 char.
63 char is the limit for DNS labels, e.g. for metadata.labels https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set
I think it’s because “xxxxxxxxxx. xxxxxxxxxx. xxxxxxxxxx. xxxxxxxxxx. xxxxxxxxxx. xxxxxxxxxx. xxxxxxxx75” contains space, which isn’t allowed.