How oparag-dev/secure-gitops-k8s-delivery works
Purpose and topology
This is a DevSecOps reference repository that provisions AWS infrastructure and deploys a task-management application through GitOps. The runtime path is public TLS load balancer → Nginx-hosted React SPA → internal Flask API → private Amazon RDS PostgreSQL. The application is packaged and deployed separately from its cloud and cluster foundations.
Application entry points
• Flask starts through app/taskapp_backend/run.py; API routing, authentication, and persistence are centered in app/taskapp_backend/app/routes.py, app/taskapp_backend/app/auth.py, and app/taskapp_backend/app/models.py.
• The React/Vite client starts at app/taskapp_frontend/src/main.tsx, with routing/application composition in app/taskapp_frontend/src/App.tsx.
• Browser-to-API integration is centralized in app/taskapp_frontend/src/services/api.ts; production Nginx proxies /api/ to the backend via app/taskapp_frontend/nginx-production.conf.
User, auth, and task flow
The SPA owns login state through app/taskapp_frontend/src/contexts/AuthContext.tsx and gates authenticated UI using app/taskapp_frontend/src/components/ProtectedRoute.tsx. Dashboard/Kanban interactions originate in app/taskapp_frontend/src/pages/Dashboard.tsx and task UI components. Requests reach Flask REST endpoints, where JWT authentication protects task operations; SQLAlchemy models form the boundary to PostgreSQL. Database schema evolution is managed with Alembic under app/taskapp_backend/migrations/env.py and app/taskapp_backend/migrations/versions/d5edfb30a373_initial_migration.py.
Container and Kubernetes application boundary
Each tier has an independent container build definition: app/taskapp_backend/Dockerfile and app/taskapp_frontend/Dockerfile. Helm is the deployable application contract:
• Backend Deployment and internal ClusterIP service: helm/taskapp/templates/backend-deployment.yaml, helm/taskapp/templates/backend-service.yaml.
• Frontend Deployment, public service, and Nginx configuration: helm/taskapp/templates/frontend-deployment.yaml, helm/taskapp/templates/frontend-service.yaml, helm/taskapp/templates/frontend-nginx-configmap.yaml.
• Environment-specific image tags, RDS host, and load-balancer/TLS settings are supplied through helm/taskapp/values.yaml. Backend database credentials and JWT key are intentionally external Kubernetes Secrets.
GitOps delivery control flow
GitHub Actions validates, builds, scans, publishes immutable commit-SHA images to Docker Hub, and updates Helm image tags through .github/workflows/ci.yml. Argo CD watches the repository and reconciles the Helm chart into the taskapp namespace using argocd/taskapp-application.yaml; reconciliation includes automated drift correction/pruning. This makes Git and chart values the desired-state boundary, while Docker Hub is the image distribution dependency.
AWS and cluster foundation
Terraform bootstraps protected remote state separately in terraform/bootstrap/backend/main.tf, then composes the main environment from terraform/root/main.tf and reusable modules. Architecturally material modules include private networking (terraform/modules/vpc/main.tf), managed PostgreSQL (terraform/modules/rds/main.tf), DNS (terraform/modules/dns/main.tf), and state/object storage (terraform/modules/s3/main.tf). kOps defines the AWS Kubernetes control plane and workers in kops/cluster.yaml; workloads run on that cluster rather than directly on Terraform-managed compute.
Security and observability guardrails
Kyverno admission enforcement is defined in kyverno/policies/taskapp-deployment-security.yaml, requiring versioned images and hardened, resource-bounded pod settings for TaskApp deployments. Namespace separation begins in k8s/namespaces.yaml. Prometheus/Grafana are installed as platform services with configuration in monitoring/kube-prometheus-stack-values.yaml; the TaskApp chart exposes monitoring integration through helm/taskapp/templates/servicemonitor.yaml. Guarded lifecycle orchestration is provided by scripts/deploy.sh and scripts/destroy.sh.
Main entry points: values.yaml TaskApp Helm Chart · frontend-deployment.yaml Frontend Deployment · cluster.yaml kOps Kubernetes Cluster · main.tf Terraform Environment
Components 21
TaskApp
- Frontend Deployment · Serves the SPA and proxies /api/ to the backend.
helm/taskapp/templates/frontend-deployment.yaml - React SPA · Owns login state, protected routes, and task UI.
app/taskapp_frontend/src/main.tsx - API Client
app/taskapp_frontend/src/services/api.ts - Backend Deployment · Internal ClusterIP API service.
helm/taskapp/templates/backend-deployment.yaml - REST API & JWT Auth · Protects task operations and handles API requests.
app/taskapp_backend/app/routes.py - SQLAlchemy Models
app/taskapp_backend/app/models.py - Alembic Migrations
app/taskapp_backend/migrations/env.py
GitOps Delivery
- TaskApp Helm Chart · Defines workloads, services, Nginx, and monitoring integration.
helm/taskapp/values.yaml - GitHub Actions CI · Validates, scans, publishes SHA images, and updates chart tags.
.github/workflows/ci.yml - Docker Hub
- Argo CD · Automatically syncs, corrects drift, and prunes TaskApp resources.
argocd/taskapp-application.yaml
AWS Platform
- Public TLS Load Balancer
helm/taskapp/values.yaml - RDS PostgreSQL · Private application database.
terraform/modules/rds/main.tf - kOps Kubernetes Cluster · Hosts TaskApp and platform workloads.
kops/cluster.yaml - Terraform Environment · Composes reusable AWS foundation modules.
terraform/root/main.tf - Private VPC Networking
terraform/modules/vpc/main.tf - Terraform Remote State · Protected state backend bootstrapped separately.
terraform/bootstrap/backend/main.tf
Guardrails
- Kyverno Policies · Requires versioned images and hardened, resource-bounded TaskApp pods.
kyverno/policies/taskapp-deployment-security.yaml - Prometheus & Grafana
monitoring/kube-prometheus-stack-values.yaml - TaskApp ServiceMonitor
helm/taskapp/templates/servicemonitor.yaml
Other components
- Users
Connections 24
- Users → Public TLS Load Balancer: HTTPS
- Public TLS Load Balancer → Frontend Deployment: public service
- Frontend Deployment → React SPA: serves
- React SPA → API Client: task requests
- API Client → Frontend Deployment: /api/
- Frontend Deployment → Backend Deployment: Nginx proxy
- Backend Deployment → REST API & JWT Auth: routes requests
- REST API & JWT Auth → SQLAlchemy Models: persists tasks
- SQLAlchemy Models → RDS PostgreSQL: SQL
- Alembic Migrations → RDS PostgreSQL: evolves schema
- GitHub Actions CI → Docker Hub: publishes SHA images
- GitHub Actions CI → TaskApp Helm Chart: updates image tags
- TaskApp Helm Chart → Argo CD: desired state
- Argo CD → kOps Kubernetes Cluster: reconciles taskapp namespace
- Docker Hub → kOps Kubernetes Cluster: image pulls
- TaskApp Helm Chart → Frontend Deployment: renders workload
- TaskApp Helm Chart → Backend Deployment: renders workload
- Terraform Environment → Private VPC Networking: provisions
- Terraform Environment → RDS PostgreSQL: provisions
- Terraform Remote State → Terraform Environment: stores state
- Private VPC Networking → kOps Kubernetes Cluster: network foundation
- Kyverno Policies → kOps Kubernetes Cluster: admission enforcement
- TaskApp ServiceMonitor → Prometheus & Grafana: scrape target
- TaskApp Helm Chart → TaskApp ServiceMonitor: renders