observability: run prometheus/loki/grafana as 1000:1000 (rootless uid mapping)
Container root maps to a subuid that owns nothing under /opt, so the data-dir writes fail. Container uid 1000 is the invoking user in rootless podman.
This commit is contained in:
@@ -103,6 +103,9 @@ services:
|
||||
image: docker.io/prom/prometheus:latest
|
||||
container_name: prometheus
|
||||
restart: unless-stopped
|
||||
# Rootless: container uid 1000 maps to the invoking user, so the
|
||||
# container can write its /opt/prometheus/data bind mount.
|
||||
user: "1000:1000"
|
||||
command:
|
||||
- --config.file=/etc/prometheus/prometheus.yml
|
||||
- --storage.tsdb.path=/prometheus
|
||||
@@ -123,6 +126,9 @@ services:
|
||||
image: docker.io/grafana/grafana:latest
|
||||
container_name: grafana
|
||||
restart: unless-stopped
|
||||
# Rootless: container uid 1000 maps to the invoking user, so the
|
||||
# container can write its /opt/grafana/data bind mount.
|
||||
user: "1000:1000"
|
||||
environment:
|
||||
GF_SERVER_ROOT_URL: "https://grafana.franksdank.cloud"
|
||||
GF_SECURITY_ADMIN_USER: "${GRAFANA_ADMIN_USER}"
|
||||
@@ -144,6 +150,9 @@ services:
|
||||
image: docker.io/grafana/loki:latest
|
||||
container_name: loki
|
||||
restart: unless-stopped
|
||||
# Rootless: container uid 1000 maps to the invoking user, so the
|
||||
# container can write its /opt/loki/data bind mount.
|
||||
user: "1000:1000"
|
||||
command: ["-config.file=/etc/loki/loki-config.yaml"]
|
||||
ports:
|
||||
- "3100:3100"
|
||||
|
||||
@@ -118,3 +118,18 @@ CADDYFILE="$REPO_ROOT/dankclaw/Caddyfile"
|
||||
@test "prometheus targets are host:port (no URL schemes)" {
|
||||
! grep -nE '^\s*-\s*"?http' "$REPO_ROOT/shared/prometheus/prometheus.yml"
|
||||
}
|
||||
|
||||
@test "observability containers run as the host user (rootless uid mapping)" {
|
||||
# Rootless podman maps container uid 1000 to the invoking user, so
|
||||
# 1000:1000 lets these containers write their /opt data dirs. Container
|
||||
# root would map to a subuid that owns nothing under /opt.
|
||||
local compose="$REPO_ROOT/dankclaw/compose.yaml"
|
||||
local svc
|
||||
for svc in prometheus loki grafana; do
|
||||
local block
|
||||
block=$(awk "/^ $svc:$/,/^ [a-z]/" "$compose" | grep -v "^ $svc:")
|
||||
echo "$block" | grep -q 'user: "1000:1000"' || {
|
||||
echo "service $svc does not run as user 1000:1000"; return 1;
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user