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

feat: Introduce CloudEvents to KEDA #4968

Merged
merged 69 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
18d3269
Update
SpiritZhou Sep 13, 2023
e41da36
Update
SpiritZhou Sep 14, 2023
79867ad
Update
SpiritZhou Sep 14, 2023
d1377e0
Update
SpiritZhou Sep 14, 2023
677765e
Update
SpiritZhou Sep 18, 2023
658dffa
Update
SpiritZhou Sep 19, 2023
2f24aff
Update
SpiritZhou Sep 20, 2023
77eda57
Merge branch 'main' into spiritzhou/cloudevent
SpiritZhou Sep 20, 2023
ab854e7
Merged update
SpiritZhou Sep 20, 2023
d89e24d
Update
SpiritZhou Sep 20, 2023
994a1e8
Update
SpiritZhou Sep 20, 2023
19c7c24
Update
SpiritZhou Sep 20, 2023
309a218
Update
SpiritZhou Sep 20, 2023
81d226c
Update
SpiritZhou Sep 20, 2023
b5acfb9
Update
SpiritZhou Sep 20, 2023
16e877c
Update
SpiritZhou Sep 21, 2023
56fa0e7
Update
SpiritZhou Sep 25, 2023
597105f
Fix
SpiritZhou Sep 25, 2023
e4da8a4
Merge branch 'main' into spiritzhou/cloudevent
SpiritZhou Sep 25, 2023
f1466dc
Fix
SpiritZhou Sep 25, 2023
158973c
Update pkg/eventemitter/eventemitter.go
SpiritZhou Sep 25, 2023
fd87e80
Update controllers/keda/cloudevent_controller.go
SpiritZhou Sep 25, 2023
517f9ad
Update
SpiritZhou Sep 25, 2023
a8f3edc
Add create handler failed checking
SpiritZhou Sep 25, 2023
d22b2dc
Update apis/keda/v1alpha1/cloudevent_types.go
SpiritZhou Sep 26, 2023
f0813e4
Fix
SpiritZhou Sep 26, 2023
4d73878
Update controllers/keda/cloudevent_finalizer.go
SpiritZhou Sep 26, 2023
70ce2a2
Update pkg/eventemitter/eventemitter.go
SpiritZhou Sep 26, 2023
a01888e
Fix
SpiritZhou Sep 26, 2023
540fa89
Update pkg/eventemitter/cloudevent_http_handler.go
SpiritZhou Sep 26, 2023
2ee77e3
Fix
SpiritZhou Sep 26, 2023
7a995e8
Update pkg/eventemitter/cloudevent_http_handler.go
SpiritZhou Sep 26, 2023
851887e
Fix
SpiritZhou Sep 26, 2023
e882aa6
Update
SpiritZhou Sep 26, 2023
99a5b8c
Merge branch 'main' into spiritzhou/cloudevent
SpiritZhou Oct 9, 2023
9b01fd4
Update
SpiritZhou Oct 9, 2023
663d0c8
Update
SpiritZhou Oct 11, 2023
8afd0c9
Update
SpiritZhou Oct 11, 2023
16c5b6d
Update
SpiritZhou Oct 11, 2023
8b2f458
Update
SpiritZhou Oct 11, 2023
0827887
Update
SpiritZhou Oct 11, 2023
cfc46c9
Update for a subgroup eventing.keda.sh
SpiritZhou Oct 12, 2023
d157829
Update
SpiritZhou Oct 12, 2023
c98ec0b
Fix
SpiritZhou Oct 12, 2023
f8aa5b4
Fix test
SpiritZhou Oct 12, 2023
f469644
Update
SpiritZhou Oct 12, 2023
46af8b2
Change CRD name to CloudEventSource
SpiritZhou Oct 13, 2023
61f2def
Add status in CloudEventSource
SpiritZhou Oct 17, 2023
9d4ea9f
Update sample
SpiritZhou Oct 17, 2023
42ee4fd
Fix pb files
SpiritZhou Oct 27, 2023
67ebee4
Update apis/eventing/v1alpha1/cloudeventsource_types.go
SpiritZhou Oct 27, 2023
005210c
Update
SpiritZhou Oct 30, 2023
1ac44ff
Update
SpiritZhou Oct 30, 2023
81524aa
Merge branch 'main' into spiritzhou/cloudevent
SpiritZhou Oct 31, 2023
783bc52
Update controllers/eventing/cloudeventsource_finalizer.go
SpiritZhou Oct 31, 2023
243c3f8
Update controllers/eventing/cloudeventsource_controller.go
SpiritZhou Oct 31, 2023
8608a1d
Update pkg/eventemitter/eventemitter.go
SpiritZhou Oct 31, 2023
0fe1af5
Update
SpiritZhou Nov 1, 2023
f499575
Add unittest
SpiritZhou Nov 9, 2023
2553796
Update
SpiritZhou Nov 9, 2023
5d99835
Update pkg/eventemitter/cloudevent_http_handler.go
SpiritZhou Nov 9, 2023
3786aff
Update
SpiritZhou Nov 9, 2023
c7f88a8
suggested improvements after PR review (#1)
josefkarasek Nov 13, 2023
b2ccf7d
Update
SpiritZhou Nov 13, 2023
03e47da
Update CHANGELOG.md
SpiritZhou Nov 17, 2023
98c2808
Add unit test
SpiritZhou Nov 17, 2023
145a96a
Update
SpiritZhou Nov 17, 2023
2048a9b
Update
SpiritZhou Nov 17, 2023
5b9ff56
Merge branch 'main' into spiritzhou/cloudevent
SpiritZhou Nov 20, 2023
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
71 changes: 71 additions & 0 deletions apis/keda/v1alpha1/cloudevents_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
Copyright 2021 The KEDA Authors

Licensed 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:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// CloudEvent defines how a trigger can authenticate globally
// +genclient
// +kubebuilder:resource:path=cloudevents,scope=Namespaced
// +kubebuilder:subresource:status
type CloudEvent struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec CloudEventSpec `json:"spec"`
}

