From a0dfeee1bc57824e1e626e9ed5377c7c9d3ceb7a Mon Sep 17 00:00:00 2001 From: Leonardo Grasso Date: Thu, 1 Oct 2020 15:23:47 +0200 Subject: [PATCH] fix(falco): set the appropiate apiVersion for rbac Signed-off-by: Leonardo Grasso --- falco/templates/_helpers.tpl | 11 +++++++++++ falco/templates/clusterrole.yaml | 2 +- falco/templates/clusterrolebinding.yaml | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/falco/templates/_helpers.tpl b/falco/templates/_helpers.tpl index 58f5a1c3..3f03dddb 100644 --- a/falco/templates/_helpers.tpl +++ b/falco/templates/_helpers.tpl @@ -72,4 +72,15 @@ Extract the unixSocket's directory path {{- if .Values.falco.grpc.unixSocketPath -}} {{- .Values.falco.grpc.unixSocketPath | trimPrefix "unix://" | dir -}} {{- end -}} +{{- end -}} + +{{/* +Return the appropriate apiVersion for rbac. +*/}} +{{- define "rbac.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1" }} +{{- print "rbac.authorization.k8s.io/v1" -}} +{{- else -}} +{{- print "rbac.authorization.k8s.io/v1beta1" -}} +{{- end -}} {{- end -}} \ No newline at end of file diff --git a/falco/templates/clusterrole.yaml b/falco/templates/clusterrole.yaml index eb929c88..11f74a87 100644 --- a/falco/templates/clusterrole.yaml +++ b/falco/templates/clusterrole.yaml @@ -1,6 +1,6 @@ {{- if .Values.rbac.create }} kind: ClusterRole -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: {{ template "rbac.apiVersion" . }} metadata: name: {{ template "falco.fullname" .}} labels: diff --git a/falco/templates/clusterrolebinding.yaml b/falco/templates/clusterrolebinding.yaml index 50ccb056..dff364eb 100644 --- a/falco/templates/clusterrolebinding.yaml +++ b/falco/templates/clusterrolebinding.yaml @@ -1,6 +1,6 @@ {{- if .Values.rbac.create }} kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: {{ template "rbac.apiVersion" . }} metadata: name: {{ template "falco.fullname" .}} labels: