Files
mg4/k8s/influxdb.yaml
nilsandClaude Opus 5.5 5473ab1c2b Dashboards in Grafana; clean up after the Next.js app
- k8s/grafana.yaml: Grafana 13.2.3 with a 1Gi PVC, sign-up and
  anonymous access off. The InfluxDB datasource (URL and token from the
  environment) and three dashboards — Live, Consumption, Charging — are
  provisioned from k8s/grafana/ via kustomize-generated ConfigMaps.
- server.yaml for the Go server (port 8080, UID 65532, smaller limits),
  image tag 2.0.0. The NetworkPolicy now admits Grafana to InfluxDB.
- ingress.yaml: IngressRoutes for car.stinnesbeck.com and Grafana
  (placeholder host car-grafana.stinnesbeck.com) with tls: {}, using
  Traefik's default certificate; the cert-manager Certificate is gone.
- secrets.example.yaml: drops the dashboard secrets, adds grafana-admin.
- AGENTS.md loses its Next.js block; SPECS.md describes the new setup.

The removal of web/ (the Next.js app) and of the stale .next/ cache
upstream had committed already landed in 51e6f6f, which was staged
together with the Go server by mistake.

Checked end to end in podman (Go server + InfluxDB 2.7.12 + Grafana
13.2.3): all 25 dashboard queries return the expected data, and the
dashboards were rendered with headless Chromium. Manifests validated
offline with kustomize and kubeconform. Nothing applied to a cluster.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QLJfZQZeAKAwSqViTmLzki
2026-10-17 15:18:09 +02:00

135 lines
3.6 KiB
YAML

# InfluxDB 2, cluster-internal only. On first start (empty volume) the image's setup mode
# creates the org, the bucket and the admin token from the influxdb-auth Secret; on later
# starts those variables are ignored and the data on the volume wins.
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: influxdb
namespace: mg4
labels:
app.kubernetes.io/name: influxdb
app.kubernetes.io/part-of: mg4
spec:
serviceName: influxdb
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: influxdb
template:
metadata:
labels:
app.kubernetes.io/name: influxdb
app.kubernetes.io/part-of: mg4
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: influxdb
image: docker.io/library/influxdb:2.7.12-alpine
ports:
- name: http
containerPort: 8086
env:
- name: INFLUXD_REPORTING_DISABLED
value: "true"
- name: DOCKER_INFLUXDB_INIT_MODE
value: setup
- name: DOCKER_INFLUXDB_INIT_ORG
value: mg4
- name: DOCKER_INFLUXDB_INIT_BUCKET
value: mg4
- name: DOCKER_INFLUXDB_INIT_USERNAME
value: admin
- name: DOCKER_INFLUXDB_INIT_PASSWORD
valueFrom:
secretKeyRef:
name: influxdb-auth
key: admin-password
- name: DOCKER_INFLUXDB_INIT_ADMIN_TOKEN
valueFrom:
secretKeyRef:
name: influxdb-auth
key: admin-token
volumeMounts:
- name: data
mountPath: /var/lib/influxdb2
- name: config
mountPath: /etc/influxdb2
readinessProbe:
httpGet:
path: /health
port: http
periodSeconds: 10
livenessProbe:
httpGet:
path: /health
port: http
initialDelaySeconds: 30
periodSeconds: 30
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
memory: 1Gi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
volumes:
- name: config
emptyDir: {}
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: ["ReadWriteOnce"]
# No storageClassName: the cluster's default class is used.
resources:
requests:
storage: 10Gi
---
apiVersion: v1
kind: Service
metadata:
name: influxdb
namespace: mg4
labels:
app.kubernetes.io/name: influxdb
app.kubernetes.io/part-of: mg4
spec:
selector:
app.kubernetes.io/name: influxdb
ports:
- name: http
port: 8086
targetPort: http
---
# Only the server and Grafana may reach InfluxDB. Has no effect on a CNI without
# NetworkPolicy support.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: influxdb-from-server-and-grafana
namespace: mg4
spec:
podSelector:
matchLabels:
app.kubernetes.io/name: influxdb
policyTypes: ["Ingress"]
ingress:
- from:
- podSelector:
matchLabels:
app.kubernetes.io/name: mg4-server
- podSelector:
matchLabels:
app.kubernetes.io/name: grafana
ports:
- port: 8086