_helpers.tpl 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. {{- define "vminsert.args" -}}
  2. {{- $Values := (.helm).Values | default .Values -}}
  3. {{- $app := $Values.vminsert -}}
  4. {{- $args := default dict -}}
  5. {{- $_ := set . "style" "plain" }}
  6. {{- $_ := set . "appKey" "vmstorage" }}
  7. {{- $args = mergeOverwrite $args (fromYaml (include "vm.license.flag" .)) -}}
  8. {{- $args = mergeOverwrite $args $app.extraArgs -}}
  9. {{- $storage := $Values.vmstorage }}
  10. {{- if and (not $app.suppressStorageFQDNsRender) $storage.enabled $storage.replicaCount }}
  11. {{- $storageNodes := default list }}
  12. {{- $fqdn := include "vm.fqdn" . }}
  13. {{- if $Values.autoDiscovery }}
  14. {{- if eq (include "vm.enterprise.disabled" . ) "true" }}
  15. {{- fail "SRV autodiscovery is only supported in enterprise. Either define license or set `autoDiscovery` to `false`" }}
  16. {{- end }}
  17. {{- $storageNode := printf "srv+_vminsert._tcp.%s" $fqdn }}
  18. {{- $storageNodes = append $storageNodes $storageNode }}
  19. {{- else }}
  20. {{- $port := "8400" }}
  21. {{- range $i := until ($storage.replicaCount | int) -}}
  22. {{- if not (has (float64 $i) $app.excludeStorageIDs) -}}
  23. {{- $_ := set $ "appIdx" $i }}
  24. {{- $storageNode := include "vm.fqdn" $ -}}
  25. {{- $storageNodes = append $storageNodes (printf "%s:%s" $storageNode $port) -}}
  26. {{- end -}}
  27. {{- end -}}
  28. {{- $_ := unset $ "appIdx" }}
  29. {{- end }}
  30. {{- $_ := set $args "storageNode" (concat ($args.storageNode | default list) $storageNodes) }}
  31. {{- end -}}
  32. {{- if empty $args.storageNode }}
  33. {{- fail "no storageNodes found. Either set vmstorage.enabled to true or add nodes to vminsert.extraArgs.storageNode"}}
  34. {{- end }}
  35. {{- toYaml (fromYaml (include "vm.args" $args)).args -}}
  36. {{- end -}}
  37. {{- define "vmauth.args" -}}
  38. {{- $Values := (.helm).Values | default .Values }}
  39. {{- $app := $Values.vmauth -}}
  40. {{- $args := default dict -}}
  41. {{- $_ := set $args "auth.config" "/config/auth.yml" -}}
  42. {{- $args = mergeOverwrite $args (fromYaml (include "vm.license.flag" .)) -}}
  43. {{- $args = mergeOverwrite $args $app.extraArgs -}}
  44. {{- toYaml (fromYaml (include "vm.args" $args)).args -}}
  45. {{- end -}}
  46. {{- define "vmselect.args" -}}
  47. {{- $Values := (.helm).Values | default .Values -}}
  48. {{- $app := $Values.vmselect -}}
  49. {{- $args := default dict -}}
  50. {{- $_ := set . "style" "plain" }}
  51. {{- $_ := set . "appKey" "vmstorage" }}
  52. {{- $_ := set $args "cacheDataPath" $app.cacheMountPath -}}
  53. {{- $args = mergeOverwrite $args (fromYaml (include "vm.license.flag" .)) -}}
  54. {{- $args = mergeOverwrite $args $app.extraArgs -}}
  55. {{- $storage := $Values.vmstorage }}
  56. {{- if and (not $app.suppressStorageFQDNsRender) $storage.enabled $storage.replicaCount }}
  57. {{- $storageNodes := default list }}
  58. {{- $fqdn := include "vm.fqdn" . }}
  59. {{- if $Values.autoDiscovery }}
  60. {{- if eq (include "vm.enterprise.disabled" . ) "true" }}
  61. {{- fail "SRV autodiscovery is only supported in enterprise. Either define license or set `autoDiscovery` to `false`" }}
  62. {{- end }}
  63. {{- $storageNode := printf "srv+_vmselect._tcp.%s" $fqdn }}
  64. {{- $storageNodes = append $storageNodes $storageNode }}
  65. {{- else }}
  66. {{- $port := "8401" }}
  67. {{- range $i := until ($storage.replicaCount | int) -}}
  68. {{- $_ := set $ "appIdx" $i }}
  69. {{- $storageNode := include "vm.fqdn" $ -}}
  70. {{- $storageNodes = append $storageNodes (printf "%s:%s" $storageNode $port) -}}
  71. {{- end -}}
  72. {{- $_ := unset . "appIdx" }}
  73. {{- end }}
  74. {{- $_ := set $args "storageNode" (concat ($args.storageNode | default list) $storageNodes) }}
  75. {{- end }}
  76. {{- if and $app.statefulSet.enabled $app.enabled $app.replicaCount }}
  77. {{- $selectNodes := default list }}
  78. {{- $_ := set . "appKey" "vmselect" }}
  79. {{- $fqdn := include "vm.fqdn" . }}
  80. {{- if $Values.autoDiscovery }}
  81. {{- if eq (include "vm.enterprise.disabled" . ) "true" }}
  82. {{- fail "SRV autodiscovery is only supported in enterprise. Either define license or set `autoDiscovery` to `false`" }}
  83. {{- end }}
  84. {{- $selectNode := printf "srv+_http._tcp.%s" $fqdn }}
  85. {{- $selectNodes = append $selectNodes $selectNode }}
  86. {{- else }}
  87. {{- $port := "8481" }}
  88. {{- with $app.extraArgs.httpListenAddr }}
  89. {{- $port = regexReplaceAll ".*:(\\d+)" . "${1}" }}
  90. {{- end -}}
  91. {{- range $i := until ($app.replicaCount | int) -}}
  92. {{- $_ := set $ "appIdx" $i }}
  93. {{- $selectNode := include "vm.fqdn" $ -}}
  94. {{- $selectNodes = append $selectNodes (printf "%s:%s" $selectNode $port) -}}
  95. {{- end -}}
  96. {{- $_ := unset $ "appIdx" }}
  97. {{- end }}
  98. {{- $_ := set $args "selectNode" (concat ($args.selectNode | default list) $selectNodes) }}
  99. {{- end -}}
  100. {{- if empty $args.storageNode }}
  101. {{- fail "no storageNodes found. Either set vmstorage.enabled to true or add nodes to vmselect.extraArgs.storageNode"}}
  102. {{- end }}
  103. {{- toYaml (fromYaml (include "vm.args" $args)).args -}}
  104. {{- end -}}
  105. {{- define "vmstorage.args" -}}
  106. {{- $Values := (.helm).Values | default .Values -}}
  107. {{- $app := $Values.vmstorage -}}
  108. {{- $args := default dict -}}
  109. {{- $_ := set $args "retentionPeriod" (toString $app.retentionPeriod) -}}
  110. {{- $_ := set $args "storageDataPath" $app.persistentVolume.mountPath -}}
  111. {{- $args = mergeOverwrite $args (fromYaml (include "vm.license.flag" .)) -}}
  112. {{- $args = mergeOverwrite $args $app.extraArgs -}}
  113. {{- toYaml (fromYaml (include "vm.args" $args)).args -}}
  114. {{- end -}}
  115. {{- define "vmbackupmanager.args" -}}
  116. {{- $Values := (.helm).Values | default .Values -}}
  117. {{- $app := $Values.vmstorage -}}
  118. {{- $manager := $app.vmbackupmanager -}}
  119. {{- $args := default dict -}}
  120. {{- $_ := set $args "disableHourly" $manager.disableHourly -}}
  121. {{- $_ := set $args "disableDaily" $manager.disableDaily -}}
  122. {{- $_ := set $args "disableWeekly" $manager.disableWeekly -}}
  123. {{- $_ := set $args "disableMonthly" $manager.disableMonthly -}}
  124. {{- $_ := set $args "keepLastHourly" $manager.retention.keepLastHourly -}}
  125. {{- $_ := set $args "keepLastDaily" $manager.retention.keepLastDaily -}}
  126. {{- $_ := set $args "keepLastWeekly" $manager.retention.keepLastWeekly -}}
  127. {{- $_ := set $args "keepLastMonthly" $manager.retention.keepLastMonthly -}}
  128. {{- $_ := set $args "storageDataPath" $app.persistentVolume.mountPath -}}
  129. {{- $_ := set $args "dst" (printf "%s/$(POD_NAME)" $manager.destination) -}}
  130. {{- $_ := set $args "snapshot.createURL" "http://localhost:8482/snapshot/create" -}}
  131. {{- $_ := set $args "snapshot.deleteURL" "http://localhost:8482/snapshot/delete" -}}
  132. {{- $args = mergeOverwrite $args (fromYaml (include "vm.license.flag" .)) -}}
  133. {{- $args = mergeOverwrite $args $manager.extraArgs -}}
  134. {{- toYaml (fromYaml (include "vm.args" $args)).args -}}
  135. {{- end -}}
  136. {{- define "vmbackupmanager.restore.args" -}}
  137. {{- $Values := (.helm).Values | default .Values -}}
  138. {{- $app := $Values.vmstorage -}}
  139. {{- $manager := $app.vmbackupmanager -}}
  140. {{- $args := default dict -}}
  141. {{- $_ := set $args "storageDataPath" $app.persistentVolume.mountPath -}}
  142. {{- $args = mergeOverwrite $args (fromYaml (include "vm.license.flag" .)) -}}
  143. {{- $args = mergeOverwrite $args $manager.extraArgs -}}
  144. {{- $output := (fromYaml (include "vm.args" $args)).args -}}
  145. {{- $output = concat (list "restore") $output -}}
  146. {{- toYaml $output -}}
  147. {{- end -}}
  148. {{- define "vmselect.ports" -}}
  149. - name: http
  150. port: {{ .service.servicePort }}
  151. protocol: TCP
  152. targetPort: {{ .service.targetPort }}
  153. {{- range .service.extraPorts }}
  154. - name: {{ .name }}
  155. port: {{ .port }}
  156. protocol: TCP
  157. targetPort: {{ .targetPort }}
  158. {{- end }}
  159. {{- with .extraArgs.clusternativeListenAddr }}
  160. - name: cluster-tcp
  161. protocol: TCP
  162. port: {{ include "vm.port.from.flag" (dict "flag" .) }}
  163. targetPort: cluster-tcp
  164. {{- end }}
  165. {{- end -}}
  166. {{- define "vminsert.ports" -}}
  167. - name: http
  168. port: {{ .service.servicePort }}
  169. protocol: TCP
  170. targetPort: {{ .service.targetPort }}
  171. {{- range .service.extraPorts }}
  172. - name: {{ .name }}
  173. port: {{ .port }}
  174. protocol: TCP
  175. targetPort: {{ .targetPort }}
  176. {{- end }}
  177. {{- with .extraArgs.clusternativeListenAddr }}
  178. - name: cluster-tcp
  179. protocol: TCP
  180. port: {{ include "vm.port.from.flag" (dict "flag" .) }}
  181. targetPort: cluster-tcp
  182. {{- end }}
  183. {{- with .extraArgs.graphiteListenAddr }}
  184. - name: graphite-tcp
  185. protocol: TCP
  186. port: {{ include "vm.port.from.flag" (dict "flag" .) }}
  187. targetPort: graphite-tcp
  188. - name: graphite-udp
  189. protocol: UDP
  190. port: {{ include "vm.port.from.flag" (dict "flag" .) }}
  191. targetPort: graphite-udp
  192. {{- end }}
  193. {{- with .extraArgs.influxListenAddr }}
  194. - name: influx-tcp
  195. protocol: TCP
  196. port: {{ include "vm.port.from.flag" (dict "flag" .) }}
  197. targetPort: influx-tcp
  198. - name: influx-udp
  199. protocol: UDP
  200. port: {{ include "vm.port.from.flag" (dict "flag" .) }}
  201. targetPort: influx-udp
  202. {{- end }}
  203. {{- with .extraArgs.opentsdbHTTPListenAddr }}
  204. - name: opentsdbhttp
  205. port: {{ include "vm.port.from.flag" (dict "flag" .) }}
  206. targetPort: opentsdbhttp
  207. {{- end }}
  208. {{- with .extraArgs.opentsdbListenAddr }}
  209. {{- if or .service.udp (ne .service.type "LoadBalancer") }}
  210. - name: opentsdb-udp
  211. protocol: UDP
  212. port: {{ include "vm.port.from.flag" (dict "flag" .) }}
  213. targetPort: opentsdb-udp
  214. {{- end }}
  215. - name: opentsdb-tcp
  216. protocol: TCP
  217. port: {{ include "vm.port.from.flag" (dict "flag" .) }}
  218. targetPort: opentsdb-tcp
  219. {{- end }}
  220. {{- end -}}
  221. {{- define "vmstorage.ports" -}}
  222. - port: {{ .service.servicePort }}
  223. targetPort: http
  224. protocol: TCP
  225. name: http
  226. - port: {{ .service.vmselectPort }}
  227. targetPort: vmselect
  228. protocol: TCP
  229. name: vmselect
  230. - port: {{ .service.vminsertPort }}
  231. targetPort: vminsert
  232. protocol: TCP
  233. name: vminsert
  234. {{- range .service.extraPorts }}
  235. - name: {{ .name }}
  236. port: {{ .port }}
  237. protocol: TCP
  238. targetPort: {{ .targetPort }}
  239. {{- end }}
  240. {{- end -}}
  241. {{- define "vmauth.ports" -}}
  242. - port: {{ .service.servicePort }}
  243. targetPort: http
  244. protocol: TCP
  245. name: http
  246. {{- range .service.extraPorts }}
  247. - name: {{ .name }}
  248. port: {{ .port }}
  249. protocol: TCP
  250. targetPort: {{ .targetPort }}
  251. {{- end }}
  252. {{- end -}}