This repository contains a FastAPI weather service that needs to be containerized and deployed to Kubernetes. However, there are several issues throughout the codebase that are preventing it from working correctly.
Your task is to:
- Write a Dockerfile, and build a docker image for the application
- Deploy it to a local Kubernetes cluster (minikube)
- Debug any issues you encounter
- Fix the problems
- Successfully deploy a working version of the application
- Debug the deployment if any issues arise
- Docker
- minikube
- Python 3.8+
fastapi-weather-app/
├── README.md
├── app/
│ ├── main.py
│ ├── weather_data.py
│ └── requirements.txt
├── Dockerfile [missing]
└── kubernetes/
└── deployment.yaml [with bugs]
Clone this repository and examine the code. The application is a simple weather API that provides forecasts for different cities.
python -m venv venv
source venv/bin/activate
pip install -r app/requirements.txt
export DB_CONNECTION_STRING="postgresql://user:password@localhost:5432/weather_db"
cd app && python main.pyCreate a Dockerfile in the root of the repository.
- Start minikube:
minikube start- Use minikube's Docker daemon:
eval $(minikube docker-env) # On Windows: minikube docker-env | Invoke-Expression- Build the image in minikube's environment:
docker xxx xxxxxx- Deploy to Kubernetes:
kubectl xxx xxxxxx- Check the deployment:
kubectl xxx xxxxxx
kubectl xxx xxxxxxkubectl xxx xxxxxxcurl $(minikube service weather-api-service --url)/health
curl $(minikube service weather-api-service --url)/weather/new%20york- Can you create a
publicnamespace and deploy the application there? Instead of thedefaultnamespace. - Can you use Helm & Helm Charts to deploy the application? If so, how?
Good luck!