This repository provides comprehensive Terraform configuration files for provisioning and managing an S3 bucket. It also includes GitHub Actions to run a CI/CD pipeline that builds and pushes Docker images. These images are then used to start a Kubernetes deployment on a local machine using Rancher Desktop. Uses Argo CD to monitor changes in github repo then make that change in K8s cluster. I first developed this project for normal kubernetes deployment. Now It uses helm package manager to package the app. And deploy it into different usecases, like dev,prod etc..
Instructions for setting up the deployment with Minikube are also provided. Plus files for starting a K8s cluster in digitalocean is also provided.
- Terraform Configuration: Automates the provisioning and management of an S3 bucket.
 - CI/CD Pipeline: Utilizes GitHub Actions to automate the build and push of Docker images.
 - Docker compose Deployment: Deployed using docker compose. It will be useful when we don't want to deploy without spining up a resource hungry kuberentes cluster.
 - Kubernetes Deployment: Deploys applications locally using Rancher Desktop, with alternative instructions for Minikube. It uses argo cd for continuous deployments for the changes happend in github.
 
- Ensure Terraform is installed on your local machine.
 - Navigate to the 
terraformdirectory. - Run 
terraform initto initialize the Terraform configuration. - Execute 
terraform applyto provision the S3 bucket. 
- The repository contains a 
.github/workflowsdirectory with GitHub Actions workflows. - Workflows automate the building and pushing of Docker images to a container registry.
 - Ensure your repository secrets include credentials for accessing the container registry.
 
- 
Rancher Desktop:
- Rancher Desktop is an open-source project that provides a simple way to run Kubernetes clusters on your local machine. It offers an easy-to-use interface and powerful features for managing Kubernetes workloads.
 
 - 
Minikube:
- Minikube is a tool that allows you to run a single-node Kubernetes cluster on your local machine. It's designed for users looking to develop and test Kubernetes applications locally.
 
 
There are two ways to set up AWS credentials. Here, I've used a .env file, but AWS CLI is the most secure option.
This guide outlines the steps to log in to AWS using the AWS Command Line Interface (CLI).
Before proceeding, ensure you have the following:
- An AWS account
 - AWS CLI installed on your local machine
 - Access keys or IAM user credentials for your AWS account
 
- 
Install AWS CLI:
If you haven't installed AWS CLI yet, you can follow the official installation guide provided by AWS.
 - 
Configure AWS CLI:
Run the following command to configure AWS CLI with your access keys or IAM user credentials:
aws configure
You will be prompted to enter your AWS Access Key ID, AWS Secret Access Key, AWS region, and default output format.
 
If you don't want to use AWS CLI setup, create a .env file and copy the following content:
AWS_ACCESS_KEY_ID=<-AWS access key ID->
AWS_SECRET_ACCESS_KEY=<-AWS secret access key->
AWS_DEFAULT_REGION=<-AWS default region->Then run:
source .envTo get started with this Terraform project, follow these steps:
- 
Clone the repository to your local machine:
git clone https://github.com/lijozech-12/Container_automation.git
 - 
Install Terraform:
Follow the Terraform installation instructions to install Terraform on your machine.
 - 
Initialize Terraform:
terraform init
 - 
Create
terraform.tfvarsand provide the values:aws_region = "us-east-1" instance_ami = "ami-12345678" s3_bucket_name = "lijos-test-bucket" weather-page-docker-compose = "/location to /weather-page-docker-compose.yml"
 - 
Review and Modify Terraform Configurations:
Navigate to the
terraformdirectory and review the.tffiles to understand the infrastructure resources being managed. - 
Plan and Apply Terraform Changes:
terraform plan terraform apply
 
Now that the S3 bucket is set up, we need to insert data into the bucket. To do that, run the following command. It will start a Docker container and insert data into the database:
docker-compose -f weather-fetcher-docker-compose.yml up -dChange the permission of the file:
chmod +x deploy.shRun the file:
./deploy.shThis script is only to build and deploy it manuvally. It will automatically deployed using github actions.
Now deploy it by running the following command:
docker-compose -f weather-page-docker-compose.yml upVisit the following link:
After setting up rancher desktop run the below commands
cd container-orchestrator 
kubectl apply -f weather-app-deployment.yaml
kubectl apply -f weather-app-service.yaml
kubectl apply weather-app-ingress.yaml It will start running when you use kubectl get all to see all the resources.

Helm package is stored inside a weatherapp-helm folder. You can start the cluster using following commands.
# normal deployment
helm install weather-app weatherapp-helm/ --values weatherapp-helm/values.yaml# Dev deployment
helm install weather-app-dev weatherapp-helm/ --values weatherapp-helm/values.yaml -f weatherapp-helm/values-dev.yaml -n dev# Production deployment
helm install weather-app weatherapp-helm/ --values weatherapp-helm/values.yaml -f weatherapp-helm/values-prod.yaml -n prodFollow Installation documentation to install Argo CD in your cluster.
Argo CD will help to continuously deploy changes pushed into github in the Kuberentes cluster. After installing it Specify the github repo and it's path(In our case weatherapp-helm). It will take the code from repo and deploy it in our cluster.
when you visit http://localhost:30083/ you can see the website.
This guide provides step-by-step instructions for deploying the weather-app on a local Kubernetes cluster using Minikube.
Before you begin, you'll need to install the following tools:
- kubectl: The command-line tool for interacting with Kubernetes clusters. Installation instructions.
 - A Hypervisor: Such as VirtualBox, VMware, Hyper-V, or Docker. This is needed for Minikube to create VMs.
 - Minikube: Simplifies running Kubernetes locally. Installation instructions.
 
Start a single-node Kubernetes cluster with Minikube:
minikube startEnable the built-in NGINX Ingress controller in Minikube:
minikube addons enable ingressGo inside k8's folder
cd container-orchestratorRun the below commands
kubectl apply -f weather-app-deployment.yaml
kubectl apply -f weather-app-service.yamlkubectl apply -f weather-app-ingress.yamlFind the IP address of your Minikube VM:
minikube iphttp://<-minikube-ip->/weather
http://<minikube-ip>/weather
Replace <-minikube-ip-> with the actual IP address.
helm install weather-app weatherapp-helm/







