Skip to content

Commit

Permalink
Merge branch 'master' into update-operator-with-keda-support
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard87 authored Jun 13, 2024
2 parents d387e15 + a374de8 commit 343ff63
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 6 deletions.
41 changes: 41 additions & 0 deletions api/deployments/component_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,47 @@ func createHorizontalScalingObjects(name string, minReplicas *int32, maxReplicas
return scaler, hpa
}

func createAutoscaler(name string, minReplicas *int32, maxReplicas int32, targetCpu *int32, targetMemory *int32) v2.HorizontalPodAutoscaler {
var metrics []v2.MetricSpec

if targetCpu != nil {
metrics = append(metrics, v2.MetricSpec{
Resource: &v2.ResourceMetricSource{
Name: "cpu",
Target: v2.MetricTarget{
Type: "cpu",
AverageUtilization: targetCpu,
},
},
})
}

if targetMemory != nil {
metrics = append(metrics, v2.MetricSpec{
Resource: &v2.ResourceMetricSource{
Name: "memory",
Target: v2.MetricTarget{
Type: "memory",
AverageUtilization: targetMemory,
},
},
})
}

autoscaler := v2.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: labelselector.ForComponent(anyAppName, "frontend"),
},
Spec: v2.HorizontalPodAutoscalerSpec{
MinReplicas: minReplicas,
MaxReplicas: maxReplicas,
Metrics: metrics,
},
}
return autoscaler
}

func TestGetComponents_WithIdentity(t *testing.T) {
// Setup
commonTestUtils, controllerTestUtils, client, radixclient, kedaClient, promclient, secretProviderClient, certClient := setupTest(t)
Expand Down
1 change: 1 addition & 0 deletions api/deployments/component_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/equinor/radix-api/api/kubequery"
"github.com/equinor/radix-api/api/models"
"github.com/equinor/radix-api/api/utils/event"
"github.com/equinor/radix-api/api/utils/horizontalscaling"

Check failure on line 11 in api/deployments/component_handler.go

View workflow job for this annotation

GitHub Actions / Unit Test

"github.com/equinor/radix-api/api/utils/horizontalscaling" imported and not used

Check failure on line 11 in api/deployments/component_handler.go

View workflow job for this annotation

GitHub Actions / Lint

"github.com/equinor/radix-api/api/utils/horizontalscaling" imported and not used) (typecheck)

Check failure on line 11 in api/deployments/component_handler.go

View workflow job for this annotation

GitHub Actions / Lint

"github.com/equinor/radix-api/api/utils/horizontalscaling" imported and not used) (typecheck)

Check failure on line 11 in api/deployments/component_handler.go

View workflow job for this annotation

GitHub Actions / Lint

"github.com/equinor/radix-api/api/utils/horizontalscaling" imported and not used (typecheck)

Check failure on line 11 in api/deployments/component_handler.go

View workflow job for this annotation

GitHub Actions / Lint

"github.com/equinor/radix-api/api/utils/horizontalscaling" imported and not used) (typecheck)

Check failure on line 11 in api/deployments/component_handler.go

View workflow job for this annotation

GitHub Actions / Lint

"github.com/equinor/radix-api/api/utils/horizontalscaling" imported and not used) (typecheck)
"github.com/equinor/radix-api/api/utils/labelselector"
radixutils "github.com/equinor/radix-common/utils"
"github.com/equinor/radix-common/utils/slice"
Expand Down
7 changes: 6 additions & 1 deletion api/environments/environment_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2743,7 +2743,12 @@ func Test_DeleteBatch(t *testing.T) {
}
}

func initHandler(client kubernetes.Interface, radixclient radixclient.Interface, kedaClient kedav2.Interface, secretproviderclient secretsstorevclient.Interface, certClient certclient.Interface, handlerConfig ...EnvironmentHandlerOptions) EnvironmentHandler {
func initHandler(client kubernetes.Interface,
radixclient radixclient.Interface,
kedaClient kedav2.Interface,
secretproviderclient secretsstorevclient.Interface,
certClient certclient.Interface,
handlerConfig ...EnvironmentHandlerOptions) EnvironmentHandler {
accounts := models.NewAccounts(client, radixclient, kedaClient, secretproviderclient, nil, certClient, client, radixclient, kedaClient, secretproviderclient, nil, certClient, "", radixmodels.Impersonation{})
options := []EnvironmentHandlerOptions{WithAccounts(accounts)}
options = append(options, handlerConfig...)
Expand Down
11 changes: 6 additions & 5 deletions radixconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ spec:
ports:
- name: http
port: 3002
public: true
- name: metrics
port: 9090
publicPort: http
monitoring: true
monitoringConfig:
portName: metrics
variables:
REQUIRE_APP_CONFIGURATION_ITEM: "true"
REQUIRE_APP_AD_GROUPS: "true"
Expand All @@ -27,11 +32,9 @@ spec:
LOG_PRETTY: "false"
environmentConfig:
- environment: qa
runAsNonRoot: true
horizontalScaling:
minReplicas: 1
maxReplicas: 2
monitoring: true
resources:
requests:
memory: "400M"
Expand All @@ -44,9 +47,7 @@ spec:
TEKTON_IMG_TAG: "main-latest"
GOMAXPROCS: "1"
- environment: prod
runAsNonRoot: true
replicas: 2
monitoring: true
resources:
requests:
memory: "700M"
Expand Down

0 comments on commit 343ff63

Please sign in to comment.