In this Devops CI/CD project, we will learn about-
- What is CI/CD?
- What is the workflow of CI/CD?
- How we will use various tools to create a CI/CD pipeline to deploy applications on the server?
- How to deploy Applications on Tomcat Server in various environments?
- How to create CI/CD pipelines with the help of various tools like git, GitHub, Docker, Ansible, and Kubernetes, on AWS EC2?
- We will cover this DevOps CI/CD project in Modules.
Table of Contents
What is CI And CD?:-
we’re going to learn about something called continuous integration, continuous delivery, and continuous deployment. It might sound complicated but don’t worry, I’ll break it down for you.So, imagine we have a website. This is our official website, and I have a diagram here to help explain things.
First, let’s talk about continuous integration.
- Basically, we have our source code on our computers. We then put that code into a system called Git, which helps us manage our code. Once the code is in Git, a special tool called as Continuous Integration Process takes over. It automatically builds the code and runs tests to make sure everything is working correctly.
- After that, we generate something called artifacts, which are like little packages of our code. These artifacts need to be deployed, or put, into different environments. The environments can be different depending on the project or the people we’re working with. It could be a staging environment or a test environment.
Example:-
Let’s say we want to deploy our artifacts to the staging environment. Once they’re there, we do some tests to make sure everything is still working well. We check for any bugs or performance issues.
If everything looks good, we can then deploy the code to the production environment. This is the real deal, where everyone can see and use our website.
Now, here’s the cool part. If we can do all of this automatically, without needing someone to do it manually, we call it continuous deployment. We can automatically deploy the code to the staging environment and then to the production environment.
But sometimes, we might need someone to give their approval or do something manually before deploying. In that case, it’s not continuous deployment anymore.
So, that’s the basic idea of continuous integration, continuous delivery, and continuous deployment. It’s all about making sure our code is tested, deployed, and working smoothly. Pretty cool, right?
Let’s try to apply the same idea to our project
This project is about DevOps, which we’ll work on during this Blog.
Here’s the deal:
- We have some code on our computer, and once it’s ready, we’ll upload it to GitHub.
- Then, our CI tool called Jenkins will pull the code and build it with the help of Maven for us.
- If this whole process happens automatically, we call it continuous integration(CI).
- similar way, Once the artifacts are generated, it will be copied onto Ansible.
- Ansible is going to make it a containerized application by creating an image. And then, it will deploy the code to Kubernetes.
- This happens automatically, so we call it Continuous Delivery(CD).
- But to make continuous deployment work, we might need more than one environment.
- But hey, if we can make it happen, we’ll achieve continuous deployment too!
- I hope you understand how we’re using continuous integration(CI) and continuous delivery(CD) in this project.
Introduction to CI/CD project:-
In This DevOps Project, we will create a complete CI/CD Pipeline to build and deploy the Agile Application.
Used Tools in this project:-
We will use various tools here to create a CI/CD pipeline to deploy applications which are the following-
Git-Use as a local version control system on your local System(Laptop).
GitHub-Use as a distributor version control system(DVCS).
Jenkins- Use as the continuous integration tool(CI Tool).
Maven- Use as a Build tool to create Artifact.
Ansible- Use as configuration management under the deployment tool.
Docker- Use For containerization
Kubernetes-Use as a container management tool that will control the containers
AWS- All Setup will be on AWS EC2
Why and how these Tools will be used? How does the Workflow of these Tools work in This project?
We are going to set up all this involvement on airplanes. Now, let’s see how these tools are going to fit into our DevOps workflow.
- Usually, we have the source code with the developers and they commit that code into the distributed version control system(GitHub) during the development phase.
- Then we need to build this code, right? For that, we are going to use the continuous integration tool called Jenkins. Once Jenkins builds the code, it generates artifacts. For those artifacts, we need to deploy them onto the target environment.
- So we needed some tool that can able to deploy the artifacts on the target environment. In our case, we are going to use Ansible as a deployment tool and it can able to deploy our applications on a VM or docker container, or Kubernetes. in our case, initially, we will deploy our application on our VM. Then we are going to deploy it on our Docker container. At last, we are going to deploy it on our Kubernetes.
- By the end of this course, we could able to set up this complete CI/CD pipeline. This has given me a rapid idea of what we cover during this program.
What I am going to cover in this CI/CD project?
During this DevOps project, we are going to deploy our application on three different kinds of target environments.
- On VM(EC2)-Initially, we are going to deploy it on a VM. I mean to say a virtual VM(EC2)
- On Docker Container– The second one is on your Docker container
- On Kubernetes cluster- At last, the Third one is on a Kubernetes cluster
NOTE:- In all environments, the Server will be Tomacat Server
How we will build and deploy our application on these environments 1)VM 2) Docker Container and 3)Kubernetes environment?
1)Application Deployment On VM Environment
- we are going to build and deploy our application on your VM EC2(Tomcat server).
- For this, we are going to set up CI/CD pipeline with the help of GitHub, Jenkins, and Maven, Tomcat.
Setting up CI/CD pipeline with the help of GitHub, Jenkins, and Maven, Tomcat.
For this Ci/CD setup, we are going to follow below steps-
Step1a:- By this time, we don’t have any environment, so we are going to start with setting up a Jenkins server first(in AWS EC2)
Step 1b:- Set up and configure Maven and Git.
Step 1c:- Set up the Tomcat server (in AWS EC2)
Step 1d:- Integrate GitHub, Maven, and Tomcat Server with Jenkins.
Step 1e:- Then we are going to create a CI/CD Jenkins job, and we are going to see how we can build and deploy it on a Tomcat server.
Step 1f:- Once the deployment is done, we are going to test our deployment.
If you want to set up this CI/CD from scratch , then please go through Module-2
2.a- Application Deployment on Docker Environment
- By this time, we have an environment with Git, GitHub, Jenkins, Maven, and Tomcat(we have done this in a previous environment).
- And we can able to commit our code to GitHub. Jenkins is going to pull the code from GitHub, Build with the help of Maven, and deploy it on a Tomcat server.
- Next thing, we are going to see how we can deploy our artifacts on a Docker container.
- We are going to see how to set up a Docker environment why because GitHub and Jenkins, Maven already exist.
- Now we are going to build and deploy our application on your Docker Container. And for this, we will create below CI/CD pipeline.
Setting up CI/CD pipeline with the help of GitHub, Jenkins, and Maven, Docker:-
For this Ci/CD setup, we are going to follow below steps-
Step 1:- First we will Set up the Docker environment
Step 2:- Then we are going to see how to write a Dockerfile
Step 3:- After writing Dockerfile, we will create an image with the help of Dockerfile and then will create a container on the docker host(in EC2)
Step 4:- After that, we will integrate the Docker host with Jenkins
Step 5:- At last, we are going to Create a CI/CD job on Jenkins to build and deploy on a container
To do this setup, please go through Module-3
2.b- Application Deployment on Docker Environment with the help of Ansible
we are going to see how we can deploy it on a container with the help of Ansible.
Setting up CI/CD pipeline with the help of GitHub, Jenkins, and Maven, Docker:-
- By this time, we have an environment in similar way, as we have seen earlier. But instead of deploying on your VM, we are going to deploy it on a Docker container. Next thing we are going to see how we can deploy it on a container with the help of Ansible.
- So here we are going to use GitHub, Jenkins, Maven, Ansible, and Docker. Here we are going to see how to set up Ansible server next, integrating Docker host with Ansible next Ansible Playbook to create an image and Ansible playbook to create a container and integrating Ansible with Jenkins. At last, we are going to create a CI/CD job to build code on Ansible and deploy it on a Docker container.
For this Ci/CD setup, we are going to follow below steps-
Step 1:-Setup Ansible Server
Step 2:- Integrate Docker Host with Ansible server
Step 3:-Ansible Playbook to create an image
Step 4:-Ansible playbook to create Container
Step 5:- CI/CD job to build code on Ansible and deploy it on Docker container
3) Application Deployment On Kubernetes
- Here, we are going to see how to build and deploy artifacts on Kubernetes.
- So most of the environment is ready by this time, except for Kubernetes. So we are going to set up Kubernetes on AWS.
- Here we will use a service called the EKS(Elastic Kubernetes Service). Next, we will write pod, service, and deployment manifest files.
- I will show you how to write it. Next, integrating Kubernetes with Ansible. Next, Ansible playbooks to create deployments and services.
- At last, we are going to create a CI/CD job to build code on Ansible and deploy it on a Kubernetes cluster.
- By this time, we could be able to similar conduct in this environment. But instead of Docker host, we are going to deploy our applications on Kubernetes Cluster.
- Hope This information has given enough idea, of what we are going to cover during this program,
Setting up CI/CD pipeline with the help of GitHub, Jenkins, and Maven, Docker, Kubernetes:-
- By this time, we have an environment in similar way, as we have seen earlier. But instead of deploying on your VM, we are going to deploy it on a Docker container. Next thing we are going to see how we can deploy it on a container with the help of Ansible.
- So here we are going to use GitHub, Jenkins, Maven, Ansible, and Docker. Here we are going to see how to set up Ansible server next, integrating Docker host with Ansible next Ansible Playbook to create an image and Ansible playbook to create a container and integrating Ansible with Jenkins. At last, we are going to create a CI/CD job to build code on Ansible and deploy it on a Docker container.
For this Ci/CD setup, we are going to follow below steps-