Skip to content

Instantly share code, notes, and snippets.

@denzhel
Created December 5, 2021 19:52
Show Gist options
  • Select an option

  • Save denzhel/829d80a68e8c9a3274c155a8d0336728 to your computer and use it in GitHub Desktop.

Select an option

Save denzhel/829d80a68e8c9a3274c155a8d0336728 to your computer and use it in GitHub Desktop.
helm template get first element and value

I had this YAML list and I needed to extract the name of the first server without the port:

global:
  datastores:
     db:
       hosts:
       - name: prod-mongo-11
         port: 27017
       - name: prod-mongo-12
         port: 27017
       - name: prod-mongo-13
         port: 27017

Solution:

'{{ index .Values.global.datastores.db.hosts 0 "name"  }}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment