EricGao888 commented on code in PR #13367:
URL: 
https://github.com/apache/dolphinscheduler/pull/13367#discussion_r1067649383


##########
deploy/kubernetes/dolphinscheduler/templates/keda-autoscaler-worker.yaml:
##########
@@ -0,0 +1,59 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+################################
+## DolphinScheduler Worker KEDA Scaler
+#################################
+{{- if and .Values.worker.keda.enabled }}
+apiVersion: keda.sh/v1alpha1
+kind: ScaledObject
+metadata:
+  name: {{ include "dolphinscheduler.fullname" . }}-worker
+  labels:
+    component: worker-horizontalpodautoscaler
+    deploymentName: {{ include "dolphinscheduler.fullname" . }}-worker
+spec:
+  scaleTargetRef:
+    kind: StatefulSet
+    name: {{ include "dolphinscheduler.fullname" . }}-worker
+  pollingInterval:  {{ .Values.worker.keda.pollingInterval }}   # Optional. 
Default: 30 seconds
+  cooldownPeriod: {{ .Values.worker.keda.cooldownPeriod }}    # Optional. 
Default: 300 seconds
+  minReplicaCount: {{ .Values.worker.keda.minReplicaCount }}   # Optional. 
Default: 0
+  maxReplicaCount: {{ .Values.worker.keda.maxReplicaCount }}   # Optional. 
Default: 100
+  {{- if .Values.worker.keda.advanced }}
+  advanced:
+    {{ toYaml .Values.worker.keda.advanced | indent 4 }}
+    {{- end }}
+  # This is just an example, you could customize the trigger rule.
+  # FYI, check TaskExecutionStatus.java for the human-readable meaning of 
state values below.
+  triggers:
+    - type: postgresql
+      metadata:
+#        connection: jdbc:postgresql://{{ template 
"dolphinscheduler.postgresql.fullname" . }}:5432/{{ 
.Values.postgresql.postgresqlDatabase }}?{{ .Values.postgresql.params }}
+#        host: {{ template "dolphinscheduler.postgresql.fullname" . }}.{{ 
.Release.Namespace }}.svc.cluster.local
+        host: 
dolphinscheduler-postgresql-0.dolphinscheduler-postgresql-headless.{{ 
.Release.Namespace }}.svc.cluster.local

Review Comment:
   > > Need to find a way to get the first part of dns 
`dolphinscheduler-postgresql-0.dolphinscheduler-postgresql-headless` 
dynamically.
   > 
   > We can't do that because the database can be user-specified, not deployed 
by our Chart. Can we use the `connection` field? I see you commented it out, if 
we can use `connection`, we might consider refactor out the following part as a 
template and include it here.
   > 
   > 
https://github.com/apache/dolphinscheduler/blob/dd0d73036ed5065aa4f4920700aaa0aabc13ef7e/deploy/kubernetes/dolphinscheduler/templates/_helpers.tpl#L149-L156
   
   Thanks for the reply. Currently, I'm working on pg autoscaler and supporting 
the default pg chart. The thing I'm trying to do here is to get the 
`cluster-wide dns` from template instead of hard-coding it. Although this 
ScaledObject is deployed in the same namespace where ds is deployed, but KEDA 
operator is actually deployed in another namespace. Therefore, the pg host name 
here must be a `cluster-wide dns`. At present, I get this dns by hard-coding 
the first part 
`dolphinscheduler-postgresql-0.dolphinscheduler-postgresql-headless.` and I 
think there should be a better way to do it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to