This project houses the code and configuration for an ETL (Extract, Transform, Load) pipeline designed to fetch NASA's Astronomy Picture of the Day (APOD) data and store it in a PostgreSQL database. The pipeline is orchestrated using Apache Airflow, ensuring seamless data flow and scheduling. Additionally, the setup is containerized with Docker and includes Kubernetes configurations for scalable deployment.
- Fetches daily APOD data from NASA's API. 🌠
- Transforms the data into a structured format. 📊
- Loads the data into a PostgreSQL database. 🗄️
- Scheduled to run daily using Apache Airflow. ⏰
- Dockerized for easy deployment. 🐳
- Kubernetes deployment configuration for scalability. ☸️
Before you begin, ensure you have the following installed:
- Docker
- Docker Compose
- Kubernetes (optional, for deployment)
- Python 3.x
- Apache Airflow
- Astronomer
- Clone the repository:
git clone https://github.com/snehaapratap/NASA_APOD_DATA.git
cd NASA_APOD_DATA- Build the Docker image:
docker build -t snehaapratap/nasa-apod-k8s .-
Airflow Connections:
-
Create a connection in Airflow for the NASA API with the following details:
- Conn Id:
nasa_api - Conn Type:
HTTP - Host:
https://api.nasa.gov/ - Extra:
{"api_key": "YOUR_NASA_API_KEY"}
- Conn Id:
-
Create a connection in Airflow for the PostgreSQL database with the following details:
- Conn Id:
my_postgres_connection - Conn Type:
Postgres - Host:
postgres_db - Schema:
postgres - Login:
postgres - Password:
postgres - Port:
5432
- Conn Id:
-
-
Environment Variables:
- Ensure the following environment variables are set:
AIRFLOW_HOME: Path to your Airflow home directory.
- Ensure the following environment variables are set:
- Start the PostgreSQL service:
docker-compose up -d postgres- Initialize the Airflow database using astronomer:
astro dev init- Start the Airflow web server :
astro dev start
- Access the Airflow UI at
http://localhost:8080and trigger thenasa_apod_postgresDAG.
To run the tests, use the following command:
pytest tests/To deploy the application on Kubernetes, follow these steps:
- Create the namespace:
kubectl apply -f k8s/namespace.yml- Deploy the application:
kubectl apply -f k8s/deployment.yml
kubectl apply -f k8s/service.ymlContributions are welcome! Please open an issue or submit a pull request.