The Request is Invalid message - when running kubectl apply -f elasticsearch.yaml

Course: Introduction to ECK
Version: latest
Question:

In Lab, Lesson 3
Running the command to apply latest changes to elasticsearch .yaml
I've copied and pasted the additional code from the example

This is the file:

The output: The request is Invalid: patch: invalid value ....
Then at the end: Strict decoding error: unknown field "volumeClaimTemplates"

I can't get the formatting right. I am copying and pasting the code block but then have to manually reformat each line in vim . I can't get the hang of it.
Everytime I run the kubectl apply command, there is a decoding error on different fields I fix one field but then there's another field error.
Help!

Note: even when I copy the example code block in the lab and do a set: paste in vim, I still see a similar error.

A few things jump out at first.

First, the volumeClaimTemplates block is indented at the highest level and should be inline with values like count, config, and so on under the nodeSets block.

Overall though, it looks like at least one example had some bad indentation so the entire lab is going be reviewed and corrected.

I have taken the example from the documentation (Lesson 3, Step 6) and wrapped it in a cat EOF wrapper that should let you copy this block and deploy it from the CLI only. See if this works, I tested it myself earlier...you can also paste the entire thing into a yaml file and trim the top and bottom lines if you think thats easier to iterate on.

Good luck and don't sleep on using kubectl explain es.spec.etc.etc to see fields and hierarchy explained. Great for checking which level things go and what they are.

cat <<EOF | kubectl apply -f -
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: main
spec:
  version: 8.17.0
  nodeSets:
  - name: new
    count: 1
    config:
      node.store.allow_mmap: false
      node.roles: ["master", "data", "ingest"]
      xpack.security.audit.enabled: false
    volumeClaimTemplates:
    - metadata:
        name: elasticsearch-data
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 10Gi
        storageClassName: standard
EOF
1 Like

That helped enormously, I'm new to this so appreciate the tips. Yeah, I thought it was weird I was copying the example code block in the training and still getting it wrong. Thanks again.

1 Like