From 81a4812bb5d05bcca0abd5b3d4ab9dbc3ba8bfdb Mon Sep 17 00:00:00 2001 From: Nikita Gorlov <34012178+nv30@users.noreply.github.com> Date: Fri, 27 Dec 2019 16:09:39 +0300 Subject: [PATCH] [stable/node-problem-detector] Template apiVersion for podSecurityPolicy (#19769) * Template apiVersion for podSecurityPolicy for k8s version v1.16.3 or newer Signed-off-by: Nikita Gorlov * Updated chart version Signed-off-by: Nikita Gorlov --- stable/node-problem-detector/Chart.yaml | 2 +- stable/node-problem-detector/templates/_helpers.tpl | 11 +++++++++++ stable/node-problem-detector/templates/psp.yaml | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/stable/node-problem-detector/Chart.yaml b/stable/node-problem-detector/Chart.yaml index 5ff5359ae0..e95922ac5d 100644 --- a/stable/node-problem-detector/Chart.yaml +++ b/stable/node-problem-detector/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: node-problem-detector -version: "1.6.1" +version: "1.6.2" appVersion: v0.7.0 home: https://github.com/kubernetes/node-problem-detector description: Installs the node-problem-detector daemonset for monitoring extra attributes on nodes diff --git a/stable/node-problem-detector/templates/_helpers.tpl b/stable/node-problem-detector/templates/_helpers.tpl index 25077d3171..d3d3776464 100644 --- a/stable/node-problem-detector/templates/_helpers.tpl +++ b/stable/node-problem-detector/templates/_helpers.tpl @@ -48,3 +48,14 @@ Create the name of the configmap for storing custom monitor definitions {{- $fullname := include "node-problem-detector.fullname" . -}} {{- printf "%s-custom-config" $fullname | replace "+" "_" | trunc 63 -}} {{- end -}} + +{{/* +Return the appropriate apiVersion for podSecurityPolicy. +*/}} +{{- define "podSecurityPolicy.apiVersion" -}} +{{- if semverCompare ">=1.10-0" .Capabilities.KubeVersion.GitVersion -}} +{{- print "policy/v1beta1" -}} +{{- else -}} +{{- print "extensions/v1beta1" -}} +{{- end -}} +{{- end -}} diff --git a/stable/node-problem-detector/templates/psp.yaml b/stable/node-problem-detector/templates/psp.yaml index c00ec6e91a..5c14753d45 100644 --- a/stable/node-problem-detector/templates/psp.yaml +++ b/stable/node-problem-detector/templates/psp.yaml @@ -1,5 +1,5 @@ {{- if .Values.rbac.pspEnabled }} -apiVersion: extensions/v1beta1 +apiVersion: {{ template "podSecurityPolicy.apiVersion" . }} kind: PodSecurityPolicy metadata: name: {{ template "node-problem-detector.fullname" . }}