Skip to content

Commit 9b9f5a4

Browse files
committed
The Helm chart now allows setting configuration
1 parent 4f52a7f commit 9b9f5a4

File tree

9 files changed

+88
-95
lines changed

9 files changed

+88
-95
lines changed

var/helm/Chart.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,5 @@ apiVersion: v2
22
name: mrmat-python-api-fastapi
33
description: A Helm chart for MrMat Python API FastAPI
44
type: application
5-
6-
# This is the chart version. This version number should be incremented each time you make changes
7-
# to the chart and its templates, including the app version.
8-
# Versions are expected to follow Semantic Versioning (https://semver.org/)
95
version: "0.0.0"
10-
11-
# This is the version number of the application being deployed. This version number should be
12-
# incremented each time you make changes to the application. Versions are not expected to
13-
# follow Semantic Versioning. They should reflect the version the application is using.
14-
# It is recommended to use it with quotes.
156
appVersion: "0.0.0.dev0"

var/helm/templates/_helpers.tpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
{{/* Common labels */}}
3+
{{ define "common.labels" }}
4+
app: mpafastapi
5+
version: {{ .Chart.AppVersion }}
6+
app.kubernetes.io/part-of: mpafastapi
7+
app.kubernetes.io/version: {{ .Chart.AppVersion }}
8+
{{ end }}

var/helm/templates/deployment.yaml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
11
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
4-
name: mrmat-python-api-fastapi
4+
name: mpafastapi
55
labels:
6-
app.kubernetes.io/name: mrmat-python-api-fastapi
7-
app.kubernetes.io/part-of: mrmat-python-api-fastapi
6+
app.kubernetes.io/name: mpafastapi
7+
{{ include "common.labels" . | nindent 4 }}
88
spec:
99
replicas: {{ .Values.pod.replicas | int }}
1010
selector:
1111
matchLabels:
12-
app: {{ .Values.pod.name }}
13-
version: {{ .Chart.AppVersion }}
12+
{{ include "common.labels" . | nindent 6 }}
1413
template:
1514
metadata:
1615
labels:
17-
sidecar.istio.io/inject: "true"
18-
app: {{ .Values.pod.name }}
19-
version: {{ .Chart.AppVersion }}
20-
app.kubernetes.io/name: mrmat-python-api-fastapi
21-
app.kubernetes.io/part-of: mrmat-python-api-fastapi
16+
{{ include "common.labels" . | nindent 8 }}
2217
annotations:
2318
prometheus.io/scrape: "true"
2419
prometheus.io/scheme: http
2520
prometheus.io/port: "8000"
2621
prometheus.io/path: /metrics
2722
spec:
28-
serviceAccountName: {{ .Values.serviceAccount.name }}
23+
serviceAccountName: {{ .Values.sa.name }}
24+
volumes:
25+
- name: config-volume
26+
secret:
27+
secretName: config-mpafastapi
28+
- name: data-volume
29+
emptyDir:
30+
sizeLimit: 10Mi
31+
medium: Memory
2932
containers:
30-
- name: mrmat-python-api-fastapi
33+
- name: mpafastapi
3134
image: {{ .Values.pod.repository }}:{{ .Chart.AppVersion }}
3235
imagePullPolicy: {{ .Values.pod.imagePullPolicy }}
3336
env:
37+
- name: APP_CONFIG
38+
value: /config/app_config.json
3439
- name: OTEL_SERVICE_NAME
3540
value: "mrmat-python-api-fastapi"
3641
- name: OTEL_TRACES_EXPORTER
@@ -51,6 +56,12 @@ spec:
5156
- name: http
5257
containerPort: {{ .Values.pod.port }}
5358
protocol: TCP
59+
volumeMounts:
60+
- name: config-volume
61+
mountPath: /config
62+
readOnly: true
63+
- name: data-volume
64+
mountPath: /data
5465
securityContext:
5566
capabilities:
5667
drop:

var/helm/templates/httproute.yaml

Lines changed: 0 additions & 34 deletions
This file was deleted.

