Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jenkins Controller and Build Pods in different namespaces #705

Open
dee-kryvenko opened this issue Jan 31, 2022 · 6 comments
Open

Jenkins Controller and Build Pods in different namespaces #705

dee-kryvenko opened this issue Jan 31, 2022 · 6 comments
Labels
enhancement New feature or request not-stale
Milestone

Comments

@dee-kryvenko
Copy link

Need to be able to have build pods and jenkins controller in separate namespaces. Doesn't seem to be currently possible, which pose the risk of user-defined jobs to be able to construct such a pod that uses SA from controller so it can read secrets, amend controller pod etc. There are four separate roles in a typical shared k8s setup - cluster admins, operator admins, controller admins and jobs admins.

@dee-kryvenko dee-kryvenko added the enhancement New feature or request label Jan 31, 2022
@MKajzik MKajzik added this to the New API milestone Feb 1, 2022
@devdattakulkarni
Copy link

+1 From multi-tenancy perspective also this is an important requirement - that the Operator is able to support creating Jenkins instances in different namespaces.

@thecooldrop
Copy link

Hi @dee-kryvenko, could you provide more details as to why this is not possible? I am unable to come to the same conclusion as you

@dee-kryvenko
Copy link
Author

@thecooldrop because https://github.com/jenkinsci/kubernetes-operator/blob/v0.7.0/pkg/configuration/base/resources/base_configuration_configmap.go#L207 is clearly using jenkins.ObjectMeta.Namespace without any ability for the user to override it.

@github-actions github-actions bot added the stale label May 8, 2023
@dashashutosh24
Copy link

I was able to resolve this by creating a copy of the role and rolebinding from the namespace in which jenkins master resides in the namespace where I want the slave pods to run. In the rolebinding, I granted the master service account in the master namespace access to the role in the slave agent namespace.

@stale stale bot removed the stale label May 15, 2023
@brokenpip3
Copy link
Collaborator

I was able to resolve this by creating a copy of the role and rolebinding from the namespace in which jenkins master resides in the namespace where I want the slave pods to run. In the rolebinding, I granted the master service account in the master namespace access to the role in the slave agent namespace.

so you are saying that in your tests it's just a rbac issue because the jenkins operator does not have the grants to create pods, cm, secrets etc in the others namespace?

I never tried this, maybe it's something we can fix easily

@dashashutosh24
Copy link

dashashutosh24 commented May 18, 2023

Yes it seems it was only a permissions issue.
This could be the rolebinding in the slave build agents' namespace:

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: jenkins-operator-jenkins
  namespace: jenkins-slaves
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: jenkins-operator-jenkins
subjects:
- kind: ServiceAccount
  name: jenkins-operator-jenkins
  namespace: jenkins-operator

The role is an exact copy of the role in master's namespace with the same permissions and the rolebinding binds it with the serviceaccount used by master in it's own namespace.

@github-actions github-actions bot added the stale label Jul 17, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 28, 2023
@brokenpip3 brokenpip3 reopened this Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request not-stale
Projects
None yet
Development

No branches or pull requests

6 participants