// +kubebuilder:object:root=true

// CloudEventList is a list of CloudEvent resources
type CloudEventList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []CloudEvent `json:"items"`
}

// CloudEvent
type CloudEventSpec struct {
// +optional
ClusterName string `json:"clusterName,omitempty"`

// +optional
AzureEventGrid *AzureEventGridSpec `json:"azureEventGrid,omitempty"`
}

type AzureEventGridSpec struct {
EndPoint string `json:"endPoint"`

Key string `json:"key"`

TopicName string `json:"topicName"`

SubscriptionName string `json:"subscriptionName"`
}

func init() {
SchemeBuilder.Register(&CloudEvent{}, &CloudEventList{})
}

// GenerateIdentifier returns identifier for the object in for "kind.namespace.name"
func (t *CloudEvent) GenerateIdentifier() string {
return GenerateIdentifier("CloudEvent", t.Namespace, t.Name)
}
93 changes: 93 additions & 0 deletions apis/keda/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
kedav1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1"
kedacontrollers "github.com/kedacore/keda/v2/controllers/keda"
"github.com/kedacore/keda/v2/pkg/certificates"
"github.com/kedacore/keda/v2/pkg/eventemitter"
"github.com/kedacore/keda/v2/pkg/k8s"
"github.com/kedacore/keda/v2/pkg/metricsservice"
"github.com/kedacore/keda/v2/pkg/scaling"
Expand Down Expand Up @@ -178,6 +179,7 @@ func main() {

globalHTTPTimeout := time.Duration(globalHTTPTimeoutMS) * time.Millisecond
eventRecorder := mgr.GetEventRecorderFor("keda-operator")
eventEmitter := eventemitter.NewEventEmitter(mgr.GetClient(), eventRecorder)

kubeClientset, err := kubernetes.NewForConfig(cfg)
if err != nil {
Expand Down Expand Up @@ -208,6 +210,7 @@ func main() {
Recorder: eventRecorder,
ScaleClient: scaleClient,
ScaleHandler: scaledHandler,
EventEmitter: *eventEmitter,
}).SetupWithManager(mgr, controller.Options{
MaxConcurrentReconciles: scaledObjectMaxReconciles,
}); err != nil {
Expand Down Expand Up @@ -241,6 +244,13 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "ClusterTriggerAuthentication")
os.Exit(1)
}
if err = (&kedacontrollers.CloudEventsReconciler{
Client: mgr.GetClient(),
EventEmitter: *eventEmitter,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "CloudEvents")
os.Exit(1)
}
//+kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
Expand Down
62 changes: 62 additions & 0 deletions config/crd/bases/keda.sh_cloudevents.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.12.0
name: cloudevents.keda.sh
spec:
group: keda.sh
names:
kind: CloudEvent
listKind: CloudEventList
plural: cloudevents
singular: cloudevent
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: CloudEvent defines how a trigger can authenticate globally
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: CloudEvent
properties:
azureEventGrid:
properties:
endPoint:
type: string
key:
type: string
subscriptionName:
type: string
topicName:
type: string
required:
- endPoint
- key
- subscriptionName
- topicName
type: object
clusterName:
type: string
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
1 change: 1 addition & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ resources:
- bases/keda.sh_scaledjobs.yaml
- bases/keda.sh_triggerauthentications.yaml
- bases/keda.sh_clustertriggerauthentications.yaml
- bases/keda.sh_cloudevents.yaml
# +kubebuilder:scaffold:crdkustomizeresource

## ScaledJob CRD needs to be patched because for some usecases (details in the patch file)
Expand Down
7 changes: 7 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ rules:
- leases
verbs:
- '*'
- apiGroups:
- keda.sh
resources:
- cloudevents
- cloudevents/status
verbs:
- '*'
- apiGroups:
- keda.sh
resources:
Expand Down
12 changes: 12 additions & 0 deletions config/samples/keda_v1alpha1_cloudevents.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: keda.sh/v1alpha1
kind: CloudEvent
metadata:
name: cloudevents-sample
namespace: keda
spec:
clusterName: cluster-sample
azureEventGrid:
endPoint: https://eventgridtestnamespace.eastus-1.eventgrid.azure.net/
key: FXZBmVucowoeM/Kl0zNeDJHoyOZO+sXB+IeeE7S6aSg=
topicName: testtopicone
subscriptionName: 66a7fcba-dac3-46d8-b509-202f305618c8
Loading