Hi, in the affinity practice lab I am having the following error Set Node Affin . . .

Sam Engr:
Hi, in the affinity practice lab I am having the following error

Set Node Affinity to the deployment to place the pods on node01 only

Name: blue
Replicas: 3
Image: nginx
NodeAffinity: requiredDuringSchedulingIgnoredDuringExecution
Key: color
values: blue

kubectl apply -f deployment.yaml

error: error validating “deployment.yaml”: error validating data: ValidationError(Deployment.spec.template): unknown field “affinity” in io.k8s.api.core.v1.PodTemplateSpec; if you choose to ignore these errors, turn validation off with --validate=false

Any thoughts?

unnivkn:
looks like you are missing the correct syntax… use like this . Also refer the documentation:

spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: disktype
            operator: In
            values:
            - ssd         

https://kubernetes.io/docs/tasks/configure-pod-container/assign-pods-nodes-using-node-affinity/