Skip to content

DevOps challenge project for Particle41 hiring — containerized microservice + Terraform-based Azure infrastructure.

ktsreddy007/Particle41_DevOps_Challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

✅ SimpleTimeService Serverless Deployment Documentation

👨‍💻 Author

Teja Surendar Reddy
DevOps Engineer | Cloud Enthusiast
📧 Email: ktsreddy007@gmail.com


🧾 Overview

SimpleTimeService is a lightweight microservice built in C# (.NET 8) that returns the current timestamp (India Standard Time) and the visitor's IP address in JSON format.

Key Features

  • Containerized using Docker with a non-root user
  • Image hosted on DockerHub: ktsreddy/teja_particle41_devops-challenge:v1.0
  • Deployed to Azure Container Apps via modular Terraform
  • Integrated with a private subnet inside a custom VNet

🌍 Example Application URL

https://teja-aca--z3o5mig.purplemoss-d4634061.southindia.azurecontainerapps.io/

Note: The domain may vary depending on your Azure configuration.


📦 Sample JSON Response

{
  "timestamp": "<User current date & Time>",
  "ip": "<visitor's IP address>"
}

🧰 Technology Stack

Layer Technology
Language C# (.NET 8)
Architecture Pattern Microservice
Containerization Docker (multi-stage, non-root)
Cloud Provider Microsoft Azure
Deployment Azure Container Apps (Serverless)
Infra-as-Code Terraform (modular architecture)
Container Registry Docker Hub

🗂️ Project Structure

PARTICLE41_DEVOPS_CHALLENGE/
├── SimpleTimeService_app/                               # C# Source Code
│   ├── bin/
│   ├── obj/
│   ├── Controllers/
│   │   └── TimeController.cs
│   ├── Properties/
│   ├── .dockerignore
│   ├── appsettings.Development.json
│   ├── appsettings.json
│   ├── Dockerfile
│   ├── Program.cs
│   ├── SimpleTimeService.csproj
│   ├── SimpleTimeService.http
│   └── SimpleTimeService.sln
├── terraform/                                           # Terraform IaC setup
│   ├── env/                                   # Environment-specific configs & root module
│   │   └── dev/                                # Execute your terraform commands from here
│   │       ├── .terraform/
│   │       ├── .env
│   │       ├── .env.template
│   │       ├── main.tf
│   │       ├── outputs.tf
│   │       ├── terraform.tfstate
│   │       ├── terraform.tfvars
│   │       ├── terraform.tfvars.example
│   │       └── variables.tf
│   ├── modules/                                        # Reusable modules
│   │   ├── container_app/
│   │   ├── network/
│   │   └── resource_group/
│   └── .gitignore
├── Particle41_DevOps_Challenge.sln
├── images                                        # Architecture & output screenshots
└── README.md

🚀 Deployment Guide

🛠️ Prerequisites

Tool Purpose Install Link
Azure CLI Login, create service principal Install Azure CLI
Terraform Provision cloud infrastructure Install Terraform
Docker Build container image Install Docker
DockerHub Push cotainer image Login into DockerHub
Azure Account Required to provision resources Azure Free Tier

🔐 Authentication & Azure Credentials

  1. Login to Azure CLI:
az login
  1. Create Service Principal for Terraform:
az ad sp create-for-rbac --name "Your_sp_name" --role="Contributor" --scopes="/subscriptions/<your-subscription-id>" --sdk-auth
  1. Get below details and save in .env file :
ARM_CLIENT_ID=<appId>
ARM_CLIENT_SECRET=<password>
ARM_SUBSCRIPTION_ID=<subscriptionId>
ARM_TENANT_ID=<tenant>
  1. Register core resource providers at susbscription level in azure for Az Container apps
az provider register --namespace Microsoft.App
az provider register --namespace Microsoft.OperationalInsights
az provider register --namespace Microsoft.Insights
az provider register --namespace Microsoft.Network
az provider register --namespace Microsoft.ContainerRegistry
az provider register --namespace Microsoft.Logz
az provider register --namespace Microsoft.ManagedIdentity
az provider register --namespace Microsoft.Monitor
az provider register --namespace Microsoft.Web
  1. Check the status of registered resource provider
az provider show --namespace Microsoft.App --query "registrationState"

🐳 Docker Image

  1. 🔧 Build & Push Image to Docker Hub
cd SimpleTimeService_app
docker build -t simpletimeservice .      # Building 1st locally with no custom tag
docker tag simpletimeservice ktsreddy/teja_particle41_devops-challenge:v1.0  #tag the localdocker image with dockerhubrepo:v1.0
docker push ktsreddy/teja_particle41_devops-challenge:v1.0       # Pushing the tagged image to the remote dockerhub repo 

⬇️ Pull the docker image to your local (Optional)

docker pull ktsreddy/teja_particle41_devops-challenge:v1.0

☁️ Deploying Infrastructure via Terraform to Azure Cloud

  1. 📂Navigate to Terraform Environment Folder
cd terraform/env/dev
  1. 🔄Configure Variables by editing terraform.tfvars or create a new file using:
cp terraform.tfvars.example terraform.tfvars

Note: Update the values as per your Azure setup(resource group, image name, subnet names, etc.).

  1. ⚙️Run Terraform Commands
terraform init
terraform validate
terraform plan -out=tfplan or terraform plan
terraform apply tfplan or terraform apply

✅ This will provision:

  • Resource Group: Tejarg
  • VNet with 2 public & 2 private subnets
  • Azure Container App Environment: teja-aca-env
  • Container App: teja-aca (with public ingress)
  • VNet integration (private subnet)

📡Serverless Infrastructure Overview

Provisioned Azure Resources:

  • Tejarg (Resource Group)
  • tejavnet (Virtual Network with 4 subnets(2 Private,2 Public))
  • teja-aca-env (Container App Environment)
  • teja-aca (Container App)
  • kubernetes load balancer (default from AKS infra via Az Container App)
  • aks-agentpool-* NSG (auto-generated)

Note : You may see AKS-related resources like load balancers, NSGs automatically generated. This is normal when using Azure Container Apps with VNet integration.

Screenshots

Azure Resources
Azure_Resources: These are provisioned resources we will see once terraform has deployed

Network Structure
Azure_Resources: This is the interal network arcitecture how the ACA works with default K8 loadbalancer and NSG's

ACA Log
ACA Log: It shows that our container is pulled and runnng successfully in ACA Log on Azure.


🧪 Validate the Deployment

curl https://teja-aca--z3o5mig.purplemoss-d4634061.southindia.azurecontainerapps.io/

Expected output:

Network Structure


📌 Notes

  • The Container App uses built-in ingress to expose the service publicly.So we didnt setup additional API Gateway.
  • The infrastructure adheres to best practices including use of:
    • Implemented conditional startup with manual logging logic at application code level
    • Private subnet integration
    • Its completely serverless
    • Modular, reusable Terraform code
    • Secure non-root Docker container

🔒 Security Considerations

  • ✅ Docker image runs as non-root user (USER myuser)
  • Ingress HTTPS automatically enabled (Azure-managed) via Azure
  • IP address masking if needed can be applied using Application Gateway or header filtering (didn't implemented)


📚 Additional Resources


📬 Questions?

Feel free to reach out:
📧 ktsreddy007@gmail.com

About

DevOps challenge project for Particle41 hiring — containerized microservice + Terraform-based Azure infrastructure.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published