StatefulSet name accepts DNS subdomain standard, but Pods controlled by StatefulSet accepts DNS label standard #104195
Description
What happened:
Names allowed for Pods, Deployment, StatefulSet follow DNS subdomain name defined in RFC 1123.
Pods controlled by Deployment follows DNS subdomain name standard as well.
However, Pod controlled by StatefuSet is following DNS label standard.
StatefulSet allows names with "." , but Pods created by the StatefulSet fails with error --
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedCreate 4m23s (x17 over 9m51s) statefulset-controller create Pod sts1-vol.1-0 in StatefulSet sts1-vol.1 failed error: Pod "sts1-vol.1-0" is invalid: spec.hostname: Invalid value: "sts1-vol.1-0": a DNS-1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')
What you expected to happen:
Since "." character is allowed in the StatefulSet name, Pod replicas controlled by the StatefulSet should allow "." character as well.
If "." is not possible for Pods controlled by StatefulSet, then StatefulSet creation should fail for "." character in the name.
How to reproduce it (as minimally and precisely as possible):
$ kubectl create -f 1sts-1vol-dot.yaml -n test
persistentvolumeclaim/pvc-3 created
statefulset.apps/sts1-vol.1 created
YAML FILE -->
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-3
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
storageClassName: rook-cephfs
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: sts1-vol.1
spec:
replicas: 2
selector:
matchLabels:
app: ubuntu-ss
serviceName: ubuntu-svc
template:
metadata:
labels:
app: ubuntu-ss
spec:
containers:
- name: ubuntu
image: ubuntu
ports:
- containerPort: 80
name: web
volumeMounts:
- name: data
mountPath: /mnt/data
command: ["/bin/sh", "-c"]
args:
- while true; do
sleep 3600;
done
volumes:
- name: data
persistentVolumeClaim:
claimName: pvc-3
readOnly: false
Anything else we need to know?:
Pods controlled by ReplicaSet gets successfully created as it follows DNS subdomain standard.
Environment:
- Kubernetes version (use
kubectl version
):
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.2", GitCommit:"092fbfbf53427de67cac1e9fa54aaa09a28371d7", GitTreeState:"clean", BuildDate:"2021-06-16T12:59:11Z", GoVersion:"go1.16.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.11", GitCommit:"c6a2f08fc4378c5381dd948d9ad9d1080e3e6b33", GitTreeState:"clean", BuildDate:"2021-05-12T12:19:22Z", GoVersion:"go1.15.12", Compiler:"gc", Platform:"linux/amd64"}
- Cloud provider or hardware configuration:
Bare Metal
- OS (e.g:
cat /etc/os-release
):
NAME="CentOS Linux"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
- Kernel (e.g.
uname -a
):
Linux 'redacted hostname' 4.18.0-240.el8.x86_64 #1 SMP Fri Sep 25 19:48:47 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
- Install tools:
kubeadm version: &version.Info{Major:"1", Minor:"19+", GitVersion:"v1.19.8-eks-1-19-4", GitCommit:"832dfd094a0c1a0dfe4303775e5e6047473bef6a", GitTreeState:"clean", BuildDate:"2021-05-05T18:01:29Z", GoVersion:"go1.15.11", Compiler:"gc", Platform:"linux/amd64"}
- Network plugin and version (if this is a network-related bug):
Flannel
/sig api-machinery