kubernetes: Confusing error message with apps/v1beta2.statefulset
apps/v1beta2.StatefulSet is going to have a change that changes the defaulting behavior. The user facing aspect of this change is that .Spec.selector will need to be provided when trying to create an object.
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
name: test
spec:
serviceName: "test"
replicas: 2
template:
metadata:
labels:
name: test
spec:
containers:
- name: alpine
image: alpine
command:
- /bin/sleep
- "1000000"
Trying to create this object throws the following errors:
The StatefulSet "test" is invalid:
* spec.selector: Required value
* spec.template.metadata.labels: Invalid value: map[string]string{"name":"test"}: `selector` does not match template `labels`
We could have a better error message that indicates:
(1) The spec.selector must match at least one label in spec.template.metadata.labels
(2) Optionally, also saying that the spec.selector is set-based (as opposed to being equality based)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (9 by maintainers)
I stumbled on this too and found the error message pretty confusing. Without this issue, it would have taken me a lot longer to find the answer.
If it helps someone else, here’s exactly what I had to do.
From
extensions/v1beta1to
apps/v1beta2The line that says
spec.selector: Required valuedoes seem to help in this case. It points at the problem that you now must set that field explicitly.@foxish In the case you described this morning,
spec.selectorwas filled in but with the wrong format. Did it not complain aboutspec.selectorbeing missing in that case?Maybe it would help if the second error about labels not matching also printed the value of
spec.selectorso you could see that it is using a value you didn’t expect?