使用 NodeSelector 验证 Pod 模板时出错


    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

任何解决此问题的指针都会很棒。

上述错误适用于:

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: {}

最新更新