Multinode simple python app
parent
8c89d039c4
commit
d9c654c54e
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
image: Dockerfile
|
||||
docker build -t shoppinglist-frontend:latest .
|
||||
|
||||
load:
|
||||
kind load docker-image shoppinglist-frontend:latest
|
||||
|
||||
apply:
|
||||
kubectl apply -f k8s/
|
||||
|
||||
restart:
|
||||
kubectl delete pod -l app=shoppinglist-frontend
|
||||
|
||||
watch:
|
||||
kubectl get pods -l app=shoppinglist-frontend -w
|
||||
|
|
@ -2,9 +2,17 @@
|
|||
from flask import Flask, request, jsonify
|
||||
import redis
|
||||
|
||||
import random
|
||||
|
||||
my_random_id = random.randrange(100)
|
||||
|
||||
r = redis.Redis(host='redis', port=6379)
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route("/id", methods=["GET"])
|
||||
def id():
|
||||
return f"{my_random_id}\n"
|
||||
|
||||
@app.route("/items", methods=["GET", "POST"])
|
||||
def items():
|
||||
if request.method == "POST":
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ kind: Deployment
|
|||
metadata:
|
||||
name: shoppinglist-frontend
|
||||
spec:
|
||||
replicas: 1
|
||||
replicas: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
app: shoppinglist-frontend
|
||||
|
|
@ -15,6 +15,7 @@ spec:
|
|||
containers:
|
||||
- name: frontend
|
||||
image: shoppinglist-frontend:latest
|
||||
imagePullPolicy: Never
|
||||
ports:
|
||||
- containerPort: 5000
|
||||
env:
|
||||
|
|
|
|||
Loading…
Reference in New Issue