Files
mg4/k8s/server.yaml
T

155 lines
4.7 KiB
YAML

# The car server (Go). One replica on purpose: pending pairing requests and the wrong-password
# counters are kept in memory.
# The roads of the app's Grid map, fetched on demand, are kept on this small volume.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mg4-server-maps
namespace: mg4
labels:
app.kubernetes.io/name: mg4-server
app.kubernetes.io/part-of: mg4
spec:
accessModes: ["ReadWriteOnce"]
# No storageClassName: the cluster's default class is used.
resources:
requests:
storage: 1Gi
---
# The files the car sends from its Logs tab (signal recordings), read with LOGS_TOKEN. Unlike
# the map cache these are not fetched again, so they get a volume of their own.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mg4-server-logs
namespace: mg4
labels:
app.kubernetes.io/name: mg4-server
app.kubernetes.io/part-of: mg4
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mg4-server
namespace: mg4
labels:
app.kubernetes.io/name: mg4-server
app.kubernetes.io/part-of: mg4
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app.kubernetes.io/name: mg4-server
template:
metadata:
labels:
app.kubernetes.io/name: mg4-server
app.kubernetes.io/part-of: mg4
spec:
securityContext:
runAsNonRoot: true
runAsUser: 65532
runAsGroup: 65532
fsGroup: 65532
seccompProfile:
type: RuntimeDefault
containers:
- name: server
# Pinned by digest so a re-pushed tag cannot change what runs (version in SPECS.md).
image: git.stinnesbeck.com/nils/mg4-server@sha256:c68837f0e53cfca150644987be535e04d5e999bd4c91064d40973db67235df48
ports:
- name: http
containerPort: 8080
env:
- name: INFLUX_URL
value: http://influxdb.mg4.svc:8086
- name: INFLUX_ORG
value: mg4
- name: INFLUX_BUCKET
value: mg4
# Where a phone reaches the server; the pairing QR code points here.
- name: PUBLIC_URL
value: https://car.k8s.stinnesbeck.com
# App updates: the releases of this repository, relayed to the car. Read with
# FORGE_TOKEN from the mg4-server Secret; leave that empty to switch updates off.
- name: FORGE_URL
value: https://git.stinnesbeck.com
- name: FORGE_REPO
value: nils/mg4
# The roads for the app's Grid map: OpenStreetMap vector tiles, fetched only for the
# tiles a car asks for and kept on the volume below; "off" switches maps off.
- name: MAP_TILES_URL
value: https://tiles.openfreemap.org/planet
- name: MAP_CACHE_DIR
value: /var/cache/mg4-maps
# Files from the car's Logs tab, kept on the volume below (the newest 200, at most
# 180 days). Reading them needs LOGS_TOKEN from the Secret; empty switches reading off.
- name: LOGS_DIR
value: /var/lib/mg4-logs
- name: INFLUX_TOKEN
valueFrom:
secretKeyRef:
name: influxdb-auth
key: admin-token
# INGEST_TOKEN, APPROVAL_PASSWORD, FORGE_TOKEN, LOGS_TOKEN.
envFrom:
- secretRef:
name: mg4-server
readinessProbe:
httpGet:
path: /v1/health
port: http
periodSeconds: 10
livenessProbe:
httpGet:
path: /v1/health
port: http
initialDelaySeconds: 5
periodSeconds: 30
resources:
requests:
cpu: 10m
memory: 32Mi
limits:
memory: 128Mi
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
volumeMounts:
- name: maps
mountPath: /var/cache/mg4-maps
- name: logs
mountPath: /var/lib/mg4-logs
volumes:
- name: maps
persistentVolumeClaim:
claimName: mg4-server-maps
- name: logs
persistentVolumeClaim:
claimName: mg4-server-logs
---
apiVersion: v1
kind: Service
metadata:
name: mg4-server
namespace: mg4
labels:
app.kubernetes.io/name: mg4-server
app.kubernetes.io/part-of: mg4
spec:
selector:
app.kubernetes.io/name: mg4-server
ports:
- name: http
port: 80
targetPort: http