Welcome to the Linux Foundation Forum!

Does the indentation mean anything for list elements in Kubernetes yaml?

does the indentation mean anything for list elements in Kubernetes yaml ? For example, in the pod yaml under Use-Case: As container environment variables "- name" under "containers:" is indented, however, "- secretRef" under "envFrom" is not indented...

Comments

  • FlamentBruno
    FlamentBruno Posts: 9
    edited July 2020

    Hello,
    Not related to Kubernetes.
    yaml works like this.

  • chrispokorni
    chrispokorni Posts: 1,613

    Hi @Ryan-Chase,

    In this specific example, - name is evaluated the same way, with or without indentation:

    With indentation (as presented in the example):

    spec:
      containers:
        - name: test-container
          image: k8s.gcr.io/busybox
    

    Without indentation:

    spec:
      containers:
      - name: test-container
        image: k8s.gcr.io/busybox
    

    Regards,
    -Chris

Categories

Upcoming Training