Skip to content

Commit fb71728

Browse files
committed
Deployment and Prometheus Metrics
1 parent a897606 commit fb71728

7 files changed

Lines changed: 15 additions & 5 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ helm-install: $(HELM_TARGET)
4343
mrmat-python-api-fastapi \
4444
${HELM_TARGET} \
4545
--install \
46+
--force \
4647
--create-namespace \
4748
--namespace mrmat-python-api-fastapi
4849

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ fastapi==0.115.11 # MIT
55
sqlalchemy[asyncio]==2.0.40 # MIT
66
uvicorn==0.34.0 # BSD 3-Clause
77
pydantic==2.10.6 # MIT
8+
prometheus-fastapi-instrumentator==7.1.0 # ISC

src/mrmat_python_api_fastapi/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
from fastapi import FastAPI
2424

25+
from prometheus_fastapi_instrumentator import Instrumentator
26+
2527
from mrmat_python_api_fastapi.apis.healthz import api_healthz
2628
from mrmat_python_api_fastapi.apis.greeting import api_greeting_v1, api_greeting_v2, api_greeting_v3
2729
from mrmat_python_api_fastapi.apis.platform import api_platform_v1
@@ -33,6 +35,7 @@
3335
app.include_router(api_greeting_v3, prefix='/api/greeting/v3', tags=['greeting'])
3436
app.include_router(api_platform_v1, prefix='/api/platform/v1', tags=['platform'])
3537

38+
Instrumentator().instrument(app).expose(app)
3639

3740
@app.get('/')
3841
def index():

var/container/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ RUN chown -R 1000:1000 /home/app/.local
1414

1515
USER app:app
1616
EXPOSE 8000
17-
#CMD ["/home/app/.local/bin/uvicorn", "--host", "0.0.0.0", "--port", "8000", "mrmat_python_api_fastapi.app:app"]
18-
CMD ["/home/app/.local/bin/mrmat-python-api-fastapi"]
17+
CMD ["/home/app/.local/bin/uvicorn", "--host", "0.0.0.0", "--port", "8000", "mrmat_python_api_fastapi.app:app"]
18+
#CMD ["/home/app/.local/bin/mrmat-python-api-fastapi"]

var/helm/templates/deployment.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ spec:
1919
version: {{ .Chart.AppVersion }}
2020
app.kubernetes.io/name: mrmat-python-api-fastapi
2121
app.kubernetes.io/part-of: mrmat-python-api-fastapi
22+
annotations:
23+
prometheus.io/scrape: "true"
24+
prometheus.io/scheme: http
25+
prometheus.io/port: "8000"
26+
prometheus.io/path: /metrics
2227
spec:
2328
serviceAccountName: {{ .Values.serviceAccount.name }}
2429
containers:

var/helm/templates/httproute.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ spec:
1313
{{- range .Values.httproute.hostnames }}
1414
- {{ . | quote }}
1515
{{- end }}
16-
- mrmat-python-api-fastapi.local
1716
parentRefs:
1817
{{- range .Values.httproute.parents }}
1918
- group: gateway.networking.k8s.io
2019
kind: Gateway
2120
name: {{ .name }}
2221
namespace: {{ .namespace }}
22+
sectionName: mrmat-python-api-fastapi
2323
{{- end }}
2424
rules:
2525
- backendRefs:

var/helm/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ httproute:
2323
enabled: true
2424
name: mrmat-python-api-fastapi-httproute
2525
hostnames:
26-
- mrmat-python-api-fastapi.local
26+
- mrmat-python-api-fastapi.covenant.local
2727
parents:
28-
- name: istio-ingress
28+
- name: edge-ingress
2929
namespace: edge
3030

3131
ingress:

0 commit comments

Comments
 (0)