From 39d4d11439c5abee7e4d8bb867a34baebd9d49d7 Mon Sep 17 00:00:00 2001 From: SpiritZhou Date: Tue, 28 Nov 2023 14:02:23 +0800 Subject: [PATCH] feat: Introduce CloudEventSources CRD and adding ClusterName parameter (#572) * Add CloudEventSources Crd and ClustetName Parameter Signed-off-by: SpiritZhou * Update Signed-off-by: SpiritZhou * Update Signed-off-by: SpiritZhou * Update keda/values.yaml Co-authored-by: Tom Kerkhove Signed-off-by: SpiritZhou * Fix Signed-off-by: SpiritZhou * Update Signed-off-by: SpiritZhou * Revert unnecessary update Signed-off-by: SpiritZhou --------- Signed-off-by: SpiritZhou Co-authored-by: Tom Kerkhove --- .github/workflows/ci-core.yml | 6 ++ keda/README.md | 1 + .../templates/crds/crd-cloudeventsources.yaml | 96 +++++++++++++++++++ keda/templates/manager/clusterrole.yaml | 7 ++ keda/templates/manager/deployment.yaml | 1 + keda/values.yaml | 3 + 6 files changed, 114 insertions(+) create mode 100644 keda/templates/crds/crd-cloudeventsources.yaml diff --git a/.github/workflows/ci-core.yml b/.github/workflows/ci-core.yml index a61cb5f8..1ef65a51 100644 --- a/.github/workflows/ci-core.yml +++ b/.github/workflows/ci-core.yml @@ -197,6 +197,9 @@ jobs: - name: Verify scaledobjects.keda.sh CRD is installed run: kubectl get crd/scaledobjects.keda.sh -o wide + + - name: Verify cloudeventsources.eventing.keda.sh CRD is installed + run: kubectl get crd/cloudeventsources.eventing.keda.sh -o wide - name: Get all ScaledObjects run: kubectl get scaledobjects -o wide @@ -210,6 +213,9 @@ jobs: - name: Get all ClusterTriggerAuthentication run: kubectl get clustertriggerauth -o wide + - name: Get all CloudEventSource + run: kubectl get cloudeventsource -o wide + - name: Deploy Nginx with autoscaling run: kubectl apply -f ./samples/nginx-scaledobject.yml diff --git a/keda/README.md b/keda/README.md index 82a4c8be..c3317266 100644 --- a/keda/README.md +++ b/keda/README.md @@ -70,6 +70,7 @@ their default values. | `certificates.mountPath` | string | `"/certs"` | Path where KEDA TLS certificates are mounted | | `certificates.secretName` | string | `"kedaorg-certs"` | Secret name to be mounted with KEDA TLS certificates | | `clusterDomain` | string | `"cluster.local"` | Kubernetes cluster domain | +| `clusterName` | string | `"kubernetes-default"` | Kubernetes cluster name. Used in features such as emitting CloudEvents | | `crds.install` | bool | `true` | Defines whether the KEDA CRDs have to be installed or not. | | `env` | list | `[]` | Additional environment variables that will be passed onto all KEDA components | | `extraObjects` | list | `[]` | Array of extra K8s manifests to deploy | diff --git a/keda/templates/crds/crd-cloudeventsources.yaml b/keda/templates/crds/crd-cloudeventsources.yaml new file mode 100644 index 00000000..58b491c1 --- /dev/null +++ b/keda/templates/crds/crd-cloudeventsources.yaml @@ -0,0 +1,96 @@ +{{- if .Values.crds.install }} +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.13.0 + labels: + app.kubernetes.io/name: {{ .Values.operator.name }} + {{- include "keda.labels" . | indent 4 }} + name: cloudeventsources.eventing.keda.sh +spec: + group: eventing.keda.sh + names: + kind: CloudEventSource + listKind: CloudEventSourceList + plural: cloudeventsources + singular: cloudeventsource + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=="Active")].status + name: Active + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: CloudEventSource defines how a KEDA event will be sent to event + sink + 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: CloudEventSourceSpec defines the spec of CloudEventSource + properties: + clusterName: + type: string + destination: + description: Destination defines the various ways to emit events + properties: + http: + properties: + uri: + type: string + required: + - uri + type: object + type: object + required: + - destination + type: object + status: + description: CloudEventSourceStatus defines the observed state of CloudEventSource + properties: + conditions: + description: Conditions an array representation to store multiple + Conditions + items: + description: Condition to store the condition state + properties: + message: + description: A human readable message indicating details about + the transition. + type: string + reason: + description: The reason for the condition's last transition. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: Type of condition + type: string + required: + - status + - type + type: object + type: array + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} +{{- end -}} diff --git a/keda/templates/manager/clusterrole.yaml b/keda/templates/manager/clusterrole.yaml index 0242a03f..d5cff9d6 100644 --- a/keda/templates/manager/clusterrole.yaml +++ b/keda/templates/manager/clusterrole.yaml @@ -99,6 +99,13 @@ rules: - leases verbs: - '*' +- apiGroups: + - eventing.keda.sh + resources: + - cloudeventsources + - cloudeventsources/status + verbs: + - '*' - apiGroups: - keda.sh resources: diff --git a/keda/templates/manager/deployment.yaml b/keda/templates/manager/deployment.yaml index d818aaf1..de67906b 100644 --- a/keda/templates/manager/deployment.yaml +++ b/keda/templates/manager/deployment.yaml @@ -91,6 +91,7 @@ spec: - "--operator-service-name={{ .Values.operator.name }}" - "--metrics-server-service-name={{ .Values.operator.name }}-metrics-apiserver" - "--webhooks-service-name={{ .Values.webhooks.name }}" + - "--k8s-cluster-name={{ .Values.clusterName }}" - "--k8s-cluster-domain={{ .Values.clusterDomain }}" {{- if .Values.prometheus.operator.enabled }} - "--metrics-bind-address=:{{ .Values.prometheus.operator.port }}" diff --git a/keda/values.yaml b/keda/values.yaml index feead77f..cbe2f70c 100644 --- a/keda/values.yaml +++ b/keda/values.yaml @@ -32,6 +32,9 @@ image: # -- Image pullPolicy for all KEDA components pullPolicy: Always +# -- Kubernetes cluster name. Used in features such as emitting CloudEvents +clusterName: kubernetes-default + # -- Kubernetes cluster domain clusterDomain: cluster.local