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?

Comments

  • vvandana
    vvandana 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.

  • chrispokorni
    chrispokorni Posts: 2,349

    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

  • vvandana
    vvandana Posts: 9
    edited June 2021

    Here is a picture of the last part of the yaml

  • serewicz
    serewicz 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,

  • chrispokorni
    chrispokorni Posts: 2,349

    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:

        spec:
          containers:
          - image: vish/stress
            imagePullPolicy: Always
            name: hog
            resources:
              limits:
                memory: "4Gi"
              requests:
                memory: "2500Mi"
            terminationMessagePath: /dev/termination-log
            terminationMessagePolicy: File
    

    Regards,
    -Chris

  • vvandana
    vvandana 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.

Categories

Upcoming Training