apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: nginx4
name: nginx4
spec:
containers:
- image: nginx
name: nginx4
nodeSelector:
app: "v1-tesla"
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Never
status: {}
当我运行上述模板kubectl create -f pod.yaml时,出现以下错误:
error: error validating "podOnANode.yaml": error validating data:
ValidationError(Pod.spec.nodeSelector.resources): invalid type for
io.k8s.api.core.v1.PodSpec.nodeSelector: got "map", expected
"string"; if you choose to ignore these errors, turn validation off
with --validate=false
任何解决此问题的指针都很好。
答案 0 :(得分:2)
以上错误是由于:
nodeSelector:
app: "v1-tesla"
resources: {}
在这里,resources: {}
代表map
,但它应该是string
。因此,请删除resources: {}
或将其值更改为string
。
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: nginx4
name: nginx4
spec:
containers:
- image: nginx
name: nginx4
nodeSelector:
app: "v1-tesla"
resources: "whatever"
dnsPolicy: ClusterFirst
restartPolicy: Never
status: {}