Skip to content

BUG/MINOR: kubernetes-ingress: gate PSP Role and RoleBinding on k8s < 1.25 - #384

Merged
dkorunic merged 1 commit into
mainfrom
psp-rbac-version-gate
Sep 16, 2026
Merged

dkorunic merged 1 commit into
mainfrom
psp-rbac-version-gate

Conversation

@dkorunic

Copy link
Copy Markdown
Member

Found while reviewing the chart for Kubernetes 1.37 compatibility.

Problem

controller-podsecuritypolicy.yaml is gated behind semverCompare "<1.25.0-0", but controller-role.yaml and controller-rolebinding.yaml — which grant use on that PodSecurityPolicy — were gated only on rbac.create and podSecurityPolicy.enabled.

On Kubernetes 1.25+ with podSecurityPolicy.enabled=true, the chart rendered:

  • ❌ a Role granting use on policy/podsecuritypolicies (API removed in 1.25)
  • ❌ its RoleBinding
  • ✅ no PodSecurityPolicy (correctly gated)

RBAC rules are not validated against discovery, so these applied without error — they were dead configuration. The practical harm is that podSecurityPolicy.enabled=true looked effective on clusters where it can no longer do anything.

Fix

Add the same version gate to both templates, so all three objects appear and disappear as a unit.

Verification

Rendered with --kube-version across the boundary and against provider-suffixed versions (these sort as semver pre-releases, which is why the -0 suffix matters):

kube-version PodSecurityPolicy Role RoleBinding
1.23.0 1 1 1
1.24.9 1 1 1
1.25.0 0 0 0
1.37.0 0 0 0
v1.37.1-gke.1000 0 0 0
  • ./test/local-test.sh kubernetes-ingress137 passed, 0 failed
  • ./test/ct-test.sh lint kubernetes-ingress — ✔︎ passed

Chart version bumped 1.54.11.54.2 (patch; bugfix) with a matching artifacthub.io/changes entry.

Note

No behaviour change on Kubernetes < 1.25 — the PSP path is untouched. On 1.25+, existing installs will have the orphaned Role/RoleBinding removed on next helm upgrade.

… 1.25

The PodSecurityPolicy template is gated behind a semverCompare "<1.25.0-0"
check, but the Role and RoleBinding that grant "use" on it were only gated
on rbac.create and podSecurityPolicy.enabled. On Kubernetes 1.25 and newer
the chart therefore rendered a Role referencing the policy/podsecuritypolicies
resource, plus its RoleBinding, while the PodSecurityPolicy itself was
correctly omitted.

RBAC rules are not validated against discovery, so these objects applied
without error and were merely dead configuration, but they referenced an API
removed in 1.25 and made podSecurityPolicy.enabled=true look effective on
clusters where it can no longer do anything.

Add the same version gate to both templates so all three objects appear and
disappear together. Verified by rendering with --kube-version: PodSecurityPolicy,
Role and RoleBinding are all present on 1.23 and 1.24, and all absent on 1.25,
1.37 and provider-suffixed versions such as v1.37.1-gke.1000.

Signed-off-by: Dinko Korunic <dkorunic@haproxy.com>
@dkorunic
dkorunic merged commit 2018c28 into main Sep 16, 2026
6 checks passed
@dkorunic
dkorunic deleted the psp-rbac-version-gate branch September 16, 2026 12:48
@haproxyci
haproxyci restored the psp-rbac-version-gate branch September 16, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant