Topic: FastAPI in Docker swarm with Postgres database + ORM
Key Takeaway:
- How to configure Docker Swarm by creating a master and worker node
- How to deploy a FastAPI backend with ORM and Postgres server to run in configured Docker Swarm
- How to replicate web app to 3
Steps:
Make sure all worker node are ready if not update iptable to allow connect and leave and join again to master
Transfer App folder which contain source , docker file , docker-compose yml to master node using file zilla
docker pull postgres:15-alpine // will pull posgres image
docker-compose build // it will build app image for local
docker stack deploy -c docker-compose.yml nahid_apps //deploy the stack in docker swarm
now call swagger http://192.168.0.121:8000/docs
table will auto created
user swagger to create a new sample user and get a list to see if it added a new user
for any error see the service logs
docker service ls
docker service logs nahid_apps_db
Commit Ref:
Readme : Wiki for Docker Swarm in Home Network
Topic: FastAPI in minikube with Postgres database with configmap and secret
Key Takeaway:
- How to apply configmap and secret in kubernets in deployment file as db user ,password , db host etc
- How to troubleshoot CrashLoopBackOff
use `kubectl describe pod x ` and then `kubectl logs pods to identify problem
- How to use base64 encoded db username and password in a secret file and how to decode in main.py
Commit Ref: dc1c52e9f6ad98d7e988e9ab3316f5d5fa47b201
Topic: FastAPI with Postgres database using Docker compose and ORM
Key Takeaway:
- Deploy Postgresql database
- Deploy fast API API set with CRUD operation
- ORM used for Postgres connectivity
- SQLite in database.py for in-memory database
- Service declared in docker-compose file, where fast API connect with db
docker-compose up -d --build
docker-compose logs app
after run:
from browser http://localhost:8000/docs
for swagger
Topic: FastAPI in minikube with Postgres database
Key Takeaway:
- Deploy Postgresql database
- Deploy fast API API set with CRUD operation with load balancer
- Python client added for database entry
- Learned how to resolve 'ImpagePullBackoff' problem by running and push in local registry
- Docker Registry created, build an image with name and tag and push to local docker repository
Topic: FastAPI in minikube
Key Takeaway:
Minikube and docker env sync
Reason behind the imagepullbackoff in minikube's own docker env
How to run simple FastAPI in minikube environment
How to see events easily in minikube dashboard
How to check minikube's kubernet config file
Topic: Mongo Express with Mongo DB
Key Takeaway:
- How to deploy MongoDB image in Kubernetes with deployment and service without exposing the external world
- How to deploy MongoDB express with exposed service
- How to use Kubernetes Config
- How to use Kubernetes Secret
-
ISTIO Setup - Sample Book Info- Visualiging Service Mesh
Docker Registry
Resources
This section should list any major frameworks/libraries used to bootstrap your project. Leave any add-ons/plugins for the acknowledgements section. Here are a few examples.