Research: invite event-driven
Event-driven might be an alternative way to interact with another system, such as Jenkins.
Currently, the DevOps controller calls Jenkins API. So, we need to maintain the Jenkins client. With event-driver, we might be able to decouple the Jenkins client.
As I mentioned in the title, this still is a research topic. Before we have any actions, there's a lot of research work need to do. Please join us, you're interested in this area.
References
- https://github.com/jenkinsci/cloudevents-plugin
- https://cloudevents.io/
- https://github.com/cloudevents/sdk-go
- Event SIG in CDF
- https://github.com/argoproj/argo-events
/assign
https://github.com/jenkinsci/cloudevents-plugin requires Jenkins version 2.277.4. I'm trying to find an alternative plugin.
Also, I use webhook as event-source verified the flow of Argo-events. I think Argo-events can be our event bus, It brings us closer to cloud native. Then I'm thinking how can I abstract out this process and provide an implementation other than Reconcile.
Hi @mzmuer , Jenkins has been bumped to 2.319.1, please see https://github.com/kubesphere/ks-jenkins/pull/61. You can use docker image kubespheredev/ks-jenkins:master or ghcr.io/kubesphere/ks-jenkins:master to test it.
One thing you need to pay attention to is that the JVM options of Jenkins need to be adjusted according to this, because the new version of Jenkins use JDK 11.
I'm having some problems。https://github.com/jenkinsci/cloudevents-plugin does not work properly. #13
Reference:
- https://github.com/kubesphere/ks-devops/blob/d3b19c56b6175c95293fb6c93ace8f053cb62046/controllers/jenkins/pipelinerun/pipelinerun_synchronizer.go#L26-L34
Event Driven Sequence Diagram
┌─┐
║"│
└┬┘
┌┼┐ | ,-.
│ +--{ ) ┌─────────────────┐ ┌───────┐
┌┴┐ | `-' │DevOps Controller│ │Jenkins│
User Devops APIServer └─────────────────┘ └───────┘
│ 𝟏 Run a Pipeline ┌┴┐ │ │
│ ──────────────────>│ │ │ │
│ │ │ │ │
│ │ │────┐ │ │
│ │ │ │ 𝟐 Create a CR: PipelineRun │ │
│ │ │<───┘ │ │
│ └┬┘ │ │
│ 𝟑 Response: │ │ │
│ Run Successfully │ │ │
│ <─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ ─ ─ ┐
│ │ │ | 𝟒 Received PipelineRun creation
. . . < ─ ┘
. . . .
. . . .
. . . .
│ │ │ 𝟓 Trigger Jenkins build ┌┴┐
│ │ │ ───────────────────────────────────>│ │
│ │ │ │ │
│ │ │ 𝟔 Response: Created successfully │ │
│ │ ┌┴┐<───────────────────────────────────│ │
│ │ │ │ └┬┘
│ ┌┴┐ 𝟕 Fire an event: job:started/completed/finalized/failed │
│ │ │ <──────────────────────────────────────────────────────────────────────────────│
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │────┐ │ │ │
│ │ │ │ 𝟖 Change corresponding PipelineRun│ │ │
│ │ │<───┘ to make controller reconcile again│ │ │
│ └┬┘ └┬┘ │
│ │ │ │
│ │ │ │
│ │ │ ─ ─ ┐
│ │ │ | 𝟗 Received PipelineRun update
. ┌┴┐ ┌┴┐ < ─ ┘
. │ │ │ │ .
. │ │ │ │ .
. │ │ │ │ .
│ │ │ │ │ 𝟏𝟎 Query Jenkins build ┌┴┐
│ │ │ │ │ ─────────────────────────────────> │ │
│ │ │ │ │ └┬┘
│ │ │ │ │ 𝟏𝟏 Response: Jenkins build detail │
│ │ │ │ ┌┴<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─│
│ │ │ │ │ │ │
│ │ │ │ │ │ │
│ │ │ │ │ │─ ─ ┐ │
│ │ │ │ │ │ | 𝟏𝟐 Reconcile the PipelineRun │
User Devops│ │IServer ┌───────│ │ │< ─ ┘ ─────┐
┌─┐ |│ │,-. │DevOps │ │ │oller│ │Jenkins│
║"│ +│ │ ) └───────│ │ │─────┘ └───────┘
└┬┘ |│ │`-' │ │ │
┌┼┐ │ │ │ │ │
│ │ │ │ │ │
┌┴┐ │ │ │ │ │
└┬┘ └┬└┬┘

niubi