แพลตฟอร์มแบบครบวงจร (Lean Edition): สำหรับ MLOps, Workflow Automation (Prefect), และ Project Management (Plane) — รองรับทั้ง Local Dev และ Production VM
เหมาะสำหรับ: พัฒนา Flow, ทดสอบโค้ด, Proof-of-Concept (ใช้ทรัพยากรต่ำสุด)
Requirements:
| Resource | Details |
|---|---|
| CPU/RAM | 2 Cores / 8 GB RAM (min) |
| Database | PostgreSQL (Lightweight) |
| Access | HTTP (No SSL/Authelia) |
| Orchestration | Docker Compose |
Core Services:
- Security: Vault (Secrets)
- Orchestration: Consul
- Project Mgt: Plane
- Prefect Server (Workflow Orchestration)
- MLflow Server (Experiment Tracking)
- PostgreSQL (MLOps Metadata)
- Traefik (HTTP Routing)
Deploy Commands:
# Start Stack
docker compose -f docker-compose.minimal.yaml up -d
# Run Development Flow (เช่น my_flow.py)
python my_flow.py
# Stop Stack
docker compose -f docker-compose.minimal.yaml downเหมาะสำหรับ: Production ที่ต้องการ Security, Scalability, Observability
Requirements:
| Resource | Details |
|---|---|
| VM Spec | 6 Cores / 16 GB RAM (reco.) |
| Security | Authelia (IdP, SSO, MFA) |
| Orchestration | Nomad + Vault (HashiStack) |
| Access | HTTPS (Traefik TLS) |
| Deployment | Ansible CLI (Control Node) |
Core Services:
- Security: Authelia (IdP), Vault (Secrets)
- Orchestration: Nomad, Consul
- Project Mgt: Plane
- Observability: Loki, Prometheus, Grafana, Tempo
- All MLOps Services: Prefect, MLflow, Label Studio, n8n
Deploy Commands (Ansible):
# Provisioning & Base Setup
ansible-playbook -i ansible/inventory/hosts.yml ansible/playbooks/02_base_setup.yml
# Initialize Vault & Inject Secrets (CRITICAL)
ansible-playbook -i ansible/inventory/hosts.yml ansible/playbooks/04_vault_init.yml
ansible-playbook -i ansible/inventory/hosts.yml ansible/playbooks/05_vault_config.yml
# Deploy Full Services Stack (Docker Compose)
ansible-playbook -i ansible/inventory/hosts.yml ansible/playbooks/07_full_stack_deploy.yml
# Submit Nomad Workloads (Vault Token required)
nomad job run config/nomad/prefect-server.nomad
nomad job run config/nomad/plane-app.nomad
# ... และ Jobs อื่นๆ ทั้งหมดโครงการนี้คือแพลตฟอร์มแบบครบวงจร (Lean Edition) ที่เน้นประสิทธิภาพด้านทรัพยากรสูงสำหรับการทำงานด้าน MLOps, Workflow Automation (Prefect), และ Project Management (Plane) เราได้แบ่งวิธีการ Deploy ออกเป็น 2 โหมดหลักเพื่อรองรับการทำงานในทุกสภาพแวดล้อม:
- Minimal Stack: สำหรับการพัฒนาบนเครื่อง Local ที่มีทรัพยากรจำกัด
- Full Stack: สำหรับ Production/Staging บน VM ที่มี Security และ Orchestration ครบถ้วน
วัตถุประสงค์: ใช้สำหรับการพัฒนา Flow, ทดสอบโค้ด, และการทำ Proof-of-Concept โดยใช้ทรัพยากรต่ำสุด
| ทรัพยากรที่ต้องการ | รายละเอียด |
|---|---|
| CPU/RAM | 2 Cores / 8 GB RAM (Minimum) |
| Database | PostgreSQL (Lightweight Configuration) |
| Access | HTTP (ไม่มี SSL/Authelia) |
| Orchestration | Docker Compose |
Stack นี้จะรันเฉพาะ Services ที่จำเป็นต่อการพัฒนา:
- Prefect Server: Workflow Orchestration Engine.
- MLflow Server: Experiment Tracking.
- PostgreSQL: ฐานข้อมูลหลักสำหรับ MLOps Metadata.
- Traefik (HTTP): Basic Routing.
ใช้ไฟล์ docker-compose.minimal.yaml ในการ Start/Stop Services:
- Start Stack:
docker compose -f docker-compose.minimal.yaml up -d
- Run Development Flow: (สมมติว่าไฟล์
my_flow.pyอยู่ใน Path ที่เข้าถึงได้)python my_flow.py
- Stop Stack:
docker compose -f docker-compose.minimal.yaml down
วัตถุประสงค์: สภาพแวดล้อม Production ที่มี Security, Scalability, และ Observability ครบถ้วน
| ทรัพยากรที่ต้องการ | รายละเอียด |
|---|---|
| VM Spec | 6 Cores / 16 GB RAM (Recommended) |
| Security | Authelia (IdP, SSO, MFA/Passkey) |
| Orchestration | Nomad + Vault (HashiStack) |
| Access | HTTPS (Traefik ทำ TLS) |
| Deployment | Ansible CLI (Control Node) |
Stack นี้ประกอบด้วย Services ทั้งหมด (รวมถึง Services ที่ถูกตัดออกจาก Minimal Stack):
- Security: Authelia (IdP), Vault (Secret Management).
- Orchestration: Nomad, Consul.
- Project Mgt: Plane.
- Observability: Loki, Prometheus, Grafana, Tempo.
- All MLOps Services: Prefect, MLflow, Label Studio, n8n.
การ Deploy Full Stack ต้องผ่าน Ansible Playbooks เพื่อจัดการ Vault Secrets และ Orchestration อย่างปลอดภัย
- Provisioning & Base Setup:
ansible-playbook -i ansible/inventory/hosts.yml ansible/playbooks/02_base_setup.yml
- Initialize Vault & Inject Secrets: (CRITICAL STEP)
ansible-playbook -i ansible/inventory/hosts.yml ansible/playbooks/04_vault_init.yml ansible-playbook -i ansible/inventory/hosts.yml ansible/playbooks/05_vault_config.yml
- Deploy Full Services Stack (Docker Compose): Deploy Core Services, Security, และ Project Services
ansible-playbook -i ansible/inventory/hosts.yml ansible/playbooks/07_full_stack_deploy.yml
- Submit Nomad Workloads: (รันจาก Local CLI ที่มีสิทธิ์ Vault Token)
nomad job run config/nomad/prefect-server.nomad nomad job run config/nomad/plane-app.nomad # ... และ Jobs อื่นๆ ทั้งหมด
ทุก Services ใน Full Stack ถูกป้องกันโดย Authelia (SSO, MFA, Passkey/WebAuthn)
| Service | URL | Authentication |
|---|---|---|
| Plane | https://plane.yourdomain.com | Authelia SSO |
| Prefect | https://prefect.yourdomain.com | Authelia SSO |
| Grafana | https://grafana.yourdomain.com | Authelia SSO |
ยินดีรับทุกข้อเสนอแนะ! หากต้องการปรับปรุง Minimal Stack หรือ Nomad Job Specs สำหรับ Full Stack โปรดเปิด Issue หรือ Pull Request
Distributed under the MIT License.
ทุก Services ใน Full Stack ถูกป้องกันโดย Authelia เพื่อบังคับใช้ Single Sign-On (SSO) และ Multi-Factor Authentication (MFA) รวมถึงการรองรับ Passkey/WebAuthn
| Service | URL (ผ่าน Traefik) | Authentication |
|---|---|---|
| Plane | https://plane.yourdomain.com |
Authelia SSO |
| Prefect | https://prefect.yourdomain.com |
Authelia SSO |
| Grafana | https://grafana.yourdomain.com |
Authelia SSO |
ยินดีรับทุกข้อเสนอแนะ! หากคุณต้องการปรับปรุงการตั้งค่า Minimal Stack หรือปรับปรุง Nomad Job Specs สำหรับ Full Stack โปรดเปิด Issue หรือ Pull Request
โครงการนี้อยู่ภายใต้ลิขสิทธิ์ MIT License
โครงสร้างนี้ออกแบบให้
ansibleและdocker-composeอ้างอิงไฟล์ในconfigและdataได้ง่าย
monolith-lean-platform/
├── .gitignore # Ignore rules (e.g., /data/, *.env, Vault Tokens)
├── README.md # Project overview & guides
├── LICENSE # License
│
├── docker-compose/ # Docker Compose files (per stack)
│ ├── docker-compose.minimal.yaml # For Local Dev (Prefect, MLflow, DB)
│ └── docker-compose.full.yaml # For VM Prod (used by Ansible)
│
├── ansible/ # Provisioning & VM config (Full Stack)
│ ├── inventory/
│ │ └── hosts.yml # VM IP/User
│ ├── roles/ # (Optional) reusable roles
│ ├── playbooks/ # Main deploy playbooks
│ └── vault/
│ └── project_secrets.yml # Encrypted secrets (Ansible Vault)
│
├── config/ # All service configs
│ ├── authelia/ # Authelia config & rules
│ ├── nomad/ # Nomad job specs (*.nomad)
│ ├── vault/ # Vault policies & setup
│ ├── traefik/ # Traefik routers, middlewares, TLS
│ ├── postgres/ # PostgreSQL config (schemas, etc.)
│ └── grafana/ # Grafana configs & dashboards
│
├── app/ # Main app code (backend/frontend)
│ ├── backend/
│ └── frontend/
│
├── prefect_flows/ # Prefect Flows (Python)
│ ├── ci_cd_flows.py # CI/CD flows
│ └── mlops_flows.py # MLOps pipelines
│
└── data/ # Persistent storage volumes
├── postgres/ # DB data
├── vault/ # Vault storage backend
├── minio/ # MinIO artifacts
└── prometheus/ # Metrics data
1. Shared Configuration
/config: Central for all configs. Minimal Stack uses only Prefect, MLflow, Traefik configs, but Full Stack can reuse all.
2. Deployment Separation
/docker-compose: For Minimal Stack (local dev)..minimal.yamlmounts only needed volumes./ansible: For Full Stack (VM/Prod). Playbooks usedocker-compose.full.yamlandnomad job runfor workloads.
3. Application Logic
/prefect_flows: Python logic for Prefect Agent (local or Nomad). Decoupled for easy testing.