infra(logging): Loki single-binary + Alloy DaemonSet, 192h bounded retention (F4)
No log store existed: pod logs were kubelet files on the node and died with the pod (~8h deepest history for a busy workload). Adds: - Loki 3.7.1 single-binary (1 Deployment + 8Gi local-path PVC on siriussec), retention_period 192h with the compactor deleting on filesystem, ingest rate limits, so the store is time- and rate-bounded. - Alloy 1.13.0 DaemonSet (all nodes, no RBAC, no API access) shipping /var/log/pods, /var/log/journal and the Pi's docker json logs. File sources read from byte 0 and stamp the timestamp from the line, so the history the nodes already held (18d cilium on linode, 31d registry on rpi) landed on day one instead of starting the 7-day clock at deploy time. - Grafana datasource (uid loki) via the existing sidecar, ServiceMonitor, ingest-rate guard rule. - docs/logging.md with the measured bytes/day, the 8-day projection and the runbook. Measured: ~360-502 MB/day raw -> ~90 MB/day compressed, 192h -> <=0.8GiB, on a node with 103GiB free (house floor 32GiB). Verified 7-day-old lines return for kube-system cilium-agent and for the siriussec/linode journals, and survive a Loki pod restart (PVC).
This commit is contained in:
parent
ac19ffb340
commit
179257d8fb
10 changed files with 890 additions and 0 deletions
138
infrastructure/logging/loki.yaml
Normal file
138
infrastructure/logging/loki.yaml
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
# Loki single-binary: one pod, one local-path PVC on siriussec.
|
||||
#
|
||||
# Off-node-ephemeral is satisfied by the PVC, not by the node's filesystem:
|
||||
# the store lives in /opt/local-path-provisioner/... on the NVMe, survives
|
||||
# pod restarts (and kubelet GC of /var/log/pods), and is re-mounted on node
|
||||
# reboot. 8Gi is the bound; the measured need is well under 1 GiB (see
|
||||
# docs/logging.md), so the PVC is ~10x the projected 8-day footprint.
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: loki-data
|
||||
namespace: logging
|
||||
labels:
|
||||
app.kubernetes.io/name: loki
|
||||
app.kubernetes.io/part-of: logging
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: local-path
|
||||
resources:
|
||||
requests:
|
||||
storage: 8Gi
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: loki
|
||||
namespace: logging
|
||||
labels:
|
||||
app.kubernetes.io/name: loki
|
||||
app.kubernetes.io/part-of: logging
|
||||
spec:
|
||||
replicas: 1
|
||||
# RWO local-path volume: a rolling update would deadlock with the new pod
|
||||
# Pending on the volume (same reason Grafana uses Recreate here).
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: loki
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: loki
|
||||
app.kubernetes.io/part-of: logging
|
||||
spec:
|
||||
# The PVC is provisioned by local-path on whichever node first mounts it;
|
||||
# pin to the node with the NVMe and the free space.
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: siriussec
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 10001
|
||||
runAsGroup: 10001
|
||||
fsGroup: 10001
|
||||
fsGroupChangePolicy: OnRootMismatch
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: loki
|
||||
image: grafana/loki:3.7.1
|
||||
imagePullPolicy: IfNotPresent
|
||||
args:
|
||||
- -config.file=/etc/loki/config.yaml
|
||||
- -log.level=info
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 3100
|
||||
protocol: TCP
|
||||
- name: grpc
|
||||
containerPort: 9096
|
||||
protocol: TCP
|
||||
resources:
|
||||
requests:
|
||||
cpu: 50m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
cpu: "1"
|
||||
memory: 1Gi
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop: ["ALL"]
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /ready
|
||||
port: http
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 10
|
||||
failureThreshold: 6
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /ready
|
||||
port: http
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 30
|
||||
failureThreshold: 4
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /etc/loki
|
||||
readOnly: true
|
||||
- name: data
|
||||
mountPath: /loki
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
terminationGracePeriodSeconds: 60
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: loki-config
|
||||
- name: data
|
||||
persistentVolumeClaim:
|
||||
claimName: loki-data
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: loki
|
||||
namespace: logging
|
||||
labels:
|
||||
app.kubernetes.io/name: loki
|
||||
app.kubernetes.io/part-of: logging
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app.kubernetes.io/name: loki
|
||||
ports:
|
||||
- name: http
|
||||
port: 3100
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
- name: grpc
|
||||
port: 9096
|
||||
targetPort: grpc
|
||||
protocol: TCP
|
||||
Loading…
Reference in a new issue