Simple Continuous Deployment System with Jenkins and Github

In this post I'll demonstrate a simple CD system, that based on a merge to the Master branch for a project on Github will package, push and deploy a small RESTfull application.

The setup consists of a single Jenkins server, a load balancer node running HAProxy and two API servers running Apache with the libapache2-mod-wsgi module to drive the Python Bottle microframework.

First let's create the local git repository:
Create a new project on Github, and deploy your public key to it:


Next, test that you can connect using the deployed SSH key and push to the Master branch:
Let's build the Jenkins server:
Once you login to Jenkins create a new project:

Or you can copy the following config file to /var/lib/jenkins/jobs/RESTfull-CI-Pipeline: Make sure you have the github plugin installed on Jenkins for this to work.

Lastly on the Github side, add a service that will call the Jenkins API when an event is triggered e.g. merge to Master:


Time to setup the API nodes:
And finally the load balancer node:
Now every time you merge a commit to Master, Github will POST to the Jenkins API, and Jenkins will execute the job, building a debian package, and deploying it to the API nodes.

To test the simple RESTfull API run:

No comments:

Post a Comment