Welcome to the Linux Foundation Forum!

Yaml Understanding Help

Hi,

I've done some googling and I'm still looking for a good example of a fully flushed out YAML file that has comments.
I'm having a tough time understanding where each key value pair go as well was the formatting.
I understand that most use two spaces but I don't really understand why some files have different key values.

For example,

I'm looking at the batch job.yaml file in the lab. I don't have a good grasp why there is another spec in the file as well has how the indentation is working and why containers is at the bottom. I understand it is based on what kind the application is but I still don't seem to understand what is needed for what kind of application I'd deploy in kubernetes.

I feel that this is something very basic that I need a good link or something to I can understand how to read and create the YAML files better.

I see
spec:
completions: 5
template:
spec:
containers:

Thanks.

Comments

  • btanoue
    btanoue Posts: 59

    Ignore the formatting. I don't see a code block button.

  • fcioanca
    fcioanca Posts: 2,590
    edited May 2019

    @btanoue You can use the code formatting option (see the screenshot attached)!

  • btanoue
    btanoue Posts: 59
    edited May 2019

    Thank You! I was looking for a button and never checked the Paragraph button. Most sites have a dedicated code button.

  • btanoue
    btanoue Posts: 59
    edited May 2019

    apiVersion: batch/v1
    kind: Job
    metadata:
    name: sleepy
    spec:
    completions: 5
    parallelism: 2
    activeDeadlineSeconds: 15
    template:
    spec:
    containers:
    - name: resting
    image: busybox
    command: ["/bin/sleep"]
    args: ["5"]
    restartPolicy: Never

  • btanoue
    btanoue Posts: 59

    Hi,

    Thanks, I'll take a look at it. I'm just worried I'll spend way too much time on the exam for not indenting correctly. I don't think there is a syntax fixer we can use during the test.

  • btanoue
    btanoue Posts: 59

    Thank You, I'll start to look at that.

Categories

Upcoming Training