viirya commented on code in PR #135:
URL:
https://github.com/apache/spark-kubernetes-operator/pull/135#discussion_r1771782664
##########
spark-submission-worker/src/main/java/org/apache/spark/k8s/operator/SparkClusterResourceSpec.java:
##########
@@ -271,4 +277,55 @@ private static StatefulSet buildWorkerStatefulSet(
.endSpec()
.build();
}
+
+ private static Optional<HorizontalPodAutoscaler>
buildHorizontalPodAutoscaler(
+ String clusterName, String namespace, ClusterSpec spec) {
+ var instanceConfig = spec.getClusterTolerations().getInstanceConfig();
+ if (instanceConfig.getMinWorkers() >= instanceConfig.getMaxWorkers()) {
+ return Optional.empty();
+ }
+ return Optional.of(
+ new HorizontalPodAutoscalerBuilder()
+ .withNewMetadata()
+ .withNamespace(namespace)
+ .withName(clusterName + "-worker-hpa")
+ .endMetadata()
+ .withNewSpec()
+ .withNewScaleTargetRef()
+ .withApiVersion("apps/v1")
+ .withKind("StatefulSet")
+ .withName(clusterName + "-worker")
+ .endScaleTargetRef()
+ .withMinReplicas(instanceConfig.getMinWorkers())
+ .withMaxReplicas(instanceConfig.getMaxWorkers())
+ .addToMetrics(
+ new MetricSpecBuilder()
+ .withType("Resource")
+ .withNewResource()
+ .withName("cpu")
+ .withNewTarget()
+ .withType("Utilization")
+ .withAverageUtilization(30)
+ .endTarget()
+ .endResource()
+ .build())
Review Comment:
Can these configs like resource and average utilization to be specify in
cluster yaml file instead hard-coded?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]