Scope to implement Jenkins As A Service (JAAS)

Hello Community…

Our organization currently maintains ~60 standalone Jenkins instances (30 test, 30 production), each managed independently by a single resource. This creates significant operational overhead, inconsistent security controls, wasted compute from always-on static agents, and a growing backlog of manual on-demand agent requests with no centralized visibility across projects.

The proposal is to consolidate all 60 instances into a single, centralized, highly available Jenkins platform deployed on Kubernetes — while keeping each project team fully isolated and governed through project-scoped folders with RBAC enforced via the Role Strategy Plugin, synced to our org’s identity provider (LDAP/SSO). Teams get their own space with defined roles (admin, developer, viewer) without any cross-project access.

Agent provisioning shifts from static and manual to fully on-demand using the Kubernetes Plugin — agents are spun up as ephemeral pods per job and automatically destroyed the moment the job completes, eliminating idle compute costs entirely. Logs and artifacts are preserved externally before pod teardown, so no build history is lost.

Auto-scaling operates at two levels — agent pods scale horizontally per job load, and the underlying Kubernetes cluster nodes scale up or down automatically based on pending workload, requiring zero manual intervention during demand spikes.

Monitoring covers four layers — Jenkins controller health, agent pool metrics, job/pipeline analytics, and plugin security — using a Prometheus + Grafana stack for live dashboards and EFK/Loki for historical log search and audit trails.

Is there anyone with the same requirement?
Can anyone please suggest me with any existing solution for such…

Thanks in advance
Abinash

Some considerations:

  • a single instance is a single point of failure, if it is down it is down for all
  • With Role based strategy you need to be admin to change any permission (though you can enable item role management now for non admins, enabled via a system property)
  • A big instance needs quite some memory depending on how many jobs and runs you have and how busy it is. It needs considerably longer to start up
  • static agents can make sense, it depends on what you use Jenkins for. E.g. we have several jobs that run once per minute, those run on static agents. We also have static agents for e.g. ppc64le where we have no kubernetes running
  • Just to be sure, Jenkins is single node. You can’t spin up 2 instances in kubernetes that share the same JENKINS_HOME. Afaik cloudbees has something here for HA setups.

PS the term JaaS is a bit misleading for this service I think. We have also JaaS offering that means, you click a button and a Jenkins instance is created for you in a kubernetes cluster, preconfigured with SAML and a bunch of plugins. Afaik we have around 4000 instances there.

  • a single instance is a single point of failure, if it is down it is down for all
    → True: Once model is ready then for another phase HA needs to be planned
  • With Role based strategy you need to be admin to change any permission (though you can enable item role management now for non admins, enabled via a system property)
    → Infra team who will be setting up this configuraiton will be the admin and they will have all the permisisons.
    But individual team for whom there is standalone jenkins server for them it should be isolated to their jobs based on dashboard something kind. This dashboard will have only their jobs
    Individual dashboard can have individual admins
  • A big instance needs quite some memory depending on how many jobs and runs you have and how busy it is. It needs considerably longer to start up
    → true: for jenkins controller/controller this will be huge depending upon the volume of instances which will be converged into it.
    This needs to be planned as per k8 scale up and scale down tech
  • static agents can make sense, it depends on what you use Jenkins for. E.g. we have several jobs that run once per minute, those run on static agents. We also have static agents for e.g. ppc64le where we have no kubernetes running
    → what if static agent can be parked considering docker agent or k8 agents on demand.
    Once jobs are invoked it will create image/node executes the jobs if successful then it will destroy the image/node, if it fails then it will not destroy
  • Just to be sure, Jenkins is single node. You can’t spin up 2 instances in kubernetes that share the same JENKINS_HOME. Afaik cloudbees has something here for HA setups.
    → cloudbees is enterprise one and org will not invest on it. :sweat_smile:

PS the term JaaS is a bit misleading for this service I think. We have also JaaS offering that means, you click a button and a Jenkins instance is created for you in a kubernetes cluster, preconfigured with SAML and a bunch of plugins. Afaik we have around 4000 instances there.

→ Can you please provide me the contest or the material for the same so I can proceed to configure and check

Did I maybe misunderstand your plans. I had the impression that you intend to setup a single Jenkins instance that will host all jobs for all teams. Or is your plan to still have 60 Jenkins instances but unify the setup that each Jenkins runs in it’s own kubernetes cluster?

Plan is to have single jenkins controller which will be segregated based upon dashboards(view) using RBAC. Each dashboard will be applied to each team and it will be completely isolated

Not sure this plan can be achieved or not.
But feel free to give your suggestion for any alternative ways to achieve it

Views are a bit special when it comes to accessing them. You should not grant View/Read globally to users, otherwise all users can see all views. Without that permission views are visible to users that can see at least one job in the view or that have configure permission for the view.
You already wrote that you want to separate teams with folders that is the way to go. When each team sees only its own folder then you don’t need views on Jenkins root. The teams have only one thing they can navigate to and inside their folder they see then everything (or what they are allowed to see when this is further restricted in a folder). As each team might want to define their own views, those should be views in the folder and not global ones.

As written a single instance makes sense when the number of jobs is not too large. From my experience a practical limit is around 10_000 jobs.

2 Likes

