Infrastructure as Code for Data-Science-AI Projects

A complete end-to-end stack from server provisioning to security hardening for Data Science and AI.

🏠 Project Idea

This project sets up a reusable infrastructure stack for Data Science and AI workloadsβ€”from provisioning Linux servers to container orchestration, monitoring, and security.

🧠 Stack Overview

  • Provisioning with Ansible
  • Containerization with Docker
  • Lightweight Kubernetes via MicroK8s
  • Monitoring with Prometheus and Grafana
  • Logging via the ELK Stack
  • Security Hardening using SSH rules, firewall (UFW), and service accounts

πŸ“ Project Structure

project-root/
β”œβ”€β”€ infra/ansible/
β”‚   β”œβ”€β”€ inventory.ini
β”‚   β”œβ”€β”€ playbook.yml
β”‚   └── roles/
β”‚       β”œβ”€β”€ docker/
β”‚       β”œβ”€β”€ kubernetes/
β”‚       β”œβ”€β”€ monitoring/
β”‚       └── security/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ etl/
β”‚   β”œβ”€β”€ ml/
β”‚   └── k8s/
β”œβ”€β”€ monitoring/
└── security/

βš™οΈ 1. Provisioning with Ansible

Each role automates system setup:

  • docker: Installs Docker and adds user to docker group
  • kubernetes: Installs MicroK8s, exports kubeconfig
  • monitoring: Starts Prometheus, Grafana, and ELK containers
  • security: SSH hardening, firewall setup, service accounts

πŸ“¦ 2. Docker Containers

  • system-health-api (FastAPI ML model)
  • prom/prometheus (metrics collection)
  • grafana/grafana (data visualization)
  • ELK: Elasticsearch, Logstash, Kibana for centralized logs

πŸ› οΈ 3. Kubernetes (MicroK8s)

Used MicroK8s for lightweight local cluster with DNS, Dashboard. Manifests stored in app/k8s/.

πŸ“Š 4. Observability

  • Prometheus: Scrapes node/container metrics
  • Grafana: Visual dashboards
  • ELK: Log processing and search

πŸ›‘οΈ 5. Security Hardening

  • sshd_config: Key-only login, root login disabled
  • ufw_rules.sh: Only necessary ports open
  • users.yml: Non-shell service users

βœ… Outcome

This setup offers consistent, repeatable, secure infrastructure for AI/Data pipelines deployable on any VM or cloud instance.

πŸš€ Next Steps

  • Add Kafka/MQTT for data ingestion
  • Enable Prometheus alerting
  • Integrate GitHub Actions for CI/CD

πŸ“Ž GitHub Repo

github.com/dipsah9/so-dev