home-assistant: split Role for InfluxDB-token Secret RBAC

Token Job hit `secrets is forbidden: ... cannot create resource` even
though the Role listed `create` in verbs. Kubernetes RBAC rejects
`create` verbs combined with `resourceNames` — at creation time the
resource doesn't yet exist by name, so the rule never matches.

Standard pattern: split into two rules — blanket `create` on Secrets
in the namespace (creating any other Secret is the only collateral
damage, and there's no other actor with this SA), plus resourceNames-
restricted `get/update/patch` on the single named `ha-influxdb-token`
Secret. Job now creates on first run and updates in place on later
runs.
This commit is contained in:
2026-05-05 18:18:24 +02:00
parent 1daaa6f59f
commit 68482f2d3d
+8 -1
View File
@@ -29,10 +29,17 @@ metadata:
name: ha-influxdb-token-writer
namespace: home-assistant
rules:
# `create` cannot be combined with resourceNames — the resource
# doesn't exist yet at creation time. Split into two rules: blanket
# `create` on Secrets in the namespace, then resourceNames-restricted
# `get/update/patch` on the single token Secret.
- apiGroups: [""]
resources: ["secrets"]
verbs: ["create"]
- apiGroups: [""]
resources: ["secrets"]
resourceNames: ["ha-influxdb-token"]
verbs: ["get", "create", "update", "patch"]
verbs: ["get", "update", "patch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding