salaboy / knative-cloudevents-controller

Knative Controller which emits cloud events when Knative Resources change state
Apache License 2.0
2 stars 1 forks source link

Create a Knative Service Controller #2

Open salaboy opened 2 years ago

salaboy commented 2 years ago

Based on #1 Let's create a simple controller inside this project that watch Knative Services and emit a CloudEvent when a new Knative Service is created:

You can follow the following examples inside the tekton controller which creates a "Controller" and a "Reconciler"

https://github.com/tektoncd/experimental/blob/main/cloudevents/pkg/reconciler/pipelinerun/controller.go#L39

https://github.com/tektoncd/experimental/blob/main/cloudevents/pkg/reconciler/pipelinerun/reconciler.go#L75

The reconciler emits the event in the linked line.

The controller register the watches for the resources that we are interested.

salaboy commented 2 years ago

This is where all gets instantiated.. meaning this is what is going to be executed inside the docker container that ko will generate: https://github.com/tektoncd/experimental/blob/main/cloudevents/cmd/controller/main.go#L27

salaboy commented 2 years ago

As mentioned in #1 this is a Kubernetes controller that don't manage any new CRD, it just monitors existing CRDs, I think this is an important distinction to be made here.