Skip to content

Commit 1fa0567

Browse files
committed
Support for additional mesh and edge configurations and other maintenance
1 parent 823a56e commit 1fa0567

File tree

9 files changed

+94
-28
lines changed

9 files changed

+94
-28
lines changed

.idea/misc.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,18 @@ CONTAINER_SOURCES := $(shell find var/container)
1515
HELM_SOURCES := $(shell find var/helm)
1616
HELM_TARGET := dist/mrmat-python-api-fastapi-$(VERSION).tgz
1717

18-
# Can be either 'sidecar' or 'ambient'
19-
ISTIO := ambient
18+
# My cluster names default to the hostname they run on
19+
CLUSTER_NAME := $(shell hostname -s)
20+
# Can be either 'istio-sidecar' or 'istio-ambient'
21+
MESH := istio-ambient
22+
# Can be 'ingress', 'gateway-api' or 'istio'
23+
EDGE := gateway-api
24+
25+
# How the container then connects to its datastore
26+
API_DB_URL="sqlite:////data/db.sqlite3"
27+
28+
# All of this can be overridden by the include in ~/etc/api-secrets.mk
29+
-include ~/etc/secrets.mk
2030

2131
all: python container helm
2232
python: $(PYTHON_TARGET)
@@ -27,32 +37,37 @@ $(PYTHON_TARGET): $(PYTHON_SOURCES)
2737

2838
$(HELM_TARGET): $(HELM_SOURCES) container
2939
helm package \
30-
--app-version "$(VERSION)" \
3140
--version $(VERSION) \
41+
--app-version "$(VERSION)" \
3242
--destination dist/ \
3343
var/helm
44+
helm push dist/mrmat-python-api-fastapi-$(VERSION).tgz oci://localhost:5001/charts
3445

35-
container: $(PYTHON_TARGET) $(CONTAINER_SOURCES)
46+
container: $(CONTAINER_SOURCES) $(PYTHON_TARGET)
3647
docker build \
3748
-f var/container/Dockerfile \
3849
-t localhost:5001/mrmat-python-api-fastapi:$(VERSION) \
50+
--build-arg GIT_SHA=$(GIT_SHA) \
3951
--build-arg MRMAT_VERSION=$(VERSION) \
4052
--build-arg WHEEL=$(PYTHON_TARGET) \
4153
$(ROOT_PATH)
4254
docker push localhost:5001/mrmat-python-api-fastapi:$(VERSION)
4355

4456
helm-install: $(HELM_TARGET)
4557
kubectl create ns mpafastapi || 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
58+
if test "$(MESH)" == "istio-sidecar"; then kubectl label --overwrite ns mpafastapi istio-injection=true; fi
59+
if test "$(MESH)" == "istio-ambient"; then kubectl label --overwrite ns mpafastapi istio.io/dataplane-mode=ambient; fi
4860
helm upgrade \
4961
mrmat-python-api-fastapi \
5062
${HELM_TARGET} \
5163
--install \
5264
--wait \
5365
--force \
5466
--namespace mpafastapi \
55-
--set istio=$(ISTIO)
67+
--set cluster.name=$(CLUSTER_NAME) \
68+
--set cluster.mesh=$(MESH) \
69+
--set edge.kind=$(EDGE) \
70+
--set config.db_url=$(API_DB_URL)
5671

5772
helm-uninstall:
5873
helm delete -n mpafastapi mrmat-python-api-fastapi

var/client-k8s.http

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
### GET Owners
2-
GET https://mpafastapi.covenant.local/api/platform/v1/owners
2+
GET https://mpafastapi.covenant.k8s/api/platform/v1/owners
33

44
### GET resources
5-
GET https://mpafastapi.covenant.local/api/platform/v1/resources
5+
GET https://mpafastapi.covenant.k8s/api/platform/v1/resources
66

77
### Create Owner
8-
POST https://mpafastapi.covenant.local/api/platform/v1/owners
8+
POST https://mpafastapi.covenant.k8s/api/platform/v1/owners
99
Content-Type: application/json
1010

