kubernetes: Deployment names can be too long, such that ReplicaSet creation fails

This Deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: use-a-very-long-name-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-12
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: iamyouare
  template:
    metadata:
      labels:
        app: iamyouare
    spec:
      containers:
      - image: thockin/iamyouare
        name: iamyouare

…is accepted but always fails:

Events:
  Type     Reason                 Age                From                   Message
  ----     ------                 ----               ----                   -------
  Warning  ReplicaSetCreateError  1s (x13 over 22s)  deployment-controller  Failed to create new replica set "use-a-very-long-name-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-12-6bb58d578b": ReplicaSet.apps "use-a-very-long-name-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-12-6bb58d578b" is invalid: metadata.name: Invalid value: "use-a-very-long-name-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-12-6bb58d578b": must be no more than 253 characters

Deployment controller needs to truncate it’s own name to make room for the ReplicaSet suffix and eventually the pod suffix.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 1
  • Comments: 32 (32 by maintainers)

Most upvoted comments

I think we would simply API-fail > 242.

On Mon, May 1, 2023 at 2:43 PM Antonio Ojea @.***> wrote:

I’m curious, truncating does not look great does it? so I have my deployment in my manifest with name 250 chars “superlong…name12345678” and when I try to check I can only use it with the truncated name of 242 chars, no? kubectl get deployment “superlong…name”

— Reply to this email directly, view it on GitHub https://github.com/kubernetes/kubernetes/issues/116447#issuecomment-1530347378, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKWAVGZEQICIWQNX4PT4ZTXEAU7FANCNFSM6AAAAAAVVYJJBE . You are receiving this because you were mentioned.Message ID: @.***>