Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/modules/ROOT/partials/apis/camel-k-crds.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8362,6 +8362,14 @@ string

The autoscaler type.

|`metricType` +
string
|
*(Optional)*

The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
(`Utilization`, `AverageValue` or `Value`).

|`metadata` +
map[string]string
|
Expand Down
72 changes: 72 additions & 0 deletions helm/camel-k/crds/camel-k-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5015,6 +5015,15 @@ spec:
description: The trigger metadata (see Keda documentation
to learn how to fill for each type).
type: object
metricType:
description: |-
The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
(`Utilization`, `AverageValue` or `Value`).
enum:
- Utilization
- AverageValue
- Value
type: string
secrets:
description: The secrets mapping to use. Keda allows
the possibility to use values coming from different
Expand Down Expand Up @@ -7559,6 +7568,15 @@ spec:
description: The trigger metadata (see Keda documentation
to learn how to fill for each type).
type: object
metricType:
description: |-
The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
(`Utilization`, `AverageValue` or `Value`).
enum:
- Utilization
- AverageValue
- Value
type: string
secrets:
description: The secrets mapping to use. Keda allows
the possibility to use values coming from different
Expand Down Expand Up @@ -9997,6 +10015,15 @@ spec:
description: The trigger metadata (see Keda documentation
to learn how to fill for each type).
type: object
metricType:
description: |-
The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
(`Utilization`, `AverageValue` or `Value`).
enum:
- Utilization
- AverageValue
- Value
type: string
secrets:
description: The secrets mapping to use. Keda allows
the possibility to use values coming from different
Expand Down Expand Up @@ -12421,6 +12448,15 @@ spec:
description: The trigger metadata (see Keda documentation
to learn how to fill for each type).
type: object
metricType:
description: |-
The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
(`Utilization`, `AverageValue` or `Value`).
enum:
- Utilization
- AverageValue
- Value
type: string
secrets:
description: The secrets mapping to use. Keda allows
the possibility to use values coming from different
Expand Down Expand Up @@ -21707,6 +21743,15 @@ spec:
description: The trigger metadata (see Keda documentation
to learn how to fill for each type).
type: object
metricType:
description: |-
The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
(`Utilization`, `AverageValue` or `Value`).
enum:
- Utilization
- AverageValue
- Value
type: string
secrets:
description: The secrets mapping to use. Keda allows
the possibility to use values coming from different
Expand Down Expand Up @@ -24092,6 +24137,15 @@ spec:
description: The trigger metadata (see Keda documentation
to learn how to fill for each type).
type: object
metricType:
description: |-
The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
(`Utilization`, `AverageValue` or `Value`).
enum:
- Utilization
- AverageValue
- Value
type: string
secrets:
description: The secrets mapping to use. Keda allows
the possibility to use values coming from different
Expand Down Expand Up @@ -34744,6 +34798,15 @@ spec:
description: The trigger metadata (see Keda documentation
to learn how to fill for each type).
type: object
metricType:
description: |-
The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
(`Utilization`, `AverageValue` or `Value`).
enum:
- Utilization
- AverageValue
- Value
type: string
secrets:
description: The secrets mapping to use. Keda allows
the possibility to use values coming from different
Expand Down Expand Up @@ -37048,6 +37111,15 @@ spec:
description: The trigger metadata (see Keda documentation
to learn how to fill for each type).
type: object
metricType:
description: |-
The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
(`Utilization`, `AverageValue` or `Value`).
enum:
- Utilization
- AverageValue
- Value
type: string
secrets:
description: The secrets mapping to use. Keda allows
the possibility to use values coming from different
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/camel/v1/trait/keda.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ type KedaTrait struct {
type KedaTrigger struct {
// The autoscaler type.
Type string `json:"type,omitempty" property:"type"`
// The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
// (`Utilization`, `AverageValue` or `Value`).
// +kubebuilder:validation:Enum=Utilization;AverageValue;Value
// +optional
MetricType string `json:"metricType,omitempty" property:"metric-type"`
// The trigger metadata (see Keda documentation to learn how to fill for each type).
Metadata map[string]string `json:"metadata,omitempty" property:"metadata"`
// The secrets mapping to use. Keda allows the possibility to use values coming from different secrets.
Expand Down
6 changes: 4 additions & 2 deletions pkg/apis/duck/keda/v1alpha1/duck_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ type ScaledObjectSpec struct {
type ScaleTriggers struct {
Type string `json:"type"`
// +optional
Name string `json:"name,omitempty"`
Metadata map[string]string `json:"metadata"`
Name string `json:"name,omitempty"`
// +optional
MetricType string `json:"metricType,omitempty"`
Metadata map[string]string `json:"metadata"`
// +optional
AuthenticationRef *ScaledObjectAuthRef `json:"authenticationRef,omitempty"`
// +optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1709,6 +1709,15 @@ spec:
description: The trigger metadata (see Keda documentation
to learn how to fill for each type).
type: object
metricType:
description: |-
The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
(`Utilization`, `AverageValue` or `Value`).
enum:
- Utilization
- AverageValue
- Value
type: string
secrets:
description: The secrets mapping to use. Keda allows
the possibility to use values coming from different
Expand Down Expand Up @@ -4253,6 +4262,15 @@ spec:
description: The trigger metadata (see Keda documentation
to learn how to fill for each type).
type: object
metricType:
description: |-
The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
(`Utilization`, `AverageValue` or `Value`).
enum:
- Utilization
- AverageValue
- Value
type: string
secrets:
description: The secrets mapping to use. Keda allows
the possibility to use values coming from different
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,15 @@ spec:
description: The trigger metadata (see Keda documentation
to learn how to fill for each type).
type: object
metricType:
description: |-
The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
(`Utilization`, `AverageValue` or `Value`).
enum:
- Utilization
- AverageValue
- Value
type: string
secrets:
description: The secrets mapping to use. Keda allows
the possibility to use values coming from different
Expand Down Expand Up @@ -3991,6 +4000,15 @@ spec:
description: The trigger metadata (see Keda documentation
to learn how to fill for each type).
type: object
metricType:
description: |-
The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
(`Utilization`, `AverageValue` or `Value`).
enum:
- Utilization
- AverageValue
- Value
type: string
secrets:
description: The secrets mapping to use. Keda allows
the possibility to use values coming from different
Expand Down
18 changes: 18 additions & 0 deletions pkg/resources/config/crd/bases/camel.apache.org_integrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8418,6 +8418,15 @@ spec:
description: The trigger metadata (see Keda documentation
to learn how to fill for each type).
type: object
metricType:
description: |-
The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
(`Utilization`, `AverageValue` or `Value`).
enum:
- Utilization
- AverageValue
- Value
type: string
secrets:
description: The secrets mapping to use. Keda allows
the possibility to use values coming from different
Expand Down Expand Up @@ -10803,6 +10812,15 @@ spec:
description: The trigger metadata (see Keda documentation
to learn how to fill for each type).
type: object
metricType:
description: |-
The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
(`Utilization`, `AverageValue` or `Value`).
enum:
- Utilization
- AverageValue
- Value
type: string
secrets:
description: The secrets mapping to use. Keda allows
the possibility to use values coming from different
Expand Down
18 changes: 18 additions & 0 deletions pkg/resources/config/crd/bases/camel.apache.org_pipes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8476,6 +8476,15 @@ spec:
description: The trigger metadata (see Keda documentation
to learn how to fill for each type).
type: object
metricType:
description: |-
The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
(`Utilization`, `AverageValue` or `Value`).
enum:
- Utilization
- AverageValue
- Value
type: string
secrets:
description: The secrets mapping to use. Keda allows
the possibility to use values coming from different
Expand Down Expand Up @@ -10780,6 +10789,15 @@ spec:
description: The trigger metadata (see Keda documentation
to learn how to fill for each type).
type: object
metricType:
description: |-
The metric type for this trigger, mapping to KEDA's trigger-level `metricType`
(`Utilization`, `AverageValue` or `Value`).
enum:
- Utilization
- AverageValue
- Value
type: string
secrets:
description: The secrets mapping to use. Keda allows
the possibility to use values coming from different
Expand Down
5 changes: 3 additions & 2 deletions pkg/trait/keda.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ func (t *kedaTrait) populateTriggers(itName, itNamespace string) ([]v1alpha1.Sca
triggers := make([]v1alpha1.ScaleTriggers, 0, len(t.Triggers))
for _, trigger := range t.Triggers {
scaleTrigger := v1alpha1.ScaleTriggers{
Type: trigger.Type,
Metadata: trigger.Metadata,
Type: trigger.Type,
MetricType: trigger.MetricType,
Metadata: trigger.Metadata,
}
if trigger.Secrets != nil {
triggerAuth := populateTriggerAuth(trigger.Secrets, itName, itNamespace, trigger.Type)
Expand Down
29 changes: 29 additions & 0 deletions pkg/trait/keda_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,35 @@ func TestKeda(t *testing.T) {
assert.Equal(t, "10", scaledObject.Spec.Triggers[0].Metadata["lagThreshold"])
}

func TestKedaMetricType(t *testing.T) {
environment := nominalEnv(t)
// A cpu trigger with a trigger-level metricType: KEDA v2.18+ requires this for
// the cpu/memory scalers (the deprecated metadata.type was removed).
environment.Integration.Spec.Traits.Keda.Triggers = []traitv1.KedaTrigger{
{
Type: "cpu",
MetricType: "Utilization",
Metadata: map[string]string{
"value": "70",
},
},
}
traitCatalog := environment.Catalog

_, _, err := traitCatalog.apply(&environment)

require.NoError(t, err)
assert.NotEmpty(t, environment.ExecutedTraits)
assert.NotNil(t, environment.GetTrait("keda"))

scaledObject := getKedaScaledObject(environment.Resources)
require.NotNil(t, scaledObject)
require.Len(t, scaledObject.Spec.Triggers, 1)
assert.Equal(t, "cpu", scaledObject.Spec.Triggers[0].Type)
assert.Equal(t, "Utilization", scaledObject.Spec.Triggers[0].MetricType)
assert.Equal(t, "70", scaledObject.Spec.Triggers[0].Metadata["value"])
}

func TestKedaAutoDiscovery(t *testing.T) {
tests := []struct {
name string
Expand Down
Loading