Welcome to the new Linux Foundation Forum!

LAB 11.2 - issues with the taint.yaml file

sdalzielsdalziel Posts: 16
edited May 2018 in LFS258 Class Forum

Hi all,

I'm working through chapter 11 exercise 11.2 "Using Taints to Control Pod Deployment" and received the following error when I ran the command. 


$ kubectl apply -f ./taint.yaml
error: error validating "./taint.yaml": error validating data: ValidationError(Deployment.spec): unknown field "spec" in io.k8s.api.apps.v1beta1.DeploymentSpec; if you choose to ignore these errors, turn validation off with --validate=false

I included my "taint.yaml" file for help troubleshooting.


apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: taint-deployment
spec:
  replicas: 8
  template:
    metadata:
      labels:
        app: nginx
  spec:
    containers:
    - name: nginx
      image: nginx:1.7.9
      ports:
      - containerPort: 80

 

Any help would be appreciated.

Cheers,

Sean

 

Comments

  • serewiczserewicz Posts: 467

    Hello Sean,

    It looks like a whitespace issue to me. YAML is very sensitive to whitespace. My first thought is the second spec seems to be indented three spaces, instead of five. Try to line up the second spec: entry with the metadata: line above, on my file it looks like 5 indentes, but it really is relative to other indentation. 

    A second idea, ff you copied and pasted there may be a non-printable character in the file.  It's silly, but I always remember "If you can't figure it out take the cat to the vet" or the command cat -vet ./taint.yaml  Whitespace does not show a character, but tab and others will.  This is what my file looks like with all characters shown:


    apiVersion: apps/v1beta1$ kind: Deployment$ metadata:$ name: taint-deployment$ spec:$ replicas: 8$ template:$ metadata:$ labels:$ app: nginx$ spec:$ containers:$ - name: nginx$ image: nginx:1.7.9$ ports:$ - containerPort: 80$

    I'm not great at YAML, so I use a website to see the code and it helps me visualize where the block shoudl go. Try to paste your YAML into the right side of this site: https://www.json2yaml.com/ 

    Hopefully one of those things clears up the issue and the file works for you.

    Regards,

     

  • chrispokornichrispokorni Posts: 219
    edited May 2018

    Hi Sean, 

    When I receive an error like the one you posted, I know it is whitespace related. 

    What @serewicz suggested to align metadata and spec, I started using as a rule of thumb in yaml files. Of course it becomes tricky in nested files, but it still helps to get the indentation right on some lines, and use it as base for the rest of the necessary adjustments. 

    Regards, 

    -Chris

  • sdalzielsdalziel Posts: 16

    Thanks all for the replies. I deleted and wrote the taint.yaml file again. The load worked as expected.

    Cheers!

    Sean

Sign In or Register to comment.