Hello Deployment Project

What is it??

It is all about automating the entire process of taking the code that you implement from your system to the production

How do you do that??

Below are the things you need:
===================================================================
3 branches in git: develop, qa and release
3 repositories in bintray: sandbox, staging and release
3 jobs in Jenkins: hello-dev, hello-qa and hello-rel
3 namespace in kubernetes: develop, test and release
===================================================================

When any of the developer pushes the code to the github (branch: develop), jenkins (hello-dev job) will execute the pipeline defined in the JenkinsFile (available in your source code)

Note: hook missing in this example.

In this example, the pipeline is defined in such a way that the below mentioned steps get triggered

1) Pull the code from github's respective branch.
2) Build the code using dockerized maven tool.
3) Login to docker registry repository (bintray, in this example)
4) Create a docker image from the DockerFile available in the target folder.
5) Tag the local docker image to the image in the docker registry.
6) Push the image to the docker's respective registry.
7) Finally deploy the image into kubernetes respective namespace.

Note: hello-deployment project works charm in mac operation system with 16 GB RAM [Tested]

Make sure you merge the code from Github develop branch to qa branch and that should execute the pipeline defined in the JenkinsFile available in the qa enviroment. The steps are same to take it to the release environment as well.

Architecture

Alt text

Environment Setup

Fork https://www.github.com/vmudigal/hello-deployment.git repository and then clone using "git clone -b develop git clone -b develop https://www.github.com/[YOUR_GIT_ID]/hello-deployment.git".

Go into "hello-deployment/DevVM/mac" and execute "./bootscript.sh"

Done and dusted!!

Technology stack

  • Vagrant - tool for building and managing virtual machine environments in a single workflow.
  • Virtualbox - virtualization product for enterprise
  • Docker - Containerization platform
  • Jenkins - open source automation server.
  • Kubernetes - an open-source system for automating deployment, scaling, and management of containerized applications.
  • Grafana - Data visualization & Monitoring
  • InfluxDB - Open Source Time Series DB Platform for metrics and events (time series data).
  • Github - a web-based Git or version control repository
  • Springboot - Application framework
  • Maven - build tool
  • Java - programming language

Bintray Account

The docker images that are built during the automated build in Jenkins are stored in bintray as an artifacts.

  1. Sign up for a bintray account at https://bintray.com/signup/oss.

Alt text

  1. Create an Organization

Alt text

  1. Enter organization details and proceed.

Alt text

  1. Create sandbox repository

Alt text

  1. Enter sandbox repository details and proceed.

Alt text

  1. Also create staging and release repositories.

Alt text

  1. Now you have all the repositories needed.

Alt text

  1. Select any repository and click on "Set ME UP".

Setting up your credentials

Setting up your credentials is only required when resolving from a private Docker repository. Use the Docker client login command to authenticate (please use Docker v1.6 and above):

docker login -u vijayendra -p <API_KEY> -e <EMAIL> mudigal-docker-hello-sanbox.bintray.io

Pulling Docker Images

Use the Docker client pull command to download an image (please use Docker v1.6 and above):

docker pull mudigal-docker-hello-sanbox.bintray.io/<NAMESPACE>/<PACKAGE_NAME>:<VERSION>

<NAMESPACE> - Optional. When not specified "library:" will be used as the prefix to the Bintray package name.

<VERSION> - Optional. When not specified "latest" will be used as the Bintray version name.

Pushing Docker Images

Tag your image according to the following convention by running the following command:

docker tag <IMAGE_ID> mudigal-docker-hello-sanbox.bintray.io/<NAMESPACE>/<PACKAGE_NAME>:<VERSION>

Use the Docker client push command to upload and publish your images (please use Docker v1.6 and above):

docker push mudigal-docker-hello-sanbox.bintray.io/<NAMESPACE>/<PACKAGE_NAME>:<VERSION>

<NAMESPACE> - Optional. When not specified "library:" will be used as the prefix to the Bintray package name.

<VERSION> - Optional. When not specified "latest" will be used as the Bintray version name.

Alt text

  1. Note down API Key that you need to use to push artifacts.

Alt text

Alt text

Jenkins Setup

Jenkins is used as continous build, delivery and deployment server.

In you host system goto "http://localhost:8082" to access Jenkins and do the initial setup.

Alt text

Alt text

Alt text

Alt text

Alt text

Alt text

Alt text

Alt text

Alt text

Alt text

Alt text

Alt text

Alt text

Alt text

Kubernetes Dashboard

To access kubernetes dashboard, goto command prompt and execute "kubectl proxy". You can now access the dashboard at http://127.0.0.1:8001/ui

Alt text

Alt text

Alt text

Access the deployed application at http://127.0.0.1:8001/api/v1/namespaces/development/services/hello:8040/proxy/

Alt text

Alt text

Grafana Dashboard

Access grafana dashboard at http://127.0.0.1:8001/api/v1/proxy/namespaces/kube-system/services/monitoring-grafana/

Alt text

Alt text

Alt text

In case of any concerns, please feel free to drop me a message at vijayendrap@gmail.com