Skip to content

Commit 2018c28

Browse files
authored
BUG/MINOR: kubernetes-ingress: gate PSP Role and RoleBinding on k8s < 1.25 (#384)
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>
1 parent b7998ee commit 2018c28

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

kubernetes-ingress/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ apiVersion: v2
1616
name: kubernetes-ingress
1717
description: A Helm chart for HAProxy Kubernetes Ingress Controller
1818
type: application
19-
version: 1.54.1
19+
version: 1.54.2
2020
appVersion: 3.2.15
2121
kubeVersion: ">=1.23.0-0"
2222
keywords:
@@ -39,4 +39,4 @@ annotations:
3939
- name: support
4040
url: https://github.com/haproxytech/helm-charts/issues
4141
artifacthub.io/changes: |-
42-
- Use Ingress Controller 3.2.15 version for base image
42+
- Do not render the PodSecurityPolicy Role and RoleBinding on Kubernetes 1.25 and newer

kubernetes-ingress/templates/controller-role.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/}}
1616

17-
{{- if and .Values.rbac.create .Values.podSecurityPolicy.enabled -}}
17+
{{- if and (semverCompare "<1.25.0-0" .Capabilities.KubeVersion.Version) .Values.rbac.create .Values.podSecurityPolicy.enabled -}}
1818
apiVersion: rbac.authorization.k8s.io/v1
1919
kind: Role
2020
metadata:

kubernetes-ingress/templates/controller-rolebinding.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/}}
1616

17-
{{- if and .Values.rbac.create .Values.podSecurityPolicy.enabled -}}
17+
{{- if and (semverCompare "<1.25.0-0" .Capabilities.KubeVersion.Version) .Values.rbac.create .Values.podSecurityPolicy.enabled -}}
1818
apiVersion: rbac.authorization.k8s.io/v1
1919
kind: RoleBinding
2020
metadata:

0 commit comments

Comments
 (0)