healthz
This commit is contained in:
parent
4ad7bdd164
commit
701b43a22a
4 changed files with 89 additions and 8 deletions
|
|
@ -4,5 +4,6 @@ WORKDIR /app
|
|||
COPY hello-world/app.py .
|
||||
ENV FLASK_APP=app.py
|
||||
ENV FLASK_RUN_HOST=0.0.0.0
|
||||
HEALTHCHECK CMD curl --fail http://localhost:5000/healthz || exit 1
|
||||
CMD ["flask", "run"]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,90 @@
|
|||
from flask import Flask
|
||||
from pathlib import Path
|
||||
|
||||
from flask import Flask, request
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
LIVE = Path("livez")
|
||||
LIVE.write_text("ok")
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def hello_world():
|
||||
return "Hello, V2"
|
||||
version = "v3"
|
||||
if "5000" in request.base_url:
|
||||
mode = "local"
|
||||
header_color = "#a0dfa0"
|
||||
elif "30001" in request.base_url:
|
||||
mode = "active"
|
||||
header_color = "#a0c0df"
|
||||
elif "30002" in request.base_url:
|
||||
mode = "preview"
|
||||
header_color = "#dfa0df"
|
||||
else:
|
||||
mode = "unknown"
|
||||
header_color = "#dfc0a0"
|
||||
import time
|
||||
|
||||
LIVE.write_text("no")
|
||||
time.sleep(10)
|
||||
LIVE.write_text("ok")
|
||||
|
||||
return f"""
|
||||
<html>
|
||||
<head>
|
||||
<title>{mode}: Hello, World!</title>
|
||||
<style>
|
||||
body {{
|
||||
width: 100vw;
|
||||
height: calc(100vh - 100px);
|
||||
background-color: #333;
|
||||
color: #eee;
|
||||
margin: 0 auto;
|
||||
font-family: Tahoma, Verdana, Arial, sans-serif;
|
||||
}}
|
||||
|
||||
main {{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}}
|
||||
header {{
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
background-color: {header_color};
|
||||
color: #333;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<h2>{mode}: Hello, World! {version}</h2>
|
||||
</header>
|
||||
<main>
|
||||
<h1>Hello, World!</h1>
|
||||
<p>Mode: {mode}</p>
|
||||
<p>Version: {version}</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
|
||||
@app.route("/healthz")
|
||||
def healthz():
|
||||
# return "failed", 500
|
||||
return "I'm still here.", 200
|
||||
|
||||
|
||||
@app.route("/livez")
|
||||
def livez():
|
||||
if LIVE.read_text() == "ok":
|
||||
return "All done working here."
|
||||
return "I'm working here!", 500
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ spec:
|
|||
image: docker.io/waylonwalker/learn-rollouts:v1
|
||||
ports:
|
||||
- containerPort: 5000
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /-/healthz
|
||||
port: 5000
|
||||
strategy:
|
||||
blueGreen:
|
||||
# activeService specifies the service to update with the new template hash at time of promotion.
|
||||
|
|
|
|||
|
|
@ -1,9 +1,3 @@
|
|||
# create argo-rollouts namespace
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: argo-rollouts
|
||||
|
||||
# This is an auto-generated file. DO NOT EDIT
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue