BUG/MINOR: kubernetes-ingress: gate PSP Role and RoleBinding on k8s < 1.25 - #384
Merged
Merged
Conversation
… 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>
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.
Found while reviewing the chart for Kubernetes 1.37 compatibility.
Problem
controller-podsecuritypolicy.yamlis gated behindsemverCompare "<1.25.0-0", butcontroller-role.yamlandcontroller-rolebinding.yaml— which grantuseon that PodSecurityPolicy — were gated only onrbac.createandpodSecurityPolicy.enabled.On Kubernetes 1.25+ with
podSecurityPolicy.enabled=true, the chart rendered:Rolegrantinguseonpolicy/podsecuritypolicies(API removed in 1.25)RoleBindingPodSecurityPolicy(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=truelooked 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-versionacross the boundary and against provider-suffixed versions (these sort as semver pre-releases, which is why the-0suffix matters):1.23.01.24.91.25.01.37.0v1.37.1-gke.1000./test/local-test.sh kubernetes-ingress— 137 passed, 0 failed./test/ct-test.sh lint kubernetes-ingress— ✔︎ passedChart version bumped
1.54.1→1.54.2(patch; bugfix) with a matchingartifacthub.io/changesentry.Note
No behaviour change on Kubernetes < 1.25 — the PSP path is untouched. On 1.25+, existing installs will have the orphaned
Role/RoleBindingremoved on nexthelm upgrade.