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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio

### Improvements

- **General**: Add CRD-level validation markers (Minimum, MinLength, MinItems, Enum) for ScaledObject, ScaledJob, ScaleTriggers, and TriggerAuthentication API types ([#7533](https://github.com/kedacore/keda/pull/7533))
- **Elasticsearch Scaler**: Add HTTP status check for Elasticsearch errors ([#7480](https://github.com/kedacore/keda/pull/7480))

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion apis/eventing/v1alpha1/cloudevent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const (
// ClusterTriggerAuthenticationCreatedType is for event when a new ClusterTriggerAuthentication is created
ClusterTriggerAuthenticationCreatedType CloudEventType = "keda.authentication.clustertriggerauthentication.created.v1"

// ClusterTriggerAuthenticationCreatedType is for event when a ClusterTriggerAuthentication is updated
// ClusterTriggerAuthenticationUpdatedType is for event when a ClusterTriggerAuthentication is updated
ClusterTriggerAuthenticationUpdatedType CloudEventType = "keda.authentication.clustertriggerauthentication.updated.v1"

// ClusterTriggerAuthenticationRemovedType is for event when a ClusterTriggerAuthentication is deleted
Expand Down
4 changes: 2 additions & 2 deletions apis/keda/v1alpha1/condition_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ const (
const (
// ScaledJobConditionPausedReason defines the default Reason for paused ScaledJob
ScaledJobConditionPausedReason = "ScaledJobPaused"
// ScaledJobConditionPausedReason defines the default Reason for paused ScaledJob
// ScaledJobConditionUnpausedReason defines the default Reason for unpaused ScaledJob
ScaledJobConditionUnpausedReason = "ScaledJobUnpaused"
// ScaledJobConditionPausedMessage defines the default Message for paused ScaledJob
ScaledJobConditionPausedMessage = "ScaledJob is paused"
// ScaledJobConditionPausedMessage defines the default Message for paused ScaledJob
// ScaledJobConditionUnpausedMessage defines the default Message for unpaused ScaledJob
ScaledJobConditionUnpausedMessage = "ScaledJob is unpaused"
)

Expand Down
14 changes: 13 additions & 1 deletion apis/keda/v1alpha1/scaledjob_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,32 @@ const ScaledJobExcludedLabelsAnnotation = "scaledjob.keda.sh/job-excluded-labels
type ScaledJobSpec struct {
JobTargetRef *batchv1.JobSpec `json:"jobTargetRef"`
// +optional
// +kubebuilder:validation:Minimum=1
PollingInterval *int32 `json:"pollingInterval,omitempty"`
// +optional
// +kubebuilder:validation:Minimum=0
SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty"`
Comment thread
Fedosin marked this conversation as resolved.
// +optional
// +kubebuilder:validation:Minimum=0
FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty"`
// Deprecated: Use Rollout.Strategy instead (see https://github.com/kedacore/keda/issues/3596).
// +optional
// +kubebuilder:validation:Enum=gradual;immediate
RolloutStrategy string `json:"rolloutStrategy,omitempty"`
// +optional
Rollout Rollout `json:"rollout,omitempty"`
// +optional
EnvSourceContainerName string `json:"envSourceContainerName,omitempty"`
// +optional
// +kubebuilder:validation:Minimum=0
MinReplicaCount *int32 `json:"minReplicaCount,omitempty"`
// +optional
// +kubebuilder:validation:Minimum=1
MaxReplicaCount *int32 `json:"maxReplicaCount,omitempty"`
// +optional
ScalingStrategy ScalingStrategy `json:"scalingStrategy,omitempty"`
Triggers []ScaleTriggers `json:"triggers"`
// +kubebuilder:validation:MinItems=1
Triggers []ScaleTriggers `json:"triggers"`
}

// ScaledJobStatus defines the observed state of ScaledJob
Expand Down Expand Up @@ -105,6 +113,7 @@ type ScaledJobList struct {
// +optional
type ScalingStrategy struct {
// +optional
// +kubebuilder:validation:Enum=custom;accurate;eager
Strategy string `json:"strategy,omitempty"`
// +optional
CustomScalingQueueLengthDeduction *int32 `json:"customScalingQueueLengthDeduction,omitempty"`
Expand All @@ -113,15 +122,18 @@ type ScalingStrategy struct {
// +optional
PendingPodConditions []string `json:"pendingPodConditions,omitempty"`
// +optional
// +kubebuilder:validation:Enum=min;avg;sum;max
MultipleScalersCalculation string `json:"multipleScalersCalculation,omitempty"`
}

// Rollout defines the strategy for job rollouts
// +optional
type Rollout struct {
// +optional
// +kubebuilder:validation:Enum=gradual;immediate
Strategy string `json:"strategy,omitempty"`
// +optional
// +kubebuilder:validation:Enum=foreground;background
PropagationPolicy string `json:"propagationPolicy,omitempty"`
}

Expand Down
13 changes: 12 additions & 1 deletion apis/keda/v1alpha1/scaledobject_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,32 +97,42 @@ const (
)

// ScaledObjectSpec is the spec for a ScaledObject resource
// +kubebuilder:validation:XValidation:rule="!has(self.minReplicaCount) || self.minReplicaCount <= (has(self.maxReplicaCount) ? self.maxReplicaCount : 100)",message="minReplicaCount must be less than or equal to maxReplicaCount"
type ScaledObjectSpec struct {
ScaleTargetRef *ScaleTarget `json:"scaleTargetRef"`
// +optional
// +kubebuilder:validation:Minimum=1
PollingInterval *int32 `json:"pollingInterval,omitempty"`
// +optional
// +kubebuilder:validation:Minimum=0
InitialCooldownPeriod *int32 `json:"initialCooldownPeriod,omitempty"`
Comment thread
Fedosin marked this conversation as resolved.
// +optional
// +kubebuilder:validation:Minimum=0
CooldownPeriod *int32 `json:"cooldownPeriod,omitempty"`
// +optional
// +kubebuilder:validation:Minimum=0
IdleReplicaCount *int32 `json:"idleReplicaCount,omitempty"`
// +optional
// +kubebuilder:validation:Minimum=0
MinReplicaCount *int32 `json:"minReplicaCount,omitempty"`
// +optional
// +kubebuilder:validation:Minimum=1
MaxReplicaCount *int32 `json:"maxReplicaCount,omitempty"`
Comment thread
Fedosin marked this conversation as resolved.
// +optional
Advanced *AdvancedConfig `json:"advanced,omitempty"`

// +kubebuilder:validation:MinItems=1
Triggers []ScaleTriggers `json:"triggers"`
// +optional
Fallback *Fallback `json:"fallback,omitempty"`
}

// Fallback is the spec for fallback options
type Fallback struct {
// +kubebuilder:validation:Minimum=0
FailureThreshold int32 `json:"failureThreshold"`
Replicas int32 `json:"replicas"`
// +kubebuilder:validation:Minimum=0
Replicas int32 `json:"replicas"`
// +optional
// +kubebuilder:default=static
// +kubebuilder:validation:Enum=static;currentReplicas;currentReplicasIfHigher;currentReplicasIfLower
Expand Down Expand Up @@ -160,6 +170,7 @@ type HorizontalPodAutoscalerConfig struct {

// ScaleTarget holds the reference to the scale target Object
type ScaleTarget struct {
// +kubebuilder:validation:MinLength=1
Name string `json:"name"`
// +optional
APIVersion string `json:"apiVersion,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions apis/keda/v1alpha1/scaledobject_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,9 @@ func verifyCPUMemoryScalers(incomingSo *ScaledObject, action string, dryRun bool
return nil
}
}
conainerName := trigger.Metadata["containerName"]
containerName := trigger.Metadata["containerName"]
for _, container := range podSpec.Containers {
if conainerName != "" && container.Name != conainerName {
if containerName != "" && container.Name != containerName {
continue
}

Expand Down
2 changes: 2 additions & 0 deletions apis/keda/v1alpha1/scaletriggers_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

// ScaleTriggers reference the scaler that will be used
type ScaleTriggers struct {
// +kubebuilder:validation:MinLength=1
Type string `json:"type"`
// +optional
Name string `json:"name,omitempty"`
Expand All @@ -45,6 +46,7 @@ type AuthenticationRef struct {
Name string `json:"name"`
// Kind of the resource being referred to. Defaults to TriggerAuthentication.
// +optional
// +kubebuilder:validation:Enum=TriggerAuthentication;ClusterTriggerAuthentication
Kind string `json:"kind,omitempty"`
}

Expand Down
12 changes: 9 additions & 3 deletions apis/keda/v1alpha1/triggerauthentication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ type AuthEnvironment struct {
type HashiCorpVault struct {
Address string `json:"address"`
Authentication VaultAuthentication `json:"authentication"`
Secrets []VaultSecret `json:"secrets"`
// +kubebuilder:validation:MinItems=1
Secrets []VaultSecret `json:"secrets"`

// +optional
Namespace string `json:"namespace,omitempty"`
Expand Down Expand Up @@ -251,6 +252,7 @@ type Credential struct {
}

// VaultAuthentication contains the list of Hashicorp Vault authentication methods
// +kubebuilder:validation:Enum=token;kubernetes
type VaultAuthentication string

// Client authenticating to Vault
Expand All @@ -261,6 +263,7 @@ const (
)

// VaultSecretType defines the type of vault secret
// +kubebuilder:validation:Enum="";secretV2;secret;pki
type VaultSecretType string

const (
Expand Down Expand Up @@ -292,8 +295,9 @@ type VaultSecret struct {

// AzureKeyVault is used to authenticate using Azure Key Vault
type AzureKeyVault struct {
VaultURI string `json:"vaultUri"`
Secrets []AzureKeyVaultSecret `json:"secrets"`
VaultURI string `json:"vaultUri"`
// +kubebuilder:validation:MinItems=1
Secrets []AzureKeyVaultSecret `json:"secrets"`
// +optional
Credentials *AzureKeyVaultCredentials `json:"credentials"`
// +optional
Expand Down Expand Up @@ -337,6 +341,7 @@ type AzureKeyVaultCloudInfo struct {
}

type GCPSecretManager struct {
// +kubebuilder:validation:MinItems=1
Secrets []GCPSecretManagerSecret `json:"secrets"`
// +optional
Credentials *GCPCredentials `json:"credentials"`
Expand All @@ -361,6 +366,7 @@ type GCPSecretManagerSecret struct {

// AwsSecretManager is used to authenticate using AwsSecretManager
type AwsSecretManager struct {
// +kubebuilder:validation:MinItems=1
Secrets []AwsSecretManagerSecret `json:"secrets"`
// +optional
Credentials *AwsSecretManagerCredentials `json:"credentials"`
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/eventing.keda.sh_cloudeventsources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ spec:
kind:
description: Kind of the resource being referred to. Defaults
to TriggerAuthentication.
enum:
- TriggerAuthentication
- ClusterTriggerAuthentication
type: string
name:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ spec:
kind:
description: Kind of the resource being referred to. Defaults
to TriggerAuthentication.
enum:
- TriggerAuthentication
- ClusterTriggerAuthentication
type: string
name:
type: string
Expand Down
12 changes: 12 additions & 0 deletions config/crd/bases/keda.sh_clustertriggerauthentications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ spec:
- name
- parameter
type: object
minItems: 1
type: array
required:
- secrets
Expand Down Expand Up @@ -300,6 +301,7 @@ spec:
- name
- parameter
type: object
minItems: 1
type: array
vaultUri:
type: string
Expand Down Expand Up @@ -439,6 +441,7 @@ spec:
- id
- parameter
type: object
minItems: 1
type: array
required:
- secrets
Expand All @@ -452,6 +455,9 @@ spec:
authentication:
description: VaultAuthentication contains the list of Hashicorp
Vault authentication methods
enum:
- token
- kubernetes
type: string
credential:
description: Credential defines the Hashicorp Vault credentials
Expand Down Expand Up @@ -500,12 +506,18 @@ spec:
type: object
type:
description: VaultSecretType defines the type of vault secret
enum:
- ""
- secretV2
- secret
- pki
type: string
required:
- key
- parameter
- path
type: object
minItems: 1
type: array
required:
- address
Expand Down
29 changes: 29 additions & 0 deletions config/crd/bases/keda.sh_scaledjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ spec:
type: string
failedJobsHistoryLimit:
format: int32
minimum: 0
type: integer
jobTargetRef:
description: JobSpec describes how the job execution will look like.
Expand Down Expand Up @@ -8952,22 +8953,35 @@ spec:
type: object
maxReplicaCount:
format: int32
minimum: 1
type: integer
minReplicaCount:
format: int32
minimum: 0
type: integer
pollingInterval:
format: int32
minimum: 1
type: integer
rollout:
description: Rollout defines the strategy for job rollouts
properties:
propagationPolicy:
enum:
- foreground
- background
type: string
strategy:
enum:
- gradual
- immediate
type: string
type: object
rolloutStrategy:
description: 'Deprecated: Use Rollout.Strategy instead (see https://github.com/kedacore/keda/issues/3596).'
enum:
- gradual
- immediate
type: string
scalingStrategy:
description: ScalingStrategy defines the strategy of Scaling
Expand All @@ -8978,16 +8992,26 @@ spec:
customScalingRunningJobPercentage:
type: string
multipleScalersCalculation:
enum:
- min
- avg
- sum
- max
type: string
pendingPodConditions:
items:
type: string
type: array
strategy:
enum:
- custom
- accurate
- eager
type: string
type: object
successfulJobsHistoryLimit:
format: int32
minimum: 0
type: integer
triggers:
items:
Expand All @@ -9001,6 +9025,9 @@ spec:
kind:
description: Kind of the resource being referred to. Defaults
to TriggerAuthentication.
enum:
- TriggerAuthentication
- ClusterTriggerAuthentication
type: string
name:
type: string
Expand All @@ -9019,13 +9046,15 @@ spec:
name:
type: string
type:
minLength: 1
type: string
useCachedMetrics:
type: boolean
required:
- metadata
- type
type: object
minItems: 1
type: array
required:
- jobTargetRef
Expand Down
Loading
Loading