Multinode simple python app

main
John Kenyon 2025-06-20 23:24:33 -07:00
parent 8c89d039c4
commit d9c654c54e
7 changed files with 25 additions and 1 deletions

15
simple-proj/Makefile Normal file
View File

@ -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

View File

@ -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":

View File

@ -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: