Home > Software engineering >  error validating data: ValidationError(Deployment.spec.template.metadata): unknown field
error validating data: ValidationError(Deployment.spec.template.metadata): unknown field

Time:10-19

kube@Big:/mnt/c/Users/Big_Picture/Desktop/ClinZilla$ kubectl apply -f yaml-validator.yaml error: error validating "yaml-validator.yaml": error validating data: ValidationError(Deployment.spec.template.metadata): unknown field "nodeSelector" in io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta; if you choose to ignore these errors, turn validation off with --validate=false Checker yaml syntax

Reuslt running command

CodePudding user response:

NodeSelector is not a field of the "metadata" section of your pod template. it needs to be under "spec.template.spec".

see this example:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: rss-site
  labels:
    app: web
spec:
  replicas: 2
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      nodeSelector: <--- WRONG
        disktype: ssd <-- ALSO WRONG BECAUSE IT IS PART OF NODESELECTOR
      labels:
        app: web
    spec:
      nodeSelector: <--- CORRECT
        disktype: ssd 
      containers:
        - name: front-end
          image: nginx
          ports:
            - containerPort: 80
        - name: rss-reader
          image: nickchase/rss-php-nginx:v1
          ports:
            - containerPort: 88
  • Related