Welcome to the Linux Foundation Forum!

Lab 4.2 Step 5 giving error (v_2021-02-05 of the lab)

I followed steps 1 to 4 to create the deployment hog and edited the hog.yaml file to remove the lines after "status:" and other edits. Then I added the resource limts as below:
resources:
limits:
memory: "4Gi"
requests:
memory: "2500Mi"
When I go to step 5 and run
kubectl replace -f hog.yaml
I get the following error:
error: error validating "hog.yaml": error validating data: ValidationError(Deployment.spec.template.spec.containers[0].resources.limits.requests): invalid type for io.k8s.apimachinery.pkg.api.resource.Quantity: got "map", expected "string"; if you choose to ignore these errors, turn validation off with --validate=false

What am I doing wrong?

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Comments

  • Posts: 9

    Also, there may be a typo in the instructions. The example yaml file has name: hog where as the name should be stress.

  • Posts: 2,453

    Hi @vvandana,

    The error points at an issue with your yaml. However, without using the code tags to preserve the formatting of the yaml snippet provided above, it is impossible to tell what causes the validation error.

    Regards,
    -Chris

  • Posts: 9
    edited June 2021

    Here is a picture of the last part of the yaml

  • Posts: 1,000

    Hello,

    I note that you are allowing vim to indent a great deal. With such deep indentation it can be difficult to find an extra space. I would encourage you to edit the indents to keep with a consistent two characters depth. You can also use http://json2yaml.com/ and paste your YAML to the right hand side. Then if you don't get an error you can see the JSON that will be used, and ensure the variables are being assigned to the correct section"

    Regards,

  • Posts: 2,453

    Hi @vvandana,

    Just as suspected, the indentation of the newly inserted section is incorrect. Every indentation step is 2 blank spaces (press the SPACE bar 2 times), not TABs.

    The correct indentation should look like the yaml block from lab 4.2 step 4, or similar to the snippet found below:

    1. spec:
    2. containers:
    3. - image: vish/stress
    4. imagePullPolicy: Always
    5. name: hog
    6. resources:
    7. limits:
    8. memory: "4Gi"
    9. requests:
    10. memory: "2500Mi"
    11. terminationMessagePath: /dev/termination-log
    12. terminationMessagePolicy: File

    Regards,
    -Chris

  • Posts: 9
    edited June 2021

    Thanks so much to both of you. Proper indentation fixed the issue. I allowed vim to automatically indent as you noted. Will pay attention from now on.

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training