ks-devops icon indicating copy to clipboard operation
ks-devops copied to clipboard

Research: invite event-driven

Open LinuxSuRen opened this issue 4 years ago • 8 comments

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

LinuxSuRen avatar Jul 20 '21 00:07 LinuxSuRen

/assign

mzmuer avatar Dec 16 '21 16:12 mzmuer

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.

mzmuer avatar Dec 17 '21 15:12 mzmuer

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.

JohnNiang avatar Dec 19 '21 03:12 JohnNiang

I'm having some problems。https://github.com/jenkinsci/cloudevents-plugin does not work properly. #13

mzmuer avatar Dec 22 '21 02:12 mzmuer

Reference:

  • https://github.com/kubesphere/ks-devops/blob/d3b19c56b6175c95293fb6c93ace8f053cb62046/controllers/jenkins/pipelinerun/pipelinerun_synchronizer.go#L26-L34

JohnNiang avatar Dec 28 '21 05:12 JohnNiang

                                              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│
       ║"│                 +│ │   )                            └───────│ │ │─────┘                         └───────┘
       └┬┘                 |│ │`-'                                     │ │ │                                        
       ┌┼┐                  │ │                                        │ │ │                                        
        │                   │ │                                        │ │ │                                        
       ┌┴┐                  │ │                                        │ │ │                                        
                            └┬┘                                        └┬└┬┘                                        

JohnNiang avatar Dec 30 '21 05:12 JohnNiang

image

JohnNiang avatar Dec 30 '21 06:12 JohnNiang

niubi

swh0318 avatar Mar 14 '23 07:03 swh0318