jenkins-x / jx

Jenkins X provides automated CI+CD for Kubernetes with Preview Environments on Pull Requests using Cloud Native pipelines from Tekton
https://jenkins-x.io/
Apache License 2.0
4.58k stars 789 forks source link

[v3][Security] Run pipelines in separate namespaces (multi-tenant / multi-team) #8060

Open keskad opened 2 years ago

keskad commented 2 years ago

Hi,

Thanks for this impressive and fascinating project. I'm currently doing a PoC of a CI/CD using Jenkins X and probably ArgoCD.

[Background] My setup needs to fullfil following conditions:

What I need to achieve:

Is this all possible? Any hints? :smile: Thank you for your time :smile:

keskad commented 2 years ago

I was looking for it a little bit (I may not have currently probably more time unfortunately) and I was checking this:

PipelineRun job is created there in a namespace, where LighthouseJob was found: https://github.com/jenkins-x/lighthouse/blob/main/pkg/engines/tekton/controller.go#L117

Later an owner reference is linked, it is not allowed cross-namespace, so it means a LighthouseJob must be in same namespace as PipelineRun: https://github.com/jenkins-x/lighthouse/blob/main/pkg/engines/tekton/controller.go#L123

Also I found out that LighthouseJob itself has namespace in spec: but I don't know for what purpose it is. It can be set using triggers.yaml in repository, but I didn't see any difference, anyway setting a namespace from project repository is not my case as I don't want to give end-users a namespace selection for security reasons.

So... maybe a lighthouse-webhook that spawns LighthouseJob should be aware of namespace condition and spawn LighthouseJob in a proper namespace? I don't know where the namespace could be defined? Maybe in kind: SourceConfig?

keskad commented 2 years ago

Linked PR: https://github.com/jenkins-x/lighthouse/pull/1424