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
|
from flask import Flask, request, jsonify
|
||||||
import redis
|
import redis
|
||||||
|
|
||||||
|
import random
|
||||||
|
|
||||||
|
my_random_id = random.randrange(100)
|
||||||
|
|
||||||
r = redis.Redis(host='redis', port=6379)
|
r = redis.Redis(host='redis', port=6379)
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@app.route("/id", methods=["GET"])
|
||||||
|
def id():
|
||||||
|
return f"{my_random_id}\n"
|
||||||
|
|
||||||
@app.route("/items", methods=["GET", "POST"])
|
@app.route("/items", methods=["GET", "POST"])
|
||||||
def items():
|
def items():
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: shoppinglist-frontend
|
name: shoppinglist-frontend
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: 3
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: shoppinglist-frontend
|
app: shoppinglist-frontend
|
||||||
|
|
@ -15,6 +15,7 @@ spec:
|
||||||
containers:
|
containers:
|
||||||
- name: frontend
|
- name: frontend
|
||||||
image: shoppinglist-frontend:latest
|
image: shoppinglist-frontend:latest
|
||||||
|
imagePullPolicy: Never
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 5000
|
- containerPort: 5000
|
||||||
env:
|
env:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue