Skip to content

StatefulSet with long name can not create pods #64023

@svenbs

Description

@svenbs

Is this a BUG REPORT or FEATURE REQUEST?:

/kind bug

What happened:

Creating a StatefulSet with a name containing 57 characters resulted could not start any pods as kubernetes added the label "controller-revision-hash" to the pod which apparently contains the StatefulSet name and a hash appended.
The label is not truncated to 63 characters, therefore the creation of the pod fails with the error message

statefulset-controller create Pod long-redacted-statefulset-name-xxxxxxxxxxxxxxxxxxxxxxxxx-0 in StatefulSet long-redacted-statefulset-name-xxxxxxxxxxxxxxxxxxxxxxxxx failed error: Pod "long-redacted-statefulset-name-xxxxxxxxxxxxxxxxxxxxxxxxx-0" is invalid: metadata.labels: Invalid value: "long-redacted-statefulset-name-xxxxxxxxxxxxxxxxxxxxxxxxx-58d5fbb889": must be no more than 63 characters

What you expected to happen:

The label should be truncated or StatefulSets should enforce shorter names.

How to reproduce it (as minimally and precisely as possible):

Create a StatefulSet with a name longer than 57 characters:

kind: StatefulSet
metadata:
  labels:
    app: sset
  name: long-redacted-statefulset-name-xxxxxxxxxxxxxxxxxxxxxxxxx
spec:
  serviceName: ""
  replicas: 1
  selector:
    matchLabels:
      app: sset
  template:
    metadata:
      labels:
        app: sset
    spec:
      containers:
        - image: alpine
          name: sset-container
          command: 
            - sleep 
            - "300"

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version): Server Version: "v1.10.2"
  • Cloud provider or hardware configuration: baremetal
  • OS (e.g. from /etc/os-release): CentOS-7.5.1804
  • Kernel (e.g. uname -a): 3.10.0-862.2.3.el7.x86_64
  • Install tools: kubeadm

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.sig/appsCategorizes an issue or PR as relevant to SIG Apps.

    Type

    No type

    Projects

    Status

    Needs Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions