Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Active-Passive Jenkins Setup in Kubernetes

Tags:

We are planning to setup Highly Available Jenkins setup in container platform using kubernetes. We are looking at setting up one Active master and another master in standby mode. Jenkins data volume is going to be stored in a global storage that is shared between the two master containers.

In case the active master is not available then requests should fail over to other master. And the slaves should be communicating only with active master.

How do we accomplish Jenkins HA setup in active/passive mode in kubernetes. please provide your suggestions.

We would like to achieve as shown in the diagram from below link

https://endocode.com/img/blog/jenkins-ha-setup_concept.png

like image 805
P Ekambaram Avatar asked Mar 06 '19 08:03

P Ekambaram


People also ask

How can you integrate Jenkins with Kubernetes?

In order to do that, you will open the Jenkins UI and navigate to Manage Jenkins -> Manage Nodes and Clouds -> Configure Clouds -> Add a new cloud -> Kubernetes and enter the Kubernetes URL and Jenkins URL appropriately, unless Jenkins is running in Kubernetes in which case the defaults work.

How do you make Jenkins HA high availability?

There is no direct way of setting up Jenkins in High availability mode due to how Jenkins manages its data. Jenkins manages its data in a flat-file (xml), and you can have only one instance of the master node that can read the Jenkins data.

What is Kubernetes URL in Jenkins?

You can get the Kubernetes master URL by this specified command: ➜ kubectl cluster-info | grep master Kubernetes master is running at https://192.168.99.100:8443. The Jenkins pod URL post is standard - 8080, and you can get IP address in only a few steps.


2 Answers

This contradicts with how one should IMHO run applications in Kubernetes. Active/passive is a concept for the past century.

Instead, configure a health check for the Jenkins Deployment. If that fails, Kubernetes will automatically kill the task and start a replacement (which will be available only a few seconds after detecting the active one being unhealthy).

like image 173
StephenKing Avatar answered Nov 15 '22 05:11

StephenKing


There have been active considerations to emulate active/passive setup for containers, but note that as a product feature this really is not a must have and hence not built in. This very well may be implemented as an OOB feature integration wherein you have to craft your applications to at least do the following:

  1. General leader election (for master selection and traffic routing, maybe a sidecar container to do elections and message routing)
  2. Make the liveness/readiness probe detection routines (and the failover logic) to patch all pods under failed paradigm to no longer be selected via any pod selector equation
  3. In the event of another failover, you will still have to ensure another patch of labels (and this time across the old and new pods) to update pods metadata aka labels

If you are looking for something bare minimal than, configuring liveness/readiness probes may just do the trick for you. As always, you should avoid getting into a practice of mass mutating pod labels with ad-hoc patches for role selection

https://github.com/kubernetes/kubernetes/issues/45300

like image 31
Raunak Jhawar Avatar answered Nov 15 '22 04:11

Raunak Jhawar