var/helm/templates/route.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{{- if .Values.route.enabled -}}
2+
apiVersion: gateway.networking.k8s.io/v1
3+
kind: HTTPRoute
4+
metadata:
5+
name: {{ .Values.route.name }}
6+
labels:
7+
{{ include "common.labels" . | nindent 4 }}
8+
spec:
9+
hostnames:
10+
{{- range .Values.route.hostnames }}
11+
- {{ . | quote }}
12+
{{- end }}
13+
parentRefs:
14+
{{- range .Values.route.parents }}
15+
- group: gateway.networking.k8s.io
16+
kind: Gateway
17+
name: {{ .name }}
18+
namespace: {{ .namespace }}
19+
sectionName: mpafastapi
20+
{{- end }}
21+
rules:
22+
- backendRefs:
23+
- kind: Service
24+
name: {{ .Values.svc.name }}
25+
port: {{ .Values.svc.port }}
26+
weight: 1
27+
matches:
28+
- path:
29+
type: PathPrefix
30+
value: /
31+
{{- end -}}

var/helm/templates/secret.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: config-mpafastapi
5+
labels:
6+
app.kubernetes.io/name: config-mpafastapi
7+
{{ include "common.labels" . | nindent 4 }}
8+
stringData:
9+
app_config.json: |-
10+
{ "db_url": {{ .Values.config.db_url | quote }} }

var/helm/templates/service.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
apiVersion: v1
22
kind: Service
33
metadata:
4-
name: {{ .Values.service.name }}
4+
name: {{ .Values.svc.name }}
55
labels:
6-
app: {{ .Values.pod.name }}
7-
version: {{ .Chart.AppVersion }}
8-
app.kubernetes.io/name: {{ .Values.service.name }}
9-
app.kubernetes.io/part-of: mrmat-python-api-fastapi
6+
{{ include "common.labels" . | nindent 4 }}
107
spec:
118
type: ClusterIP
129
ports:
13-
- port: {{ .Values.service.port }}
10+
- port: {{ .Values.svc.port }}
1411
targetPort: {{ .Values.pod.port }}
1512
protocol: TCP
1613
name: http
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
apiVersion: v1
22
kind: ServiceAccount
33
metadata:
4-
name: {{ .Values.serviceAccount.name }}
4+
name: {{ .Values.sa.name }}
55
labels:
6-
app: {{ .Values.pod.name }}
7-
version: {{ .Chart.AppVersion }}
8-
app.kubernetes.io/name: {{ .Values.serviceAccount.name }}
9-
app.kubernetes.io/part-of: mrmat-python-api-fastapi
6+
{{ include "common.labels" . | nindent 4 }}
107
automountServiceAccountToken: true

var/helm/values.yaml

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,28 @@
11
#
2-
# Default values
2+
# Default values for MrMat :: Python API FastAPI
33

4-
# This is to override the chart name.
5-
nameOverride: ""
6-
fullnameOverride: ""
7-
8-
serviceAccount:
9-
name: mrmat-python-api-fastapi-sa
4+
sa:
5+
name: sa-mpafastapi
106

117
pod:
12-
name: mrmat-python-api-fastapi
8+
name: mpafastapi
139
replicas: 1
1410
repository: registry:5000/mrmat-python-api-fastapi
1511
imagePullPolicy: Always
1612
port: 8000
1713

18-
service:
19-
name: mrmat-python-api-fastapi-svc
14+
svc:
15+
name: svc-mpafastapi
2016
port: 80
2117

22-
httproute:
18+
route:
2319
enabled: true
24-
name: mrmat-python-api-fastapi-httproute
20+
name: route-mpafastapi
2521
hostnames:
26-
- mrmat-python-api-fastapi.covenant.local
22+
- mpafastapi.covenant.local
2723
parents:
2824
- name: edge-ingress
2925
namespace: edge
3026

31-
ingress:
32-
enabled: false
33-
name: mrmat-python-api-fastapi-ing
34-
className: ""
35-
annotations: { }
36-
# kubernetes.io/ingress.class: nginx
37-
# kubernetes.io/tls-acme: "true"
38-
hosts:
39-
- host: mrmat-python-api-fastapi.local
40-
paths:
41-
- path: /
42-
pathType: ImplementationSpecific
43-
tls: [ ]
44-
# - secretName: chart-example-tls
45-
# hosts:
46-
# - chart-example.local
27+
config:
28+
db_url: "sqlite:///data/db.sqlite"

0 commit comments

Comments
 (0)