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

Introduce CloudEvent to KEDA #1227

Merged
merged 17 commits into from
Nov 23, 2023
45 changes: 45 additions & 0 deletions content/docs/2.12/operate/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,48 @@ KEDA emits the following [Kubernetes Events](https://kubernetes.io/docs/referenc
| `TriggerAuthenticationDeleted` | `Normal` | When a TriggerAuthentication is deleted |
| `ClusterTriggerAuthenticationAdded` | `Normal` | When a new ClusterTriggerAuthentication is added |
| `ClusterTriggerAuthenticationDeleted` | `Normal` | When a ClusterTriggerAuthentication is deleted |

## CloudEvent Support

### CloudEvent Resource
`CloudEvent` resource now can be created in KEDA for emitting events to user's custom CloudEvent sink. Both Kubernetes Events and CloudEvents will be emitted if CloudEvent resource is created. This specification describes the `CloudEvent` Custom Resource definition:

[`cloudevent_types.go`](https://github.com/kedacore/keda/blob/v1.4.0/pkg/apis/keda/v1alpha1/cloudevent_types.go)

```yaml
apiVersion: keda.k8s.io/v1alpha1
kind: CloudEvent
metadata:
name: {cloud-event-name}
spec:
clusterName: {cluster-name} #Optional. Will be used in source/subject
SpiritZhou marked this conversation as resolved.
Show resolved Hide resolved
destination:
http:
uri: http://foo.bar
```

In general, an event emitted by KEDA would fundamentally come down to the following structure:
```json
{
"specversion" : "1.0",
"type" : "com.cloudevents.keda",
"source" : "/{cluster-name}/{namespace}/keda",
"subject" : "/{cluster-name}/{namespace}/workload/{scaledobject-name}",
"id" : "<guid>",
"time" : "2018-04-05T17:31:00Z",
"datacontenttype" : "application/json",
"data" : {
"reason":"<event-reason>",
"message":"<event-message>"
}
}
```

### Destination
There will be multiple type of destination to emit KEDA events. Nowadays an HTTP CloudEvent destination is supported.
#### CloudEvent HTTP
```yaml
destination:
http:
uri: http://foo.bar #An http endpoint that can receive cloudevent
```
tomkerkhove marked this conversation as resolved.
Show resolved Hide resolved