gitops-status-api/README.md
2026-04-21 13:10:31 +03:00

87 lines
1.9 KiB
Markdown

# GitOps Status API
Simple Flask API for serving and updating GitOps status information.
## Features
- **GET /status.json** - Retrieve current status in JSON format
- **GET /api/status** - API endpoint to retrieve status
- **POST /api/status** - Update status with new data
- **GET /health** - Kubernetes liveness probe
- **GET /ready** - Kubernetes readiness probe
## Local Development
```bash
# Install dependencies
pip install -r requirements.txt
# Run the app
python app.py
# Test
curl http://localhost:5000/status.json
curl -X POST http://localhost:5000/api/status -H "Content-Type: application/json" -d '{"sync_status":"SYNCED"}'
```
## Docker Build
```bash
# Build the image
docker build -t gitops-status-api:1.0.0 .
# Run locally
docker run -it -p 5000:5000 -v /tmp/data:/data gitops-status-api:1.0.0
```
## Push to Harbor
```bash
# Login to Harbor
docker login harbor.your-domain.com
# Tag for Harbor
docker tag gitops-status-api:1.0.0 harbor.your-domain.com/gitops/status-api:1.0.0
docker tag gitops-status-api:1.0.0 harbor.your-domain.com/gitops/status-api:latest
# Push to Harbor
docker push harbor.your-domain.com/gitops/status-api:1.0.0
docker push harbor.your-domain.com/gitops/status-api:latest
```
## Environment Variables
- `API_HOST` - Listen address (default: 0.0.0.0)
- `API_PORT` - Listen port (default: 5000)
- `STATUS_FILE` - Path to status.json file (default: /data/status.json)
- `FLASK_ENV` - Flask environment (default: production)
## API Examples
### Get status
```bash
curl http://localhost:5000/status.json
curl http://localhost:5000/api/status
```
### Update status
```bash
curl -X POST http://localhost:5000/api/status \
-H "Content-Type: application/json" \
-d '{
"sync_status": "SYNCED",
"drift_count": 0,
"files": ["app1", "app2"]
}'
```
### Check health
```bash
curl http://localhost:5000/health
curl http://localhost:5000/ready
```
## Version
1.0.0