- An "app" container serving the flask application on gunicorn server @ port 5001
- A "nginx" container serving the nginx service @ port 8081
- A nginx configuration (proxy pass directive) is used to route incoming requests to Nginx (port:8081) to the flask app named "app" running on port:5001.
- Git clone repository
gitclone https://github.com/sshuen30/flask-project.git
-
cd into flask-project
-
Start docker compose
docker-compose up -d
- Start docker compose and scale 3 containers for app
docker-compose up -d --build --scale app=3 (To create 3 containers for app)
- Stop docker compose
docker-compose down
- Browser: xxx.xxx.x.xx:8081
- Copy flask-development.yaml and flask-service into a kubernetes cluster (eg, Google Cloud)
- Start a deployment
kubectl apply -f flask-development.yaml
- Start a load balancer service to route traffic to deployment - no need for nginx
kubectl apply -f flask-service.yaml
- Get IP and port no. of service
kubectl get svc meme-flask-service
- Scale deployment to 2 pods
kubectl scale deployment meme-flask-deployment --replicas=2
- Change deployment image
kubectl set image deployment/meme-flask-deployment meme-flask=sshuen30/flask-app:v1