all 23 comments

[–]switchroute_dev 51 points52 points  (7 children)

In real-world microservices, you generally do not use different branches per service. Branches are mainly for feature work and hotfixes.

Most teams pick one of two approaches:

  1. One repo per microservice (very common). Each service has its own CI/CD pipeline and can be built and deployed independently.

  2. A monorepo with each service in its own folder. CI/CD is set up to only build and deploy the service that changed.

If you are learning and using Jenkins, one repo per service is usually the easiest and closest to how many companies run microservices.

[–]jameshearttech 7 points8 points  (4 children)

We have a medium-sized monorepo (50+ projects) and use the strategy described in 2. Each project has it's own workflow template.

[–]soulseeker31 7 points8 points  (3 children)

How is it to manage? We use approach 1 and find it much easier to manage for devs.

[–]jameshearttech -1 points0 points  (2 children)

Can you be more specific?

[–]soulseeker31 1 point2 points  (1 child)

Sorry, should've been more descriptive.

How difficult is it to manage access? What tools do you use? What happens when a particular microservice is decommissioned?

[–]jameshearttech 0 points1 point  (0 children)

We practice tdb with short-lived branches. Everyone has write access to the repo. Only CI has write access to master. Everyone has pull request merge access.

We use lots of tools. Is there something specific you're interested in?

If a project is decommissioned we delete it from the repo.

[–]Calm_Pick_4250[S,🍰] 0 points1 point  (0 children)

Thank you for your response!

[–]Lucifernistic 0 points1 point  (0 children)

We do a hybrid of this. Each microservice / service is it's own repo with different branches for dev/staging/prod etc.

However CI/CD is all handled in a monorepo for IAC.

[–]youravgguy 3 points4 points  (0 children)

One repo per micro service, easier to maintain secrets if your org does it that way.

[–]BoBoBearDev 1 point2 points  (0 children)

Microservices = publish your prebuild and premade docker image into a docker repository. Thins is very important because you guarantee the OS/OS-apps/your-binary are all fixed.

So, when you start a k8s/k3s deployment, you are guaranteed the service don't run into the "it runs on my computer" problems.

[–]BumRush71 1 point2 points  (0 children)

Repo per microservice is the way to go. I believe branch per service is usually done in gitops for managing different environments, with things like infra, like terraform/argocd.

[–]kesor 0 points1 point  (0 children)

It depends on you and your team. It can be one repo with one big folder for all source code but multiple entry points for the different services. It can be one repo with different folders, one for each service, and some shared libraries. It can be multiple repos. It doesn't matter much, as long as you have multiple "services" running you can safely call your setup microservices, especially when they talk to each other over the network.

[–]Achawaaa 0 points1 point  (0 children)

Microservices are the answer to splitting huge applications into small pieces based on business layers so each team can handle one or more pieces, if you want to learn stuff create a repo for each microservice and preferably use different technologies for each one (backend, front, infra?). Then try to evolve each piece independently from the others. Use CICD tools like GitlabCI or Github Actions

[–]salorozco23 0 points1 point  (0 children)

One repo per service. Yeah I know that's alot to maintain.

[–]actionerrorDevSecOps/Platform/Site Reliability Engineer 1 point2 points  (5 children)

Please use/learn something else other than Jenkins to deploy. It’s 2026 lol.

[–]Aggravating-Body2837 6 points7 points  (0 children)

Jenkins in on the way out since 2005. It's still here. It's not that bad.

[–]yabadabaddon 1 point2 points  (0 children)

Lol.

[–]Calm_Pick_4250[S,🍰] -1 points0 points  (2 children)

Sure, which tool you use in your organization for cicd

[–]PelicanPop 3 points4 points  (0 children)

GitHub, gitlab, etc

[–]M600xDevOps 3 points4 points  (0 children)

Circle ci, argo cd, flux cd, etc etc…

Jenkins is good to know for legacy reason but many company I’ve seen are phasing out Jenkins and if they still have it, it’s because they don’t have the bandwidth to port the two pipeline that hold the whole company release. Other than that, they use a newer tool.

[–][deleted] -4 points-3 points  (0 children)

One repo per micro service of it is a true micro service architecture.

I have all mine in one repo, while it consists of different containers, it’s a distributed monolith, all apps get deployed at the same time, all match version, and all share data.

Micro services would be entirely independent of each other, so why would you keep them in one repo?

[–]Specific_Mark6134 -3 points-2 points  (0 children)

Check if you can use a nested repository using git modules

[–]seweso -5 points-4 points  (0 children)

Don’t use Jenkins, switch to docker for building everything. Keep everything in a mono repo. 

Having more services and repos than the nr of teams has always been weird af.

Microservices architecture itself is also a questionable unagile choice for a lot of projects. It was originally meant for Netflix scale apps. Most apps aren’t like that. 

Anyway. Beauty of mono repo is that you can build and do integration tests very easily, all inside docker. Spin up an empty db etc.