Nextcloud pods run as the namespace's default service account: the chart's account is only created with rbac.enabled, which binds the removed PodSecurityPolicy
评估
调研方向
Start in templates/serviceaccount.yaml, where the account is rendered only when rbac.enabled is set, and in the Deployment and cron CronJob templates, where serviceAccountName is set only under that same condition. Make the account render whenever rbac.serviceaccount.create is true, default its name to the release's full name, and fail with a clear error when create is false and no name is given. Done when helm template with default values shows serviceAccountName on both pods and the account exists, and the create: false case errors out.
由索引模型根据 Issue 内容生成。
描述
Today
With the chart's defaults, the Nextcloud Deployment (and the cron CronJob, when enabled) runs as the namespace's default service account. The chart has its own account, rbac.serviceaccount, with create: true by default, but templates/serviceaccount.yaml renders it only when rbac.enabled is also true, and the pod templates set serviceAccountName only then.
rbac.enabled is off by default, and it isn't about the service account at all: it creates a Role and RoleBinding granting use on the privileged PodSecurityPolicy, in the extensions API group. PodSecurityPolicy was removed from extensions in Kubernetes 1.16 and removed entirely in 1.25. So on every supported cluster the RBAC part does nothing, and the service account is held back by a switch for a feature that no longer exists.
Why running as default matters
- Shared permissions: every pod in the namespace without its own account uses
default. A Role bound to it by another chart, an operator or an admin also applies to Nextcloud, and its mounted token can use it. - Cloud identity is blocked: a dedicated account is how a pod gets cloud credentials without static keys: an IRSA annotation on EKS, Workload Identity on GKE, the same on AKS. For Nextcloud that's the natural way to reach S3 primary storage. Today
rbac.serviceaccount.annotationsonly takes effect withrbac.enabled, which also creates the obsolete PSP Role. - No attribution: the API server's audit log records calls by account, so Nextcloud can't be told apart from anything else running as
default. - Hardened clusters flag it: CIS Kubernetes Benchmark 5.1.5 ("Ensure that default service accounts are not actively used") is commonly enforced by admission policies. The CNTi Test Suite's
dedicated_service_accounttest checks the same and fails on the chart's defaults.
Proposal
- Create the service account whenever
rbac.serviceaccount.createis true (already the default), independent ofrbac.enabled, and always setserviceAccountNameon the Nextcloud pods: the Deployment and the cron CronJob. - Default the account's name to the release's full name instead of the fixed
nextcloud-serviceaccount: once the account is always created, a fixed name would make two releases in one namespace collide. A name set inrbac.serviceaccount.nameis kept. - With
create: false, requirerbac.serviceaccount.name, with a clear error, since it must name an existing account.
The PSP Role behind rbac.enabled is left as it is: removing or repurposing it is a separate decision.
Compatibility:
- Installs with
rbac.enabled: false(the default) move fromdefaultto the chart's own account, which needs no permissions; nothing changes for Nextcloud itself. - Installs with
rbac.enabled: trueand the old default name get an account named after the release instead; anyone who bound roles tonextcloud-serviceaccountoutside the chart can keep the name by settingrbac.serviceaccount.name.
Verified
On a fork, with the change on the current main (chart 9.4.0 → 9.5.0):
helm lintpasses on the defaults and on all ninetest-valuessets. Renders were checked for the defaults, two releases in one namespace, an existing account,rbac.enabledwith the old name, the cron CronJob, andcreate: falsewithout a name (clear error).- The chart's own Lint and Test Charts workflow, on GitHub-hosted runners:
ct lintand all eight install cases pass (run 38956730034). - CNTi Test Suite (run 38956812911):
dedicated_service_accountfails onmain("sets no serviceAccountName, so its pods run as the namespace's default service account") and passes with the change; the essential tests are unchanged at 15 of 19.
Related, and not part of this: Nextcloud doesn't use the Kubernetes API, so the account's token could also stay unmounted (automountServiceAccountToken: false, CIS 5.1.6). Once the account exists by default, that's a one-line follow-up.
- 主要语言
- Go Template
- 星标
- 537
- 派生
- 317
- 平均合并
- 2 天 3 小时
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
nextcloud/helm 的其他 Issue
-
No native support for REDIS_USER enviroment var可能已有人在做 @jholmes802 于 9 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 68/100
-
nextcloud.openmetrics.allowedClients is silently ignored unless nextcloud.configs is set可能已有人在做 @JanWelker 于 25 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 78/100
-
External Redis not working: redis-session.ini: Permission denied可能已有人在做 @antoinetran 于 30 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 55/100
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
devantler-tech/ksail#7836 ·
维护者通常 1 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 76/100
SasanLabs/VulnerableApp#836 ·
维护者通常 1 天内回复
-
needs-triage
难度 2/5 1-3 小时 新手友好度 84/100
gke-labs/kube-agents#3394 ·
维护者通常 1 天内回复
-
area/CI area/CI/automation
难度 2/5 1-3 小时 新手友好度 74/100
Apicurio/apicurio-registry#10620 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
fluent/helm-charts#764 ·