1111
{

var/helm/Chart.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
apiVersion: v2
22
name: mrmat-python-api-fastapi
33
description: A Helm chart for MrMat Python API FastAPI
4+
home: https://github.com/MrMatAP/mrmat-python-api-fastapi
5+
sources:
6+
- https://github.com/MrMatAP/mrmat-python-api-fastapi
7+
maintainers:
8+
- name: MrMat
9+
10+
url: https://github.com/MrMatAP
11+
annotations:
12+
org.opencontainers.image.title: "MrMat :: Python API :: FastAPI"
13+
org.opencontainers.image.authors: "MrMat"
14+
org.opencontainers.image.vendor: "The MrMat Organisation"
15+
org.opencontainers.image.licenses: "MIT"
416
type: application
517
version: "0.0.0"
618
appVersion: "0.0.0.dev0"

var/helm/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Mathieu Imfeld
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

var/helm/templates/edge-istio-gateway-api.yaml renamed to var/helm/templates/edge-gateway-api.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
{{- if eq .Values.edge.kind "istio-gateway-api" -}}
1+
{{- if eq .Values.edge.kind "gateway-api" -}}
22
apiVersion: gateway.networking.k8s.io/v1
33
kind: HTTPRoute
44
metadata:
5-
name: {{ .Values.route.name }}
5+
name: route-mpafastapi
66
labels:
7+
app.kubernetes.io/name: route-mpafastapi
78
{{ include "common.labels" . | nindent 4 }}
89
spec:
910
hostnames:
10-
{{- range .Values.route.hostnames }}
11-
- {{ . | quote }}
12-
{{- end }}
11+
- {{ .Values.route.hostname }}.{{ .Values.cluster.name }}.{{ .Values.cluster.domain }}
1312
parentRefs:
1413
- group: gateway.networking.k8s.io
1514
kind: Gateway

var/helm/templates/edge-ingress.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ metadata:
1111
spec:
1212
tls:
1313
- hosts:
14-
- {{ .Values.ingress.hostname }}
14+
- {{ .Values.ingress.hostname }}.{{ .Values.cluster.name }}.{{ .Values.cluster.domain }}
1515
secretName: mpafastapi-cert
1616
rules:
1717
- host: {{ .Values.ingress.hostname }}

var/helm/templates/edge-istio.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,30 @@ apiVersion: gateway.networking.k8s.io/v1
44
kind: Gateway
55
metadata:
66
name: waypoint
7-
namespace: {{ .Release.Namespace }}
7+
labels:
8+
app.kubernetes.io/name: waypoint
9+
{{ include "common.labels" . | nindent 4 }}
810
spec:
911
gatewayClassName: istio-waypoint
1012
listeners:
1113
- name: mesh
1214
port: 15008
1315
protocol: HBONE
16+
---
17+
apiVersion: networking.istio.io/v1
18+
kind: VirtualService
19+
metadata:
20+
name: vs
21+
namespace: {{ .Release.Namespace }}
22+
labels:
23+
app.kubernetes.io/name: vs
24+
{{ include "common.labels" . | nindent 4 }}
25+
spec:
26+
hosts:
27+
- mpafastapi.{{ .Release.Namespace }}.svc.cluster.local
28+
http:
29+
- name: "mpafastapi"
30+
route:
31+
- destination:
32+
host: svc-mpafastapi.{{ .Release.Namespace }}.svc.cluster.local
1433
{{- end }}

var/helm/values.yaml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#
22
# Default values for MrMat :: Python API FastAPI
33

4+
cluster:
5+
mesh: istio
6+
gateway_api: true
7+
name: cluster
8+
domain: k8s
9+
410
sa:
511
name: sa-mpafastapi
612

@@ -21,19 +27,10 @@ edge:
2127
kind: istio-gateway-api
2228

2329
route:
24-
enabled: false
25-
name: route-mpafastapi
26-
hostnames:
27-
- mpafastapi.nostromo.k8s
28-
parents:
29-
- name: edge-ingress
30-
namespace: edge
31-
32-
istio: ambient
30+
hostname: mpafastapi
3331

3432
ingress:
35-
enabled: false
36-
hostname: mpafastapi.nostromo.k8s
33+
hostname: mpafastapi
3734

3835
config:
3936
db_url: "sqlite:////data/db.sqlite3"

0 commit comments

Comments
 (0)