Thanks. Yes, I read the docs (as well as most template-related forum posts) before posting my message here. My main question was how to supply the data used by the template, and how to do so in a dynamic (eventually automated) way.
So I did eventually work out one approach using Go templating dict types, as shown below.
The following template...
{{ $proxies := list
(dict "Domain" "hostdomain1.com"
"Server" "backendserver1.com")
(dict "Domain" "hostdomain2.com"
"Server" "backendserver2.com")
}}
http:
services:
{{range $proxies}}
{{.Domain | replace "." "_"}}_svc:
loadBalancer:
servers:
- url: https://{{.Server}}
{{end}}
...will result in the following output...
http:
services:
hostdomain1_com_svc:
loadBalancer:
servers:
- url: https://backendserver1.com
hostdomain2_com_svc:
loadBalancer:
servers:
- url: https://backendserver2.com
Being entirely unfamiliar with Go, it actually took much more time than anticipated to get the syntax right. The following template playground tool was absolutely invaluable in working out the kinks...
There's nothing like instantaneous real-time feedback when you're experimenting - especially in unfamiliar terrain. Kudos to the devs who put that together! ![]()
Anyway, for now, I can simply update the YAML template with relevant data in order to add new services. Yippee!
![]()