Thanks @mawinter69 , Really appreciating your review on this.

Can you please let me know how can I design/architect this plan and start from ground zero.
Once things are started then we can enhance it as per need.

Your idea and expertise here will be rewarding for me

I think there’s a misconception repeated within the Jenkins community based on conference materials. The misconception is a single controller is a bad idea and that it doesn’t handle lots of jobs or lots of agents very well. Jenkins can scale up to operate for a global company. I’ve done it at two separate companies.

Current setup: I operate a similar JaaS and it currently has 256,000 jobs. It operates on c7g.4xlarge (arm64 32GB RAM) and its startup time is a little under 5 minutes. It uses a mix of Job DSL, config as code, multibranch pipelines, and (more recently to my woes) organization job types. My 256k job count is the count of WorkflowJob count (of which a multibranch pipeline would have more than one).

Put another way: over 4000 engineers can collaborate through a single Jenkins controller if carefully designed. I have achieved this.

Over the years I’ve put out patches that make “one Jenkins instead of many” more and more reliable. Whether lots of GitHub retries with jitter backoff in plugins, the “ludicrous mode” patch series or more recently my EC2 work and unblocking parallelism in sshagent and docker plugins.

How Jenkins could be better: Jenkins can scale even further for less if work on org jobs migrated to graphql instead of REST. The information GitHub org jobs consumes for orgs with over 1000 repositories amounts to 10k+ REST API calls. The same information obtained from graphql can be obtained for 100 API calls in a few seconds compared to REST.

It is my professional opinion that rolling out many Jenkins instances is a design mistake and not to be encouraged. Jenkins (the community) should start looking more at how it handles its own internal config to stop using JVM memory dumps to XML and instead something a little more modern where HA can be achieved.

Even without active-active HA you can easily have cold-failover HA. My controller is hosted in EC2 with an autoscaling group (desired capacity = 1, max capacity = 1). My Jenkins downtime is usually the result of a GitHub outage (more recently) as opposed to blaming Jenkins itself. It serves a globally distributed company with offices in US, EU, Asia (single controller hosted in US).

The biggest challenge which faces @Abinash is not that Jenkins can’t achieve the scale… in order to achieve that scale you tend to need more than the technical expertise. You’re going to need the political will from leadership top-down and people to understand… because migrating such a design you’ve described is a multi-year project that requires social coordination as much as it does migration of process.

Examples:

  • Forcing everyone into the same workflow.
  • DRYing up the process with a shared pipeline library.
  • Credentials need to be workflow-aware. e.g. different environments get different creds (PRs shouldn’t deploy to all of prod… prod can only happen in a specific stage in a tag pipeline).
  • Managing a process for handling credentials. e.g. there needs to be as many AWS roles as there are projects (or in some cases a role can be shared for a group of projects).
  • With said AWS roles ephemeral credentials issuing ephemeral credentials via Amazon STS on the fly in pipelines so the deploy creds expire.
  • GitHub credentials that are ephemeral.
  • Other systems like databricks credentials which can be ephemeral through service principals.

Basically, a “Jenkins at scale” means as admin for an entire organizations productivity you have to be enabled to enact change. You have to sell the idea of the migration in a way that provides value.

That’s just the tip of the iceberg. I’ve written plugins which exports Jenkins logs to artifact hosts so that strict cleanup policies can be enacted to keep Jenkins running fast (like pull requests are deleted older than two weeks, etc). Automated offboarding like when repos are archived. Required Jira tracking where pull requests are not allowed to be merged without work attached to a ticket.

To roll something like this when you already have a system that’s limping but works (like 60 controllers) takes A LOT of buy in for you to be able to force it through where there’s resistance. Executives need to be willing to interrupt product work (and override teams that are unwilling with the excuse of product work which usually is a pretty good excuse).

It is do-able I am just sharing some difficulties having done it. Good luck!

1 Like

@mawinter69 @samrocketman
I have vms ready
8 vms with 4gb memory, 8cpu, 200gb storage, rhel8 in rach vm.

Is there any repo which I can follow for this setup.
Or can you provide some material which can guide me to achieve it

I’m not aware of any public repo. I guess most people that main Jenkins config in a repo do this in locally hosted places or private repos.

I can only share what we did (not based on kubernetes, that setup no longer exists), we had a bunch of repos for different purposes. All agents static, 100% configuration as code (without the plugin as that setup predates the plugin)

  • One repo for building docker images with the Jenkins version and all required plugins fixed. We could build different images for different purposes (different sets of plugins)
  • One repo that created an RPM with systemd services to start and stop Jenkins instances with side containers ( when starting a Jenkins it first called a container that runs ansible to configure the instance), you start instance with systemctl start jenkins@instance_id
  • One repo with the configuration for the Jenkins instances, ansible config with all relevant parts in xml files (excluding agents), also secrets, restart the service and any changes of the core config (not jobs and user config) are lost
  • one repo that describes the agents. Add an agent there and it is automatically added via Jenkins job
  • one repo with job configurations (not based on Job DSL), we have an own Job Generator

The setup was 100% configuration as code. Even when the JENKINS_HOME would be lost and no backup, we could recreate everything within 1h (most of that time was the job generation), we never needed to do though.

1 Like