Skip to content

SullzCode/DevOps-Assessment-Test

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DevOps-Assessment-Test

Overview

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.

Table of Contents

  1. Install Required Tools
  2. Terraform Setup
  3. Dockerizing the Application
  4. Continuous Deployment
  5. Configure GitHub Actions for Docker Hub

Install Required Tools

Terraform

Install Terraform by following the instructions here.

Google Cloud SDK

Install the Google Cloud SDK by following the instructions here.

Docker

Install Docker by following the instructions here.

GitHub Actions

No installation required. GitHub Actions is integrated into GitHub repositories.

ArgoCD

Install ArgoCD on GKE by following the instructions here.

Terraform Setup

Step 1: You Can Clone my Repository

https://github.com/Emmylong1/DevOps-Assessment-Test.git

Step 2: Set up Google Cloud Credentials

gcloud auth application-default login

Step 3: Configure Terraform Variables

Copy terraform.tfvars.example to terraform.tfvars and fill in the required variables.

Step 4: Initialize and Apply Terraform Configuration

terraform init terraform apply OR terraform apply -auto-approve

Step 5: Review and Confirm

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.

Step 6: Verify GKE Cluster

Check the GKE cluster on the Google Cloud Console.

Dockerizing the Application

Step 1: Create Dockerfile

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"]

Step 2: Build Docker Image

docker build -t emmylong1/devops-interview:v1 .

Step 3: Verify Docker Image

docker images

Continuous Integration (CI)

GitHub Actions Workflow

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

GitHub Secrets

Add these secrets to your GitHub repository: .'DOCKERHUB_TOKEN': Docker Hub access token .'': Your Docker Hub username

Verify Continuous Integration

Make changes, push to main, and check GitHub Actions for successful deployment to your dockerhub repository.

ArgoCD Webhook Configuration

  1. Access the ArgoCD UI.
  2. Go to the application you want to set up webhooks for.
  3. Navigate to the "Settings" tab.
  4. Under "Automation," find the "Webhook" section. Click "Add Webhook."
  5. Configure the webhook details, including the GitHub repository URL and secret.
  6. Save the webhook configuration.

ArgoCD Automatic Sync Configuration

  1. Access the ArgoCD UI.
  2. Go to the application you want to automatically sync.
  3. Navigate to the "Settings" tab.
  4. Under "Auto-Sync," enable automatic synchronization.
  5. Configure the desired sync options.
  6. 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.

For Conclusion

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 54.4%
  • HCL 43.7%
  • Dockerfile 1.9%