This project is dedicated to provisioning Google Kubernetes Engine (GKE) on the Google Cloud Platform, deploying a Python application using Terraform as Infrastructure as Code (IAC), implementing CI with GitHub Actions, utilizing Python Django for the application, and orchestrating continuous deployment (CD) through ArgoCD.
- Install Required Tools
- Terraform Setup
- Dockerizing the Application
- Continuous Deployment
- Configure GitHub Actions for Docker Hub
Install Terraform by following the instructions here.
Install the Google Cloud SDK by following the instructions here.
Install Docker by following the instructions here.
No installation required. GitHub Actions is integrated into GitHub repositories.
Install ArgoCD on GKE by following the instructions here.
https://github.com/Emmylong1/DevOps-Assessment-Test.git
gcloud auth application-default login
Copy terraform.tfvars.example to terraform.tfvars and fill in the required variables.
terraform init
terraform apply OR
terraform apply -auto-approve
Review the proposed changes and type 'yes' to apply them. OR -auto-approve flag with terraform apply to automatically apply changes without requiring manual confirmation.
Check the GKE cluster on the Google Cloud Console.
Create a Dockerfile in your application root:
FROM python:3.8
WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8000
ENTRYPOINT ["python", "manage.py"]
CMD ["runserver", "0.0.0.0:8000"]
docker build -t emmylong1/devops-interview:v1 .
docker images
Create .github/workflows/ci-pipeline.yml:
name: CI Pipeline
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x' # Specify your desired Python version
- name: Build Docker Image
run: |
docker build -t emmylong1/devops-interview:v1 .
env:
DOCKER_BUILDKIT: 1
- name: Push to Docker Hub
run: |
echo "${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin
docker push emmylong1/devops-interview:v1
Add these secrets to your GitHub repository: .'DOCKERHUB_TOKEN': Docker Hub access token .'': Your Docker Hub username
Make changes, push to main, and check GitHub Actions for successful deployment to your dockerhub repository.
- Access the ArgoCD UI.
- Go to the application you want to set up webhooks for.
- Navigate to the "Settings" tab.
- Under "Automation," find the "Webhook" section. Click "Add Webhook."
- Configure the webhook details, including the GitHub repository URL and secret.
- Save the webhook configuration.
- Access the ArgoCD UI.
- Go to the application you want to automatically sync.
- Navigate to the "Settings" tab.
- Under "Auto-Sync," enable automatic synchronization.
- Configure the desired sync options.
- Save the configuration
Once you create this app, Argo CD will be ready to monitor your repo and automatically make changes to the cluster. Let’s see it in action! medium.
This is to provide you Guide lines for you to implement infrastructure with Terraform, Dockerized your app, implemented continuous integration and deployment (CI/CD) with GitHub Actions and ArgoCD, and pushed the Docker image to Docker Hub. For details and troubleshooting, refer to documentation and tooling guides. The application will be automatically synced and deployed to the Kubernetes namespace called "prod" whenever changes are pushed to the main branch. Thank you.