@Gakio's solution did not work in werf yaml template (got the error "range can't iterate over ..."). The following improvement helped:
apiVersion: v1
kind: Service
metadata:
labels:
app: some-app
name: some-service
namespace: some-namespace
spec:
ports:
{{ range untilStep 40000 42000 1 }} # start stop step
- port: {{ . }}
targetPort: {{ . }}
name: exposed-port-{{ . }}
{{ end }}
selector:
app: some-app
sessionAffinity: None
type: ClusterIP