I thought to share this blogs with you guys. It was a great project, So I shared it here.
In this blog post, I'll guide you through setting up a DevOps pipeline using Terraform and Jenkins, separating the infrastructure provisioning for EC2 instances and EKS clusters into distinct folders. This approach enhances modularity and organization within your project.
Part 1: Jenkins on EC2 Instance
Step 1: Provisioning an EC2 Instance
Use Terraform to create an EC2 instance by defining the instance specifications in the dedicated "ec2_instance" folder. This involves specifying the AMI, instance type, key pair, and security groups.
Step 2: Installing Jenkins
Create a script (jenkins_
provision.sh
) within the "ec2_instance" folder to install Jenkins on the EC2 instance. This script should handle updating the system, installing Java, and setting up Jenkins.
Part 2: EKS Cluster and Application Deployment
Step 3: EKS Cluster Setup with Terraform
In the "eks_cluster" folder, extend the Terraform setup to include the creation of an Amazon EKS cluster. Define the necessary configurations, such as the cluster name, node groups, and networking details.
Step 4: Application Deployment on EKS
Create Terraform files and Kubernetes YAML manifests within the "eks_cluster" folder following best practices. Deploy a sample application to the EKS cluster, ensuring modularity and separation of concerns.
Part 3: Jenkins Pipeline Automation
Step 5: Jenkins Pipeline Configuration
Set up a Jenkins pipeline to automate the execution of Terraform scripts for EC2 and EKS. Create separate stages in the pipeline for provisioning the EC2 instance and creating the EKS cluster and deploying the application.
Step 6: Viewing the Deployed Application
Once the Jenkins pipeline runs successfully, access the deployed application through the provided URL. Verify that the entire process is automated and that the application is up and running on the EKS cluster.
This is the demo-video of succesfull working of the project. Check it out here.
Conclusion
By following this organized approach, you've successfully built a DevOps pipeline using Terraform and Jenkins, separating the infrastructure provisioning for EC2 instances and EKS clusters. This promotes modularity and enhances the overall organization of your project.
Let me know your reviews, and what things we could customise in this to enhance the project. Will be fun to discuss that. Let's connect here: