4.1 Pipeline CI/CD — GitHub, Maven, Jenkins, Artifactory, SonarQube, Docker, Tomcat, Kubernetes ( Deployment and Services)
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.
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
Pre-requisites:
- Tools like Jenkins, Artifactory, SonarQube, Kubernetes Master and Node setup is installed and the server is up and running
- Jenkins CI/CD — JFrog Artifactory Jenkins Integration
- Jenkins CI/CD — SonarQube Jenkins Integration
- Please make sure the following Jenkins Plugins are installed for this lab setup in the Jenkins Server — — Pipeline, Artifactory, SonarQube Scanner for Jenkins, SSH Agent, Email Extension Plugin.
Lab Setup:
- Configuring the Kubernetes Master’s Private key in the Jenkins Credentials store with the type “SSH Username with private key”
- Creation of the Jenkins Job — — Pipeline Project
- 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
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:
Kubernetes Cluster Screenshot of the deployment and service created.
- Breaking the Code:
We can examine the Jenkinsfile in this Page