Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for KEDA #2838

Merged
merged 22 commits into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a3a91b4
Fix #1107: keda scaffolding
nicolaferraro Dec 10, 2021
10d4bbd
Fix #1107: add support for nested trait configuration
nicolaferraro Dec 13, 2021
fc5f706
Fix #1107: initial trait
nicolaferraro Dec 15, 2021
02a9015
Fix #1107: generalize server side apply code and reuse
nicolaferraro Dec 15, 2021
58297a6
Fix #1107: adding optional keda fields
nicolaferraro Dec 15, 2021
cd8a47d
Fix #1107: adding first support for Kamelets
nicolaferraro Dec 16, 2021
f44884c
Fix #1107: refactoring annotations and secret generation
nicolaferraro Dec 17, 2021
3120f64
Fix #1107: disable camel case conversion by default
nicolaferraro Dec 20, 2021
ebe345f
Fix #1107: add documentation
nicolaferraro Dec 20, 2021
97c1868
Fix #1107: add optional authentication secret
nicolaferraro Dec 20, 2021
4883c09
Fix #1107: added tests
nicolaferraro Dec 20, 2021
55f5522
Fix #1107: added roles and regen
nicolaferraro Dec 20, 2021
37162bc
Fix #1107: update helm roles
nicolaferraro Dec 20, 2021
ff5031b
Fix #1107: add tests for kamelet binding and replicas
nicolaferraro Dec 20, 2021
1edfde7
Fix #1107: fix deepcopy gen
nicolaferraro Dec 20, 2021
6cc2aa6
Fix #1107: fix linter
nicolaferraro Dec 21, 2021
e2a70ed
Fix #1107: remove limit from doc
nicolaferraro Dec 21, 2021
87c9316
Fix #1107: fix findings
nicolaferraro Dec 21, 2021
7fb997d
Fix #1107: add missing operator role
nicolaferraro Dec 22, 2021
9a57b06
Fix #1107: simplify applier code
nicolaferraro Jan 3, 2022
9dd7bf6
Fix #1107: disable applier code to detect real CI errors
nicolaferraro Jan 10, 2022
c6d5111
Fix #1107: fix expected roles in tests
nicolaferraro Jan 10, 2022
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
21 changes: 21 additions & 0 deletions addons/keda/duck/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package duck contains a partial schema of the KEDA APIs
// +kubebuilder:object:generate=true
// +groupName=keda.sh
package v1alpha1
118 changes: 118 additions & 0 deletions addons/keda/duck/v1alpha1/duck_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +genclient:onlyVerbs=get,list,watch
// +genclient:noStatus
// +kubebuilder:object:root=true

// ScaledObject is a specification for a ScaledObject resource.
type ScaledObject struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ScaledObjectSpec `json:"spec"`
}

// ScaledObjectSpec is the spec for a ScaledObject resource.
type ScaledObjectSpec struct {
ScaleTargetRef *v1.ObjectReference `json:"scaleTargetRef"`
// +optional
PollingInterval *int32 `json:"pollingInterval,omitempty"`
// +optional
CooldownPeriod *int32 `json:"cooldownPeriod,omitempty"`
// +optional
IdleReplicaCount *int32 `json:"idleReplicaCount,omitempty"`
// +optional
MinReplicaCount *int32 `json:"minReplicaCount,omitempty"`
// +optional
MaxReplicaCount *int32 `json:"maxReplicaCount,omitempty"`

Triggers []ScaleTriggers `json:"triggers"`
}

// ScaleTriggers reference the scaler that will be used.
type ScaleTriggers struct {
Type string `json:"type"`
// +optional
Name string `json:"name,omitempty"`
Metadata map[string]string `json:"metadata"`
// +optional
AuthenticationRef *ScaledObjectAuthRef `json:"authenticationRef,omitempty"`
// +optional
FallbackReplicas *int32 `json:"fallback,omitempty"`
}

// ScaledObjectAuthRef points to the TriggerAuthentication or ClusterTriggerAuthentication object that
// is used to authenticate the scaler with the environment.
type ScaledObjectAuthRef struct {
Name string `json:"name"`
// Kind of the resource being referred to. Defaults to TriggerAuthentication.
// +optional
Kind string `json:"kind,omitempty"`
}

// +kubebuilder:object:root=true

// ScaledObjectList contains a list of ScaledObject.
type ScaledObjectList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ScaledObject `json:"items"`
}

// +genclient
// +genclient:onlyVerbs=get,list,watch
// +genclient:noStatus
// +kubebuilder:object:root=true

// TriggerAuthentication defines how a trigger can authenticate.
type TriggerAuthentication struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec TriggerAuthenticationSpec `json:"spec"`
}

// TriggerAuthenticationSpec defines the various ways to authenticate.
type TriggerAuthenticationSpec struct {
// +optional
SecretTargetRef []AuthSecretTargetRef `json:"secretTargetRef,omitempty"`
}

// AuthSecretTargetRef is used to authenticate using a reference to a secret.
type AuthSecretTargetRef struct {
Parameter string `json:"parameter"`
Name string `json:"name"`
Key string `json:"key"`
}

// +kubebuilder:object:root=true

// TriggerAuthenticationList contains a list of TriggerAuthentication.
type TriggerAuthenticationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []TriggerAuthentication `json:"items"`
}
39 changes: 39 additions & 0 deletions addons/keda/duck/v1alpha1/duck_types_support.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
ScaledObjectKind = "ScaledObject"
)

func NewScaledObject(namespace string, name string) ScaledObject {
return ScaledObject{
TypeMeta: metav1.TypeMeta{
APIVersion: SchemeGroupVersion.String(),
Kind: ScaledObjectKind,
},
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace,
Name: name,
},
}
}
57 changes: 57 additions & 0 deletions addons/keda/duck/v1alpha1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)

const (
KEDAGroup = "keda.sh"
KEDAVersion = "v1alpha1"
)

var (
// SchemeGroupVersion is group version used to register these objects.
SchemeGroupVersion = schema.GroupVersion{Group: KEDAGroup, Version: KEDAVersion}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

// AddToScheme is a shortcut to SchemeBuilder.AddToScheme.
AddToScheme = SchemeBuilder.AddToScheme
)

// Resource takes an unqualified resource and returns a Group qualified GroupResource.
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

// Adds the list of known types to Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&ScaledObject{},
&ScaledObjectList{},
&TriggerAuthentication{},
&TriggerAuthenticationList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
Loading