keda-autoscaler-worker.yaml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # Licensed to the Apache Software Foundation (ASF) under one
  2. # or more contributor license agreements. See the NOTICE file
  3. # distributed with this work for additional information
  4. # regarding copyright ownership. The ASF licenses this file
  5. # to you under the Apache License, Version 2.0 (the
  6. # "License"); you may not use this file except in compliance
  7. # with the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing,
  12. # software distributed under the License is distributed on an
  13. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. # KIND, either express or implied. See the License for the
  15. # specific language governing permissions and limitations
  16. # under the License.
  17. ################################
  18. ## DolphinScheduler Worker KEDA Scaler
  19. #################################
  20. {{- if and .Values.worker.keda.enabled }}
  21. apiVersion: keda.sh/v1alpha1
  22. kind: ScaledObject
  23. metadata:
  24. name: {{ include "dolphinscheduler.fullname" . }}-worker
  25. labels:
  26. component: worker-horizontalpodautoscaler
  27. deploymentName: {{ include "dolphinscheduler.fullname" . }}-worker
  28. spec:
  29. scaleTargetRef:
  30. kind: StatefulSet
  31. name: {{ include "dolphinscheduler.fullname" . }}-worker
  32. pollingInterval: {{ .Values.worker.keda.pollingInterval }}
  33. cooldownPeriod: {{ .Values.worker.keda.cooldownPeriod }}
  34. minReplicaCount: {{ .Values.worker.keda.minReplicaCount }}
  35. maxReplicaCount: {{ .Values.worker.keda.maxReplicaCount }}
  36. {{- if .Values.worker.keda.advanced }}
  37. advanced:
  38. {{ toYaml .Values.worker.keda.advanced | indent 4 }}
  39. {{- end }}
  40. # This is just an example, you could customize the trigger rule.
  41. # FYI, check TaskExecutionStatus.java for the human-readable meaning of state values below.
  42. triggers:
  43. {{- if .Values.postgresql.enabled }}
  44. - type: postgresql
  45. metadata:
  46. host: {{ template "dolphinscheduler.postgresql.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local
  47. port: "5432"
  48. dbName: {{ .Values.postgresql.postgresqlDatabase }}
  49. userName: {{ .Values.postgresql.postgresqlUsername }}
  50. passwordFromEnv: SPRING_DATASOURCE_PASSWORD
  51. sslmode: "disable"
  52. targetQueryValue: "1"
  53. query: >-
  54. SELECT ceil(COUNT(*)::decimal / {{ .Values.worker.env.WORKER_EXEC_THREADS }})
  55. FROM t_ds_task_instance
  56. WHERE state IN (0, 1, 8, 12, 17)
  57. {{- else if .Values.mysql.enabled }}
  58. - type: mysql
  59. metadata:
  60. host: {{ template "dolphinscheduler.mysql.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local
  61. port: "3306"
  62. dbName: {{ .Values.mysql.auth.database }}
  63. username: {{ .Values.mysql.auth.username }}
  64. passwordFromEnv: SPRING_DATASOURCE_PASSWORD
  65. queryValue: "1"
  66. query: >-
  67. SELECT CEIL(COUNT(*) / {{ .Values.worker.env.WORKER_EXEC_THREADS }})
  68. FROM t_ds_task_instance
  69. WHERE state IN (0, 1, 8, 12, 17)
  70. {{- else if .Values.externalDatabase.enabled }}
  71. {{- if eq .Values.externalDatabase.type "mysql" }}
  72. - type: mysql
  73. metadata:
  74. host: {{ .Values.externalDatabase.host }}
  75. # mysql scaler requests port in string format
  76. port: "{{ .Values.externalDatabase.port }}"
  77. dbName: {{ .Values.externalDatabase.database }}
  78. username: {{ .Values.externalDatabase.username }}
  79. passwordFromEnv: SPRING_DATASOURCE_PASSWORD
  80. queryValue: "1"
  81. query: >-
  82. SELECT CEIL(COUNT(*) / {{ .Values.worker.env.WORKER_EXEC_THREADS }})
  83. FROM t_ds_task_instance
  84. WHERE state IN (0, 1, 8, 12, 17)
  85. {{- else if eq .Values.externalDatabase.type "postgresql" }}
  86. - type: postgresql
  87. metadata:
  88. host: {{ .Values.externalDatabase.host }}
  89. port: "{{ .Values.externalDatabase.port }}"
  90. dbName: {{ .Values.externalDatabase.database }}
  91. userName: {{ .Values.externalDatabase.username }}
  92. passwordFromEnv: SPRING_DATASOURCE_PASSWORD
  93. sslmode: "disable"
  94. targetQueryValue: "1"
  95. query: >-
  96. SELECT ceil(COUNT(*)::decimal / {{ .Values.worker.env.WORKER_EXEC_THREADS }})
  97. FROM t_ds_task_instance
  98. WHERE state IN (0, 1, 8, 12, 17)
  99. {{- end }}
  100. {{- end }}
  101. {{- end }}