diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 13566b8..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Editor-based HTTP Client requests
-/httpRequests/
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
diff --git a/.idea/copyright/MIT.xml b/.idea/copyright/MIT.xml
deleted file mode 100644
index 4e0ea94..0000000
--- a/.idea/copyright/MIT.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
index c3ba54a..9d2a8af 100644
--- a/.idea/copyright/profiles_settings.xml
+++ b/.idea/copyright/profiles_settings.xml
@@ -1,3 +1,3 @@
-
+
\ No newline at end of file
diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
deleted file mode 100644
index 82d5a32..0000000
--- a/.idea/dataSources.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
- sqlite.xerial
- true
- org.sqlite.JDBC
- jdbc:sqlite:$PROJECT_DIR$/build/test.db
-
-
-
- $ProjectFileDir$
-
-
- postgresql
- true
- Kube Eng :: PostgreSQL
- org.postgresql.Driver
- jdbc:postgresql://localhost:5432/postgres
-
-
-
-
-
-
- $ProjectFileDir$
-
-
- postgresql
- true
- Kube Eng :: PostgreSQL
- org.postgresql.Driver
- jdbc:postgresql://localhost:5432/postgres
-
-
-
-
-
- $ProjectFileDir$
-
-
-
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..c2bae49
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/markdown.xml b/.idea/markdown.xml
deleted file mode 100644
index 064f873..0000000
--- a/.idea/markdown.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index be83902..37c4310 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,7 +1,11 @@
-
+
-
+
+ /usr/local/bin/bower
+
+
+
\ No newline at end of file
diff --git a/.idea/mrmat-python-api-fastapi.iml b/.idea/mrmat-python-api-fastapi.iml
index 24ec1fd..3f0523f 100644
--- a/.idea/mrmat-python-api-fastapi.iml
+++ b/.idea/mrmat-python-api-fastapi.iml
@@ -1,17 +1,22 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/pylint.xml b/.idea/pylint.xml
deleted file mode 100644
index 86e7be6..0000000
--- a/.idea/pylint.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/build.xml b/.idea/runConfigurations/build.xml
deleted file mode 100644
index b921569..0000000
--- a/.idea/runConfigurations/build.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/lint.xml b/.idea/runConfigurations/lint.xml
deleted file mode 100644
index 58e3152..0000000
--- a/.idea/runConfigurations/lint.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/pytest_in_tests.xml b/.idea/runConfigurations/pytest_in_tests.xml
deleted file mode 100644
index e8629e0..0000000
--- a/.idea/runConfigurations/pytest_in_tests.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/run.xml b/.idea/runConfigurations/run.xml
deleted file mode 100644
index 98d83e2..0000000
--- a/.idea/runConfigurations/run.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vagrant.xml b/.idea/vagrant.xml
new file mode 100644
index 0000000..a5aa786
--- /dev/null
+++ b/.idea/vagrant.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index b762af0..35eb1dd 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,11 +1,6 @@
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 119f439..dde02b4 100644
--- a/Makefile
+++ b/Makefile
@@ -15,8 +15,18 @@ CONTAINER_SOURCES := $(shell find var/container)
HELM_SOURCES := $(shell find var/helm)
HELM_TARGET := dist/mrmat-python-api-fastapi-$(VERSION).tgz
-# Can be either 'sidecar' or 'ambient'
-ISTIO := ambient
+# My cluster names default to the hostname they run on
+CLUSTER_NAME := $(shell hostname -s)
+# Can be either 'istio-sidecar' or 'istio-ambient'
+MESH := istio-ambient
+# Can be 'ingress', 'gateway-api' or 'istio'
+EDGE := gateway-api
+
+# How the container then connects to its datastore
+API_DB_URL="sqlite:////data/db.sqlite3"
+
+# All of this can be overridden by the include in ~/etc/api-secrets.mk
+-include ~/etc/secrets.mk
all: python container helm
python: $(PYTHON_TARGET)
@@ -27,15 +37,17 @@ $(PYTHON_TARGET): $(PYTHON_SOURCES)
$(HELM_TARGET): $(HELM_SOURCES) container
helm package \
- --app-version "$(VERSION)" \
--version $(VERSION) \
+ --app-version "$(VERSION)" \
--destination dist/ \
var/helm
+ helm push dist/mrmat-python-api-fastapi-$(VERSION).tgz oci://localhost:5001/charts
-container: $(PYTHON_TARGET) $(CONTAINER_SOURCES)
+container: $(CONTAINER_SOURCES) $(PYTHON_TARGET)
docker build \
-f var/container/Dockerfile \
-t localhost:5001/mrmat-python-api-fastapi:$(VERSION) \
+ --build-arg GIT_SHA=$(GIT_SHA) \
--build-arg MRMAT_VERSION=$(VERSION) \
--build-arg WHEEL=$(PYTHON_TARGET) \
$(ROOT_PATH)
@@ -43,8 +55,8 @@ container: $(PYTHON_TARGET) $(CONTAINER_SOURCES)
helm-install: $(HELM_TARGET)
kubectl create ns mpafastapi || true
- if test "$(ISTIO)" == "sidecar"; then kubectl label --overwrite ns mpafastapi istio-injection=true; fi
- if test "$(ISTIO)" == "ambient"; then kubectl label --overwrite ns mpafastapi istio.io/dataplane-mode=ambient; fi
+ if test "$(MESH)" == "istio-sidecar"; then kubectl label --overwrite ns mpafastapi istio-injection=true; fi
+ if test "$(MESH)" == "istio-ambient"; then kubectl label --overwrite ns mpafastapi istio.io/dataplane-mode=ambient; fi
helm upgrade \
mrmat-python-api-fastapi \
${HELM_TARGET} \
@@ -52,7 +64,10 @@ helm-install: $(HELM_TARGET)
--wait \
--force \
--namespace mpafastapi \
- --set istio=$(ISTIO)
+ --set cluster.name=$(CLUSTER_NAME) \
+ --set cluster.mesh=$(MESH) \
+ --set edge.kind=$(EDGE) \
+ --set config.db_url=$(API_DB_URL)
helm-uninstall:
helm delete -n mpafastapi mrmat-python-api-fastapi
diff --git a/var/client-k8s.http b/var/client-k8s.http
index 30fe249..35f5268 100644
--- a/var/client-k8s.http
+++ b/var/client-k8s.http
@@ -1,11 +1,11 @@
### GET Owners
-GET https://mpafastapi.covenant.local/api/platform/v1/owners
+GET https://mpafastapi.covenant.k8s/api/platform/v1/owners
### GET resources
-GET https://mpafastapi.covenant.local/api/platform/v1/resources
+GET https://mpafastapi.covenant.k8s/api/platform/v1/resources
### Create Owner
-POST https://mpafastapi.covenant.local/api/platform/v1/owners
+POST https://mpafastapi.covenant.k8s/api/platform/v1/owners
Content-Type: application/json
{
diff --git a/var/container/Dockerfile b/var/container/Dockerfile
index b9c2c75..b2495e0 100644
--- a/var/container/Dockerfile
+++ b/var/container/Dockerfile
@@ -1,12 +1,23 @@
-FROM python:3.12-alpine AS build
+FROM python:3.13-alpine AS build
ARG MRMAT_VERSION="0.0.0.dev0"
+ARG GIT_SHA=""
ARG WHEEL=""
ADD "$WHEEL" /
RUN pip install --user /mrmat_python_api_fastapi-*.whl
-FROM python:3.12-alpine
+FROM python:3.13-alpine
ARG MRMAT_VERSION="0.0.0.dev0"
-LABEL VERSION=$MRMAT_VERSION
+ARG GIT_SHA=""
+
+LABEL org.opencontainers.image.title="MrMat :: Python API :: FastAPI"
+LABEL org.opencontainers.image.description="A demonstration of common API interactions using Python's FastAPI"
+LABEL org.opencontainers.image.authors="MrMat"
+LABEL org.opencontainers.image.vendor="The MrMat Organisation"
+LABEL org.opencontainers.image.licenses="MIT"
+LABEL org.opencontainers.image.version="$MRMAT_VERSION"
+LABEL org.opencontainers.image.revision="$GIT_SHA"
+LABEL org.opencontainers.image.source="https://github.com/MrMatAP/mrmat-python-api-fastapi"
+
RUN addgroup -g 1000 app && \
adduser -g 'App User' -u 1000 -G app -D app
COPY --from=build /root/.local /home/app/.local
diff --git a/var/helm/Chart.yaml b/var/helm/Chart.yaml
index 62ae3d6..bc5b27a 100644
--- a/var/helm/Chart.yaml
+++ b/var/helm/Chart.yaml
@@ -1,6 +1,18 @@
apiVersion: v2
name: mrmat-python-api-fastapi
description: A Helm chart for MrMat Python API FastAPI
+home: https://github.com/MrMatAP/mrmat-python-api-fastapi
+sources:
+- https://github.com/MrMatAP/mrmat-python-api-fastapi
+maintainers:
+- name: MrMat
+ email: imfeldma@gmail.com
+ url: https://github.com/MrMatAP
+annotations:
+ org.opencontainers.image.title: "MrMat :: Python API :: FastAPI"
+ org.opencontainers.image.authors: "MrMat"
+ org.opencontainers.image.vendor: "The MrMat Organisation"
+ org.opencontainers.image.licenses: "MIT"
type: application
version: "0.0.0"
appVersion: "0.0.0.dev0"
diff --git a/var/helm/LICENSE b/var/helm/LICENSE
new file mode 100644
index 0000000..263a877
--- /dev/null
+++ b/var/helm/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2021 Mathieu Imfeld
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/var/helm/templates/edge-istio-gateway-api.yaml b/var/helm/templates/edge-gateway-api.yaml
similarity index 71%
rename from var/helm/templates/edge-istio-gateway-api.yaml
rename to var/helm/templates/edge-gateway-api.yaml
index 9a462b5..2c09734 100644
--- a/var/helm/templates/edge-istio-gateway-api.yaml
+++ b/var/helm/templates/edge-gateway-api.yaml
@@ -1,15 +1,14 @@
-{{- if eq .Values.edge.kind "istio-gateway-api" -}}
+{{- if eq .Values.edge.kind "gateway-api" -}}
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
- name: {{ .Values.route.name }}
+ name: route-mpafastapi
labels:
+ app.kubernetes.io/name: route-mpafastapi
{{ include "common.labels" . | nindent 4 }}
spec:
hostnames:
- {{- range .Values.route.hostnames }}
- - {{ . | quote }}
- {{- end }}
+ - {{ .Values.route.hostname }}.{{ .Values.cluster.name }}.{{ .Values.cluster.domain }}
parentRefs:
- group: gateway.networking.k8s.io
kind: Gateway
diff --git a/var/helm/templates/edge-ingress.yaml b/var/helm/templates/edge-ingress.yaml
index 290972b..5d003d1 100644
--- a/var/helm/templates/edge-ingress.yaml
+++ b/var/helm/templates/edge-ingress.yaml
@@ -11,7 +11,7 @@ metadata:
spec:
tls:
- hosts:
- - {{ .Values.ingress.hostname }}
+ - {{ .Values.ingress.hostname }}.{{ .Values.cluster.name }}.{{ .Values.cluster.domain }}
secretName: mpafastapi-cert
rules:
- host: {{ .Values.ingress.hostname }}
diff --git a/var/helm/templates/edge-istio.yaml b/var/helm/templates/edge-istio.yaml
index fa743dd..dacdcdf 100644
--- a/var/helm/templates/edge-istio.yaml
+++ b/var/helm/templates/edge-istio.yaml
@@ -4,11 +4,30 @@ apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: waypoint
- namespace: {{ .Release.Namespace }}
+ labels:
+ app.kubernetes.io/name: waypoint
+ {{ include "common.labels" . | nindent 4 }}
spec:
gatewayClassName: istio-waypoint
listeners:
- name: mesh
port: 15008
protocol: HBONE
+---
+apiVersion: networking.istio.io/v1
+kind: VirtualService
+metadata:
+ name: vs
+ namespace: {{ .Release.Namespace }}
+ labels:
+ app.kubernetes.io/name: vs
+ {{ include "common.labels" . | nindent 4 }}
+spec:
+ hosts:
+ - mpafastapi.{{ .Release.Namespace }}.svc.cluster.local
+ http:
+ - name: "mpafastapi"
+ route:
+ - destination:
+ host: svc-mpafastapi.{{ .Release.Namespace }}.svc.cluster.local
{{- end }}
diff --git a/var/helm/values.yaml b/var/helm/values.yaml
index f8f1f55..e1b79c4 100644
--- a/var/helm/values.yaml
+++ b/var/helm/values.yaml
@@ -1,6 +1,12 @@
#
# Default values for MrMat :: Python API FastAPI
+cluster:
+ mesh: istio
+ gateway_api: true
+ name: cluster
+ domain: k8s
+
sa:
name: sa-mpafastapi
@@ -21,19 +27,10 @@ edge:
kind: istio-gateway-api
route:
- enabled: false
- name: route-mpafastapi
- hostnames:
- - mpafastapi.nostromo.k8s
- parents:
- - name: edge-ingress
- namespace: edge
-
-istio: ambient
+ hostname: mpafastapi
ingress:
- enabled: false
- hostname: mpafastapi.nostromo.k8s
+ hostname: mpafastapi
config:
db_url: "sqlite:////data/db.sqlite3"