1

So I am quite new to docker, and in particular docker swarm. I've just installed jenkins and I want it to work on all nodes regardless of it running with only one instance on one machine or 10 instances on 5 machines.

The problem with this is of course "how does jenkins know what build definitions I've got". There is probably a specific way of solving this for jenkins, but I see myself having similar issues in the future. So it got me thinking, is there any easy way to setup replication on the filesystem/volume? preferably in a master/slave configuration that would work in a docker swarm environment?

munHunger
  • 363
  • 1
  • 3
  • 9
  • Typically with jenkins you have a single master which holds the job definitions and a collection of slaves capable of running the jobs. – jordanm Jan 24 '18 at 20:11
  • @jordanm you are absolutely correct! but what happens if the master server catches fire? there is no organizer left and all the configuration is lost. Note that this is not just a case of backing up data as I want another node to be able to respond directly. and what about load balancing? – munHunger Jan 24 '18 at 20:14
  • https://stackoverflow.com/questions/36173214/how-to-setup-jenkins-with-ha – jordanm Jan 24 '18 at 20:16
  • You should use jenksfiles or some other method for managing job configuration that stores them in version control – jordanm Jan 24 '18 at 20:16

1 Answers1

0

Even if you had a magic data replication solution, it's not going to solve the problem completely. Note I'm not a Jenkins expert.

It sounds like what you need is data persistence for your Jenkins container.

There are at least two ways to make an app with persistent data needs (like a database, Jenkins, etc.) work in a container cluster:

  1. Use the app's built-in clustering. Can Jenkins do multi-master? Doing this type of HA doesn't change much in a container orchestrator. If the app (Jenkins) supports HA, then it's usually best to do that. Just like with Mongodb replicas, or elasticsearch clusters... it's best to create separate swarm services with one container each and have them connect to each other as they would before you were using Swarm.

  2. Use Swarm to store the persistent data and have it recreate failed containers. Store the data of Jenkins in docker volumes that are Swarm-aware. This would require shared storage and a volume plugin like REX-Ray, or any of the ones on store.docker.com to hold everything that needs to be connected to a running instance of Jenkins to make it work. Then, between the docker volumes, Swarm configs, and Swarm secrets, when a service running a Jenkins container dies or has to re-create the container, it'll ensure the volumes/configs/secrets are on whatever node the task (container) launch on. This isn't true HA, but it's close.

Bret Fisher
  • 3,973
  • 2
  • 21
  • 25