4.1 Pipeline CI/CD — GitHub, Maven, Jenkins, Artifactory, SonarQube, Docker, Tomcat, Kubernetes ( Deployment and Services)

Dileep Prithvi
3 min readJun 19, 2020

--

I hope you had visited the previous stories 1.1 Series , 2.1 Series & 3.1 Series and this is the continuation of it.

Scenario:

This Lab Setup describes about the inclusion of Kubernetes Tool using the SSH Setup. Jenkins will connect to Kubernetes Cluster using the SSH mechanism and copy the yaml files from Jenkins to Kubernetes and trigger the Deployment and Services in the Kubernetes Cluster.

Best Practices:

  • For Production grade deployment from the Kubernetes, we should use the Kubernetes object such as Deployment instead of Pod.

Note: We are not using any available Kubernetes plugin to connect from Jenkins to Kubernetes Cluster. We are using SSH Agent Plugin to connect to Kubernetes Master from the Jenkins.

  • I have divided the story in to Two Sections.

4.1 Pipeline CI/CD — GitHub, Maven, Jenkins, Artifactory, SonarQube, Docker, Tomcat, Kubernetes ( Deployment and Services)

4.2 Pipeline CI/CD — GitHub, Maven, Jenkins, Artifactory, SonarQube, Docker, Tomcat, Kubernetes ( Deployment and Services)

In this article, we will discuss the Jenkins Declarative Pipeline Approach of Building the CI/CD Pipeline

Application: Simple JSP Application

Tools Used:

  • GitHub — Source Code Management
  • Maven — Build Tool
  • Jenkins — Continuous Integration (CI/CD)
  • Artifactory — Artifact Repository Manager
  • SonarQube — Code Quality and Code Analysis
  • Docker — Container Engine
  • Tomcat — Application Server
  • Kubernetes — Container Orchestration
Architecture

Pre-requisites:

Lab Setup:

  • Configuring the Kubernetes Master’s Private key in the Jenkins Credentials store with the type “SSH Username with private key
Fig1.1
  • Creation of the Jenkins Job — — Pipeline Project
Fig1.1
  • Go to Pipeline Section, Select the Git Repository and save the job

GitHub URL:

https://github.com/Dileeprithvi/CI-CD-Jks-K8s-SSH/tree/working

Branch: working

Fig1.2

Jenkins Console Output Log is attached for your reference in the GitHub

To check the code is deployed correctly, Please follow the below URL Pattern:

http://<kubernetes-master-ip>:<service-external-port>/webapp/

Ex: http://35.223.202.172:30840/webapp/

  • Jenkins Pipeline Stages Screenshot:
Pipeline Screenshot

Kubernetes Cluster Screenshot of the deployment and service created.

  • Breaking the Code:

We can examine the Jenkinsfile in this Page

--

--

Dileep Prithvi

AWS Certified Solution Architect– Associate. Skill set - AWS, DevOps