This guide provides instructions for setting up a CI/CD pipeline for deploying a Flask Contact App in a Kubernetes cluster with a Load Balancer.
Ensure the following applications are installed on your system:
- AWS CLI
- Docker
- Terraform
- kubectl
- Ansible
- Helm
- Git
- Other dependencies required to run the above tools
Clone the GitHub repository:
https://github.com/glazedonuts616/MajorProject.git- Add your AWS private key credentials to the
.awsfolder on your machine. - Configure AWS CLI with your credentials:
aws configureModify the aws_instance key name in the Terraform configuration to match the name of your AWS key file.
- Navigate to the Terraform directory:
cd MajorProject/terraform/ - Initialize and apply Terraform configurations:
terraform init terraform plan terraform apply
- Navigate to the Ansible directory:
cd MajorProject/terraform/tf_ec2_ansible/ - Update
inventory.iniwith the location of your AWS key file. - Run the Ansible playbook:
ansible-playbook -i inventory.ini ec2_ansible.yaml
- SSH into your newly created EC2 instance:
ssh -i "path-to-your-key" ubuntu@Your-EIP-Address
-
Access Docker logs to retrieve the Jenkins admin password:
docker logs jenkins-container-name
-
Open Jenkins in your browser using the EC2 IP address and port 8080:
http://Your-EIP-Address:8080 -
Enter the admin password and install the following plugins:
- EKS Token
- EC2
- Git
- Kubernetes
- Pipeline (Groovy and Grid View)
- Amazon Web Services
-
Add necessary credentials in Jenkins:
- EKS Token Credentials
- AWS Credentials
- GitHub Credentials
- GitHub Webhook Credentials
- Navigate to the EKS Terraform configuration:
cd MajorProject/terraform/eks_cluster/ - Initialize and apply the configuration:
terraform init terraform plan terraform apply
- Access Jenkins at the EC2 instance IP (port 8080).
- Add the
Jenkinsfileto your pipeline configuration. - Update the
Jenkinsfilewith the correct Kubernetes cluster endpoint URL. - Configure the pipeline to synchronize with the GitHub repository via webhook.
- Build the pipeline in Jenkins.
- Flask Contact App:
http://LoadBalancer-DNS-Name:5052 - MongoDB:
http://LoadBalancer-DNS-Name:8081
- Confirm GitHub and Jenkins webhook integration.
- Verify successful pipeline execution and deployment.
- Ensure printers are up to date and connected to the server (if applicable).
- Use the DNS name provided by the Load Balancer to access the services.
It's been real!
Yoni