Skip to content

Commit 9f12506

Browse files
pggb25TheoGrandin74
authored andcommitted
feat(keda): enable keda for GCP and fix error when creating a service without autoscaler (#2345)
1 parent 5e98576 commit 9f12506

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

libs/pages/services/src/lib/feature/page-application-create-feature/page-application-create-feature.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ export function PageApplicationCreateFeature() {
7070
cpu: 500,
7171
gpu: 0,
7272
min_running_instances: 1,
73-
max_running_instances: 2,
74-
autoscaling_mode: 'HPA',
73+
max_running_instances: 1,
74+
autoscaling_mode: 'NONE',
7575
hpa_metric_type: 'CPU',
7676
hpa_cpu_average_utilization_percent: 60,
7777
})

libs/shared/console-shared/src/lib/application-settings/ui/application-settings-resources/application-settings-resources.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,25 @@ export function ApplicationSettingsResources({
7373
const hpaMemoryAverageUtilizationPercent = watch('hpa_memory_average_utilization_percent') ?? 60
7474
const previousAutoscalingModeRef = useRef(autoscalingMode)
7575

76-
// Adjust min/max values when switching from NONE to HPA or KEDA
76+
// Adjust min/max values when switching between autoscaling modes
7777
useEffect(() => {
7878
const previousMode = previousAutoscalingModeRef.current
79+
80+
// When switching from no autoscaling to HPA/KEDA, set min=1 and max=2
7981
if (previousMode === 'NONE' && (autoscalingMode === 'HPA' || autoscalingMode === 'KEDA')) {
80-
// When switching from no autoscaling to HPA/KEDA, set min=1 and max=2
8182
if (minRunningInstances === maxRunningInstances) {
8283
setValue('min_running_instances', 1)
8384
setValue('max_running_instances', 2)
8485
}
8586
}
8687

88+
// When switching to no autoscaling (NONE), ensure max equals min
89+
if ((previousMode === 'HPA' || previousMode === 'KEDA') && autoscalingMode === 'NONE') {
90+
if (minRunningInstances !== maxRunningInstances) {
91+
setValue('max_running_instances', minRunningInstances)
92+
}
93+
}
94+
8795
// Set default HPA settings when switching to HPA mode
8896
if (autoscalingMode === 'HPA' && !hpaMetricTypeRaw) {
8997
const hpaSettings = loadHpaSettingsFromAdvancedSettings(advancedSettings)
@@ -322,7 +330,7 @@ export function ApplicationSettingsResources({
322330
{ label: 'HPA (Horizontal Pod Autoscaler)', value: 'HPA' },
323331
]
324332

325-
if (cloudProvider === 'AWS' && isKedaCluster && isKedaFeatureEnabled) {
333+
if ((cloudProvider === 'AWS' || cloudProvider === 'GCP') && isKedaCluster && isKedaFeatureEnabled) {
326334
options.push({ label: 'KEDA (Event-driven autoscaling)', value: 'KEDA' })
327335
}
328336

libs/shared/console-shared/src/lib/cluster-settings/ui/cluster-general-settings/cluster-general-settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export function ClusterGeneralSettings(props: ClusterGeneralSettingsProps) {
135135
)}
136136
</>
137137
)}
138-
{fromDetail && cloudProvider === 'AWS' && isKedaFeatureEnabled && (
138+
{fromDetail && (cloudProvider === 'AWS' || cloudProvider === 'GCP') && isKedaFeatureEnabled && (
139139
<Controller
140140
name="keda.enabled"
141141
control={control}

0 commit comments

Comments
 (0)