Welcome to the Linux Foundation Forum!

Lab 5.1 Question 9!!!

curl --cert client.pem --key client-key.pem --cacert ca.pem server: https:///api/v1/namespaces/default/pods -XPOST -H'Content-Type: application/json' -d@curlpod.json

"kind": "Status",
"apiVersion": "v1",
"metadata": {

},
"status": "Failure",
"message": "the object provided is unrecognized (must be of type Pod): couldn't get version/kind; json parse error: invalid character '\"' after top-level value ({ \"kind\": \"Pod\", \"apiVersion ...)",
"reason": "BadRequest",
"code": 400

What would be the issue here.

Comments

  • chrispokorni
    chrispokorni Posts: 2,346

    Hi @ravi.ponnaiah,

    The error message seems to indicate your problem: an unexpected character in the curlpod.json file. This typically happens when the file is generated via copy/paste from the PDF.
    I suggest exploring the SOLUTIONS tarball and use the predefined files provided in there.

    Regards,
    -Chris

  • Ok I got it now thanks @chrispokorni

  • Charles_Britton
    Charles_Britton Posts: 1
    edited June 2020

    The documentation is pretty bad in this respect. This site does not like multiple spaces either . So here is my effort to generate the correct file :/ ...

    export SPACE=' '
    cat > curlpod.json << EOF
    {
    ${SPACE}"kind": "Pod",
    ${SPACE}"apiVersion": "v1",
    ${SPACE}"metadata":{
    ${SPACE}${SPACE}"name": "curlpod",
    ${SPACE}${SPACE}"namespace": "default",
    ${SPACE}${SPACE}${SPACE}"labels": {
    ${SPACE}${SPACE}${SPACE}${SPACE}"name": "examplepod"
    ${SPACE}${SPACE}${SPACE}}
    ${SPACE}${SPACE}},
    ${SPACE}${SPACE}"spec": {
    ${SPACE}${SPACE}${SPACE}"containers": [{
    ${SPACE}${SPACE}${SPACE}${SPACE}"name": "nginx",
    ${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}"image": "nginx",
    ${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}"ports": [{"containerPort": 80}]
    ${SPACE}${SPACE}${SPACE}${SPACE}}]
    ${SPACE}${SPACE}${SPACE}}
    ${SPACE}${SPACE}}
    EOF

  • chrispokorni
    chrispokorni Posts: 2,346

    Hi @Charles_Britton,

    Your effort is greatly appreciated, but there is a preformatted curlpod.json file available in the SOLUTIONS tarball. Also, I noticed a few extra SPACES that may cause issues when generating the actual json file.

    Regards,
    -Chris

  • Thanks a lot for your help @chrispokorni

Categories

Upcoming Training