CI/CD Deployment pipeline using Jenkins on Kubernetes to deploy a Simple Nginx application
- Requirements: For CI/CD deployment pipeline using Jenkins on Kubernetes you need git repository and Kubernetes setup as well as Jenkins plugins named docker , docker pipeline( plugin integrates Jenkins with docker)and Kubernetes continuous deployment
- Create credentials in Jenkins for Kubernetes (Given ID will use in Jenkinsfile). Click to Credentials on the left menu and fill the fields as shown in below image
3. Create a new item and select pipeline option as shown in below image
4(a). Now add credentials with the key file in two steps to use encrypted git credentials in Jenkinsfile
4(b). now got to the project -> click on pipeline syntax link
now right-side drop-down choose: with credentials: Bind credentials to variables and then choose a secret box from next drop down box and choose above credential ID and enter any value which will use in Jenkinsfile. It will generate the line of code that will use in Jenkinsfile.
5. Now open the project and Configure. Type anything in the description box and Choose POOL SCM under build trigger section and fill with five stars which indicate that if any commit will occur then the pipeline will auto-trigger (follow below image)
6. Follow the below image to integrate with the git master branch and Kubernetes. The path will always fill up Jenkinsfile
7. Jenkinsfile is available in the given folder. Jenkinsfile needed two more files named kunernetes.yml (to deploy in Kubernetes with L7 or L4 with the latest tag) and changeTag.sh (Which update with latest tagged code and roll back the tag). Files are available on GITLAB for deploy service on L7 Load-Balabancer and L4 Load Balancer. For L7 load balancer: https://gitlab.com/vineetkumar03/jenkins-ci-cd-pipeline-deploy-on-kubernetes-with-l7-loadbalancer and for L4 load balancer: https://gitlab.com/vineetkumar03/jenkins-ci-cd-pipeline-deploy-on-kubernetes-with-l4-services