apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  labels:
    app: {{ .Chart.Name }}
  name: '{{ .Release.Namespace }}:{{ .Chart.Name }}'
rules:
  # manage the VCenterTemplate CRD
  - apiGroups:
      - apiextensions.k8s.io
    resources:
      - customresourcedefinitions
    verbs:
      - '*'
  # Read VCenterTemplates created by others
  - apiGroups:
      - vcenter-operator.stable.sap.cc
    resources:
      - vcenter-templates
    verbs:
      - get
      - list
      - watch
  # be able to diff/deploy to other namespaces
  - apiGroups:
      - ""
    resources:
      - namespaces
    verbs:
      - get
      - list
      - watch
  # for f in $(git grep --files-with-match VCenterTemplate); do grep -e '  kind:' -e '  apiVersion' -- $f | cut -d ':' -f 2 | sed 's/ //g' | paste -d ' ' - -; done | sort -u
  - apiGroups:
      - ""
    resources:
      - configmaps
      - services
    verbs:
      - '*'
  - apiGroups:
      - extensions
    resources:
      - deployments
    verbs:
      - '*'

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  labels:
    app: {{ .Chart.Name }}
  name: '{{ .Release.Namespace }}:{{ .Chart.Name }}'
rules:
  # manage the VCenterTemplate CRD
  - apiGroups:
      - apiextensions.k8s.io
    resources:
      - customresourcedefinitions
    verbs:
      - '*'
  # Read VCenterTemplates created by others
  - apiGroups:
      - vcenter-operator.stable.sap.cc
    resources:
      - vcenter-templates
    verbs:
      - get
      - list
      - watch
  # be able to diff/deploy to other namespaces
  - apiGroups:
      - ""
    resources:
      - namespaces
    verbs:
      - get
      - list
      - watch
  # for f in $(git grep --files-with-match VCenterTemplate); do grep -e '  kind:' -e '  apiVersion' -- $f | cut -d ':' -f 2 | sed 's/ //g' | paste -d ' ' - -; done | sort -u
  - apiGroups:
      - ""
    resources:
      - configmaps
      - services
    verbs:
      - '*'
  - apiGroups:
      - extensions
    resources:
      - deployments
    verbs:
      - '*'
{{- if .Capabilities.APIVersions.Has "apps/v1" }}
  - apiGroups:
      - apps
    resources:
      - deployments
    verbs:
      - '*'
{{- end }}

Add apps/v1 Deployments to ClusterRole
[vcenter-operator] Add apps/v1 Deployments to ClusterRole

With kubernetes 1.16, apps/v1 is the only apiVersion supported to create
Deployments.
