fix(operator): grant the service account read on pods - #294
Merged
Merged
Conversation
The reconcile loop lists pods to read why a workload is not ready, but the ClusterRole never granted it, so every read 403s and the health check falls back to leaving the stored status alone.
The example manifest is not the deployed one, so asserting on it tests a file the cluster does not use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #293.
The operator's ClusterRole never granted
pods, soread_workload_health403s on every pass (lnvps_operator/src/app_deployments.rs:1516) andwrite_back_statustakes itsNonebranch and leaves the stored status untouched — which is exactly the state #276 existed to replace. Deployments were already granted via theappsgroup, so the replica counts were readable; only the container statuses, which carry the reason, were not.RBAC here is a static manifest, not something the operator creates:
lnvps_operator/srcreferences norbac.authorization.k8s.iotype at all, andlnvps_operator/k8s-minimal.yaml:17-41is the only ClusterRole in the repo. So the rule is added here and Kieran has to apply it — merging this changes nothing in the cluster on its own.Read-only (
get,list,watch); the operator never writes a pod.Do not apply this file to the live cluster
The manifest binds
lnvps-system/lnvps-operator(k8s-minimal.yaml:14,58); the 403 namessystem:serviceaccount:lnvps:lnvps-operator. The live install was not created from this file, sokubectl apply -fwould grant the running operator nothing and, if the live binding shares the name, would rewrite its subjects and take away the permissions it has now. Filed separately as #295 — that mismatch is not this PR's to fix.Grant the rule against the live objects instead. Confirm what is actually bound, then patch the role it names:
That touches only the ClusterRole, which is cluster-scoped and carries no namespace, and never the binding.
#291's usage collection is not affected. It reads Prometheus over HTTP (
lnvps_operator/src/metrics.rs:47-95), not the Kubernetes API, so it never touches this service account's permissions.A test parses the shipped manifest and asserts the ClusterRole covers the reads the loop makes (
lnvps_operator/src/main.rs:367). Verified it fails on the manifest as it stood.cargo test --workspacepasses at a3bd8bf apart fromlnvps_e2e, which needs a migrated MySQL and fails on table-not-found before reaching any assertion; clippy is clean onlnvps_operator.