Reputation: 4738
My goal is to have multiple ports defined for a service of type LoadBalancer
and I do not want to copy paste the same thing over and over again.
I did come to a solution, but sure how I could define the range - I need all values from 50000 to 50999.
In my service, I define the range:
{{- range $service.ports }}
- name: tport
protocol: TCP
port: {{ . }}
{{- end }}
And in my values file:
ports:
- 50000
- 50001
- 50999
How could I define the ports or update the service template to do this?
Upvotes: 2
Views: 2043
Reputation: 1719
Put the min and max port as two different values on your values.yaml and use the range on your template like this:
{{- range untilStep (.Values.config.min_port|int) (.Values.config.max_port|int) 1 }}
- port: {{ . }}
targetPort: "tcp-{{ . }}"
protocol: TCP
name: "tcp-{{ . }}"
{{ -end }}
Upvotes: 7