app.py | ||
deployment.yaml | ||
Dockerfile | ||
README.md | ||
requirements.txt | ||
service.yaml | ||
tthread.py |
K8sPy
A simple test how to get a py flask app run on kubernetes.
1. For Docker
Instructions
-
docker build -t flaskapp .
-
docker images -a
-
docker run -d -p 80:8000 flaskapp
-> Open Browser: http://localhost
Endpoints:
- /start-thread/
- /start-thread
- /stop-thread/
- /stop-thread
- /content/
- /content
2. For Kubernetes
Here this is just testing with minikube!!!! (Adjust the imagePullPolicy to Never when using Minikube)
This will create a cluster with 5 nodes and 10 replica pods; On average(!) 2 pods per node, but does not have to be!
-
$ minikube start --nodes=5
-
$ minikube nodes list
-
$ minikube image load flaskapp
-
$ minikube kubectl -- apply -f deployment.yaml -f service.yaml
-
$ minikube kubectl -- get pods
-
$ minikube kubectl -- get pods -o json
-
$ minikube service list -> open URL in Browser and have fun! :)
-
$ minikube delete