File tree Expand file tree Collapse file tree 7 files changed +39
-12
lines changed
src/mrmat_python_api_fastapi Expand file tree Collapse file tree 7 files changed +39
-12
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ CONTAINER_SOURCES := $(shell find var/container)
1515HELM_SOURCES := $(shell find var/helm)
1616HELM_TARGET := dist/mrmat-python-api-fastapi-$(VERSION ) .tgz
1717
18+ # Can be either 'sidecar' or 'ambient'
19+ ISTIO := ambient
20+
1821all : python container helm
1922python : $(PYTHON_TARGET )
2023helm : $(HELM_TARGET )
@@ -40,13 +43,16 @@ container: $(PYTHON_TARGET) $(CONTAINER_SOURCES)
4043
4144helm-install : $(HELM_TARGET )
4245 kubectl create ns mpafastapi || true
43- kubectl label --overwrite ns mpafastapi istio-injection=true
46+ if test " $( ISTIO) " == " sidecar" ; then kubectl label --overwrite ns mpafastapi istio-injection=true; fi
47+ if test " $( ISTIO) " == " ambient" ; then kubectl label --overwrite ns mpafastapi istio.io/dataplane-mode=ambient; fi
4448 helm upgrade \
4549 mrmat-python-api-fastapi \
4650 ${HELM_TARGET} \
4751 --install \
52+ --wait \
4853 --force \
49- --namespace mpafastapi
54+ --namespace mpafastapi \
55+ --set istio=$(ISTIO )
5056
5157helm-uninstall :
5258 helm delete -n mpafastapi mrmat-python-api-fastapi
Original file line number Diff line number Diff line change 2121# SOFTWARE.
2222
2323from fastapi import FastAPI
24+ from fastapi .security import OAuth2PasswordBearer
2425
2526from prometheus_fastapi_instrumentator import Instrumentator
2627
2930from mrmat_python_api_fastapi .apis .platform import api_platform_v1
3031
3132app = FastAPI (title = 'MrMat :: Python :: API :: FastAPI' )
33+ oauth2_scheme = OAuth2PasswordBearer (tokenUrl = 'token' )
3234app .include_router (api_healthz , prefix = '/api/healthz' , tags = ['health' ])
3335app .include_router (api_greeting_v1 , prefix = '/api/greeting/v1' , tags = ['greeting' ])
3436app .include_router (api_greeting_v2 , prefix = '/api/greeting/v2' , tags = ['greeting' ])
Original file line number Diff line number Diff line change 3737 - name : APP_CONFIG
3838 value : /config/app_config.json
3939 - name : OTEL_SERVICE_NAME
40- value : " mrmat-python-api-fastapi "
40+ value : " {{ .Release.Namespace }}.mpafastapi "
4141 - name : OTEL_TRACES_EXPORTER
4242 value : " otlp"
4343 - name : OTEL_METRICS_EXPORTER
Original file line number Diff line number Diff line change 1- {{- if .Values.ingress.enabled }}
1+ {{- if eq .Values.edge.kind "ingress" }}
22---
33apiVersion : networking.k8s.io/v1
44kind : Ingress
Original file line number Diff line number Diff line change 1- {{- if .Values.route.enabled -}}
1+ {{- if eq .Values.edge.kind "istio-gateway-api" -}}
22apiVersion : gateway.networking.k8s.io/v1
33kind : HTTPRoute
44metadata :
@@ -11,13 +11,11 @@ spec:
1111 - {{ . | quote }}
1212 {{- end }}
1313 parentRefs :
14- {{- range .Values.route.parents }}
1514 - group : gateway.networking.k8s.io
1615 kind : Gateway
17- name : {{ .name }}
18- namespace : {{ .namespace }}
16+ name : {{ .Values.edge. name }}
17+ namespace : {{ .Values.edge.ns }}
1918 sectionName : mpafastapi
20- {{- end }}
2119 rules :
2220 - backendRefs :
2321 - kind : Service
Original file line number Diff line number Diff line change 1+ {{- if eq .Values.edge.kind "istio" }}
2+ ---
3+ apiVersion : gateway.networking.k8s.io/v1
4+ kind : Gateway
5+ metadata :
6+ name : waypoint
7+ namespace : {{ .Release.Namespace }}
8+ spec :
9+ gatewayClassName : istio-waypoint
10+ listeners :
11+ - name : mesh
12+ port : 15008
13+ protocol : HBONE
14+ {{- end }}
Original file line number Diff line number Diff line change 1515 name : svc-mpafastapi
1616 port : 80
1717
18+ edge :
19+ ns : edge
20+ name : edge-ingress
21+ kind : istio-gateway-api
22+
1823route :
1924 enabled : false
2025 name : route-mpafastapi
2126 hostnames :
22- - mpafastapi.covenant.local
27+ - mpafastapi.nostromo.k8s
2328 parents :
2429 - name : edge-ingress
2530 namespace : edge
2631
32+ istio : ambient
33+
2734ingress :
28- enabled : true
35+ enabled : false
2936 hostname : mpafastapi.nostromo.k8s
3037
3138config :
32- db_url : " sqlite://data/db.sqlite3"
39+ db_url : " sqlite://// data/db.sqlite3"
You can’t perform that action at this time.
0 commit comments