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
86 changes: 66 additions & 20 deletions content/docs/2.13/operate/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,69 @@ weight = 100

KEDA emits the following [Kubernetes Events](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#event-v1-core):

| Event | Type | Description |
| ------------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------- |
| `ScaledObjectReady` | `Normal` | On the first time a ScaledObject is ready, or if the previous ready condition status of the object was `Unknown` or `False` |
| `ScaledJobReady` | `Normal` | On the first time a ScaledJob is ready, or if the previous ready condition status of the object was `Unknown` or `False` |
| `ScaledObjectCheckFailed` | `Warning` | If the check validation for a ScaledObject fails |
| `ScaledJobCheckFailed` | `Warning` | If the check validation for a ScaledJob fails |
| `ScaledObjectDeleted` | `Normal` | When a ScaledObject is deleted and removed from KEDA watch |
| `ScaledJobDeleted` | `Normal` | When a ScaledJob is deleted and removed from KEDA watch |
| `KEDAScalersStarted` | `Normal` | When Scalers watch loop have started for a ScaledObject or ScaledJob |
| `KEDAScalersStopped` | `Normal` | When Scalers watch loop have stopped for a ScaledObject or a ScaledJob |
| `KEDAScalerFailed` | `Warning` | When a Scaler fails to create or check its event source |
| `KEDAScaleTargetActivated` | `Normal` | When the scale target (Deployment, StatefulSet, etc) of a ScaledObject is scaled to 1 |
| `KEDAScaleTargetDeactivated` | `Normal` | When the scale target (Deployment, StatefulSet, etc) of a ScaledObject is scaled to 0 |
| `KEDAScaleTargetActivationFailed` | `Warning` | When KEDA fails to scale the scale target of a ScaledObject to 1 |
| `KEDAScaleTargetDeactivationFailed` | `Warning` | When KEDA fails to scale the scale target of a ScaledObject to 0 |
| `KEDAJobsCreated` | `Normal` | When KEDA creates jobs for a ScaledJob |
| `TriggerAuthenticationAdded` | `Normal` | When a new TriggerAuthentication is added |
| `TriggerAuthenticationDeleted` | `Normal` | When a TriggerAuthentication is deleted |
| `ClusterTriggerAuthenticationAdded` | `Normal` | When a new ClusterTriggerAuthentication is added |
| `ClusterTriggerAuthenticationDeleted` | `Normal` | When a ClusterTriggerAuthentication is deleted |
| Event | Type | Description | CloudEvent Support |
| ------------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------- | ---- |
| `ScaledObjectReady` | `Normal` | On the first time a ScaledObject is ready, or if the previous ready condition status of the object was `Unknown` or `False` | YES |
| `ScaledJobReady` | `Normal` | On the first time a ScaledJob is ready, or if the previous ready condition status of the object was `Unknown` or `False` | NO |
| `ScaledObjectCheckFailed` | `Warning` | If the check validation for a ScaledObject fails | YES | |
| `ScaledJobCheckFailed` | `Warning` | If the check validation for a ScaledJob fails | NO | |
| `ScaledObjectDeleted` | `Normal` | When a ScaledObject is deleted and removed from KEDA watch | NO | |
| `ScaledJobDeleted` | `Normal` | When a ScaledJob is deleted and removed from KEDA watch | NO | |
| `KEDAScalersStarted` | `Normal` | When Scalers watch loop have started for a ScaledObject or ScaledJob | NO | |
| `KEDAScalersStopped` | `Normal` | When Scalers watch loop have stopped for a ScaledObject or a ScaledJob | NO | |
| `KEDAScalerFailed` | `Warning` | When a Scaler fails to create or check its event source| NO | |
| `KEDAScaleTargetActivated` | `Normal` | When the scale target (Deployment, StatefulSet, etc) of a ScaledObject is scaled to 1| NO | |
| `KEDAScaleTargetDeactivated` | `Normal` | When the scale target (Deployment, StatefulSet, etc) of a ScaledObject is scaled to 0 | NO | |
| `KEDAScaleTargetActivationFailed` | `Warning` | When KEDA fails to scale the scale target of a ScaledObject to 1| NO | |
| `KEDAScaleTargetDeactivationFailed` | `Warning` | When KEDA fails to scale the scale target of a ScaledObject to 0| NO | |
| `KEDAJobsCreated` | `Normal` | When KEDA creates jobs for a ScaledJob | NO | |
| `TriggerAuthenticationAdded` | `Normal` | When a new TriggerAuthentication is added| NO | |
| `TriggerAuthenticationDeleted` | `Normal` | When a TriggerAuthentication is deleted| NO | |
| `ClusterTriggerAuthenticationAdded` | `Normal` | When a new ClusterTriggerAuthentication is added| NO | |
| `ClusterTriggerAuthenticationDeleted` | `Normal` | When a ClusterTriggerAuthentication is deleted| NO | |


## CloudEvent Support (Experimental)
SpiritZhou marked this conversation as resolved.
Show resolved Hide resolved

### CloudEventSource Resource
tomkerkhove marked this conversation as resolved.
Show resolved Hide resolved
`CloudEventSource` resource now can be created in KEDA for emitting events to user's custom CloudEvent sink. Event will be emitted to both Kubernetes Events and CloudEvents Destination if CloudEventSource resource is created. This specification describes the `CloudEventSource` Custom Resource definition:
SpiritZhou marked this conversation as resolved.
Show resolved Hide resolved
SpiritZhou marked this conversation as resolved.
Show resolved Hide resolved

[`cloudeventsource_types.go`](https://github.com/kedacore/keda/blob/v2.13.0/pkg/apis/keda/v1alpha1/cloudeventsource_types.go)
SpiritZhou marked this conversation as resolved.
Show resolved Hide resolved

```yaml
apiVersion: eventing.keda.k8s.io/v1alpha1
tomkerkhove marked this conversation as resolved.
Show resolved Hide resolved
kind: CloudEventSource
metadata:
name: {cloud-event-name}
spec:
clusterName: {cluster-name} #Optional. Will be used in the source/subject to specify where the event comes from. The default value is 'kubernetes-default' and it can also be set during the installation of KEDA with --k8sClusterName. This one will overwrite others if set.
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.cloudeventsource.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
SpiritZhou marked this conversation as resolved.
Show resolved Hide resolved
tomkerkhove marked this conversation as resolved.
Show resolved Hide resolved
```yaml
destination:
http:
uri: http://foo.bar #An http endpoint that can receive cloudevent
```