Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#895 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@martin-mat 已经在做这个了。

开始于 2026年10月16日。

  • #896 来自 @martin-mat —— 未关闭

评估

难度
3/5
预计耗时
半天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
helm, kubernetes
领域
devops, security

调研方向

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.annotations only takes effect with rbac.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_account test checks the same and fails on the chart's defaults.
Proposal
  1. Create the service account whenever rbac.serviceaccount.create is true (already the default), independent of rbac.enabled, and always set serviceAccountName on the Nextcloud pods: the Deployment and the cron CronJob.
  2. 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 in rbac.serviceaccount.name is kept.
  3. With create: false, require rbac.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 from default to the chart's own account, which needs no permissions; nothing changes for Nextcloud itself.
  • Installs with rbac.enabled: true and the old default name get an account named after the release instead; anyone who bound roles to nextcloud-serviceaccount outside the chart can keep the name by setting rbac.serviceaccount.name.
Verified

On a fork, with the change on the current main (chart 9.4.0 → 9.5.0):

  • helm lint passes on the defaults and on all nine test-values sets. Renders were checked for the defaults, two releases in one namespace, an existing account, rbac.enabled with the old name, the cron CronJob, and create: false without a name (clear error).
  • The chart's own Lint and Test Charts workflow, on GitHub-hosted runners: ct lint and all eight install cases pass (run 38956730034).
  • CNTi Test Suite (run 38956812911): dedicated_service_account fails on main ("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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nextcloud/helm 的其他 Issue

查看 nextcloud/helm 的全部 Issue

相似的 Issue

更多 DevOps Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。