Telemetry no longer loses queued batches. The server drops a bad value, or a sample without a plausible time, instead of rejecting the batch, and answers 200 with what it dropped. The app sends only values inside the server's ranges (speed as a magnitude, so reversing is fine) and no samples before the head unit's clock is set. Server: - Pairing hands out and accepts a token only after the device is saved; a failed save leaves the request pending. - A paired token serves only the installation id it was paired with (403 otherwise); the shared INGEST_TOKEN still serves any. - Wrong-password lockouts and open pairing requests are limited per client address (last X-Forwarded-For entry), so a stranger cannot lock the owner out; a car starting again replaces its own request. - ABRP forwarding skips samples stamped ahead of the server's clock, which used to stop it until a restart. App: - Settings written to plaintext during a keystore failure move back into encrypted storage; the stored installation id wins. - The installation id is derived from ANDROID_ID on first start, so a reinstall finds its history; a stored or imported id still wins. - The scanned config file is deleted after import (it holds the token). - GPS stops while live telemetry is off or the server unconfigured, and pauses while parked and idle, keeping the fix the car parked with. - Range estimates use the monotonic clock. - One HTTP helper (ServerHttp) for telemetry, sync and pairing. - Last Turkish strings translated; mise logs shows the NilsMG4 tags. Grafana reads InfluxDB with its own read-only token (new grafana-influx Secret, created by hand as described in k8s/README.md). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QLJfZQZeAKAwSqViTmLzki
155 lines
4.7 KiB
YAML
155 lines
4.7 KiB
YAML
# Grafana for the dashboards. The InfluxDB datasource and the three MG4 dashboards are
|
|
# provisioned from k8s/grafana/ (ConfigMaps generated by kustomization.yaml); the dashboards
|
|
# are read-only in the UI — change the JSON in git instead.
|
|
apiVersion: v1
|
|
kind: PersistentVolumeClaim
|
|
metadata:
|
|
name: grafana-data
|
|
namespace: mg4
|
|
labels:
|
|
app.kubernetes.io/name: grafana
|
|
app.kubernetes.io/part-of: mg4
|
|
spec:
|
|
accessModes: ["ReadWriteOnce"]
|
|
# No storageClassName: the cluster's default class is used.
|
|
resources:
|
|
requests:
|
|
storage: 1Gi
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: grafana
|
|
namespace: mg4
|
|
labels:
|
|
app.kubernetes.io/name: grafana
|
|
app.kubernetes.io/part-of: mg4
|
|
spec:
|
|
replicas: 1
|
|
strategy:
|
|
type: Recreate # the SQLite database on the volume allows one writer
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: grafana
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: grafana
|
|
app.kubernetes.io/part-of: mg4
|
|
spec:
|
|
securityContext:
|
|
runAsNonRoot: true
|
|
runAsUser: 472
|
|
runAsGroup: 472
|
|
fsGroup: 472
|
|
seccompProfile:
|
|
type: RuntimeDefault
|
|
containers:
|
|
- name: grafana
|
|
image: docker.io/grafana/grafana:13.2.3
|
|
ports:
|
|
- name: http
|
|
containerPort: 3000
|
|
env:
|
|
- name: GF_SERVER_ROOT_URL
|
|
value: https://car-grafana.k8s.stinnesbeck.com
|
|
- name: GF_SECURITY_ADMIN_USER
|
|
value: admin
|
|
- name: GF_SECURITY_ADMIN_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: grafana-admin
|
|
key: admin-password
|
|
- name: GF_USERS_ALLOW_SIGN_UP
|
|
value: "false"
|
|
- name: GF_AUTH_ANONYMOUS_ENABLED
|
|
value: "false"
|
|
- name: GF_ANALYTICS_REPORTING_ENABLED
|
|
value: "false"
|
|
- name: GF_ANALYTICS_CHECK_FOR_UPDATES
|
|
value: "false"
|
|
# Read by datasources.yaml.
|
|
- name: INFLUX_URL
|
|
value: http://influxdb.mg4.svc:8086
|
|
# Read-only on the mg4 bucket; the dashboards never write (README, "Grafana's
|
|
# InfluxDB token").
|
|
- name: INFLUX_TOKEN
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: grafana-influx
|
|
key: token
|
|
volumeMounts:
|
|
- name: data
|
|
mountPath: /var/lib/grafana
|
|
- name: datasources
|
|
mountPath: /etc/grafana/provisioning/datasources
|
|
- name: dashboard-provider
|
|
mountPath: /etc/grafana/provisioning/dashboards
|
|
- name: dashboards
|
|
mountPath: /var/lib/grafana/dashboards/mg4
|
|
# The first start creates and migrates Grafana's database: measured 44 s at 0.5 CPU
|
|
# and 3 minutes at 0.1 CPU. The startup probe allows up to 10 minutes for that, and
|
|
# liveness/readiness only begin once it succeeded, so a slow first start is never
|
|
# killed mid-migration (which would restart it slowly again, in a loop).
|
|
startupProbe:
|
|
httpGet:
|
|
path: /api/health
|
|
port: http
|
|
periodSeconds: 10
|
|
timeoutSeconds: 5
|
|
failureThreshold: 60
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /api/health
|
|
port: http
|
|
periodSeconds: 10
|
|
timeoutSeconds: 5
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /api/health
|
|
port: http
|
|
periodSeconds: 30
|
|
timeoutSeconds: 5
|
|
failureThreshold: 3
|
|
# About 406 MiB in steady state in the cluster: request what it uses, and leave room
|
|
# for long-range dashboard queries before the limit OOM-kills it.
|
|
resources:
|
|
requests:
|
|
cpu: 250m
|
|
memory: 512Mi
|
|
limits:
|
|
memory: 1Gi
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
capabilities:
|
|
drop: ["ALL"]
|
|
volumes:
|
|
- name: data
|
|
persistentVolumeClaim:
|
|
claimName: grafana-data
|
|
- name: datasources
|
|
configMap:
|
|
name: grafana-datasources
|
|
- name: dashboard-provider
|
|
configMap:
|
|
name: grafana-dashboard-provider
|
|
- name: dashboards
|
|
configMap:
|
|
name: grafana-dashboards
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: grafana
|
|
namespace: mg4
|
|
labels:
|
|
app.kubernetes.io/name: grafana
|
|
app.kubernetes.io/part-of: mg4
|
|
spec:
|
|
selector:
|
|
app.kubernetes.io/name: grafana
|
|
ports:
|
|
- name: http
|
|
port: 80
|
|
targetPort: http
|