This repository contains the source code and infrastructure configuration files for the Tetris Application DevOps Project. The project aims to demonstrate the end-to-end Continuous Integration and Continuous Deployment (CI/CD) pipeline for the Tetris game application.
The repository is organized into the following main folders:
- Ansible: Contains Ansible playbooks for configuring the Jenkins Master and Agent instances.
- Terraform: Contains Terraform configuration files to set up the required infrastructure, including EKS (Elastic Kubernetes Service), Ansible Controller, Jenkins Master, and Jenkins Agent.
- Tetris-App: Contains two versions of the Tetris game application along with Helm charts and other related files.
Before proceeding with the project, ensure that you have the following prerequisites:
- AWS Account and Access Keys
- Terraform installed
- Snyk Account
Follow these steps to set up the project:
Terraform is used to automate the creation and management of infrastructure as code. It supports multiple providers such as AWS, Google Cloud, Azure, etc.
- Configure AWS credentials using AWS CLI.
- Navigate to each folder to create resources:
terraform init
- Initialize the directory.terraform plan
- Display the execution plan.terraform apply
- Apply the configuration.
Ansible is an open-source automation tool used to automate software provisioning, configuration management, and application deployment.
- Jenkins Master:
ansible-playbook -i '<jenkins-master-ip>,' -u ubuntu jenkins-master.yaml
- Jenkins Agent:
ansible-playbook -i '<jenkins-agent-ip>,' -u ubuntu jenkins-agent.yaml
Jenkins is an open-source automation server that enables developers around the world to reliably build, test, and deploy their software. It offers hundreds of plugins to support building, deploying, and automating any project.
Access the Jenkins server using the following URL:
http://<jenkins-master-public-ip>:8080
Jenkins requires the setup of several credentials to facilitate CI/CD processes:
- awsCred: Contains AWS Access Key and Secret Key.
- githubCred: Contains GitHub username and Git Token.
- snykCred: Contains Snyk Auth Token.
- sonarToken: Contains SonarQube Token.
Navigate to Jenkins Dashboard > Manage Jenkins > Manage Credentials to add these credentials.
Connect the Jenkins Agent created via Terraform to the Jenkins Master. This setup involves configuring the agent in Manage Nodes and Clouds in the Jenkins settings.
Install essential Jenkins plugins:
- Sonar Scanner: For SonarQube integration and code quality checks.
- Blue Ocean (Optional): For enhanced CI/CD pipeline visualization.
- AWS Credential: For storing AWS Access Key and Secret Key.
Navigate to Manage Jenkins > Manage Plugins to install these.
Configure Jenkins to use shared libraries for pipeline scripts:
- Go to Manage Jenkins > System Configuration > Configure System.
- Under Global Pipeline Libraries, add the library with the repository URL: https://github.com/artisantek/jenkins-sharedlibraries
SonarQube is a static code analysis tool that helps in identifying bugs, vulnerabilities, and code smells in your source code.
- Connect to the SonarQube server running in the container at:
http://<jenkins-agent-public-ip>:9000
Initial credentials are admin
for both username and password.
- Navigate to Administration > Security > Users.
- Update tokens and add this token as a credential in Jenkins.
- Go to Administration > Configuration > Webhook.
- Create a webhook with the URL:
http://<jenkins-public-ip>:8080/sonarqube-webhook/
- Navigate to Manage Jenkins > Global Tool Configuration.
- Click on Add SonarQube Scanner and configure with:
- Name:
sonar-scanner
- Install Automatically
- Name:
- Navigate to Manage Jenkins > Configure System > SonarQube Servers.
- Click on add SonarQube and configure with:
- Name:
sonar-server
- Server URL:
http://<jenkins-agent-public-ip>:9000
- Server Authentication Token:
sonarToken Cred
- Name:
Set up a Multi-Branch Pipeline to automatically build branches and pull requests:
- Navigate to Jenkins Dashboard > New Item.
- Select Multibranch Pipeline and configure source repository and branch discovery behaviors.