# helm_charts_agent-psp-clusterrole.yaml
{{- if and .Values.agent.enabled .Values.psp.create -}}
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  labels:
    app: {{ template "kiam.name" . }}
    chart: {{ template "kiam.chart" . }}
    component: "{{ .Values.agent.name }}"
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  annotations:
    k8s-addon: podsecuritypolicy.addons.k8s.io
  name: {{ template "kiam.fullname" . }}-agent-psp-use
rules:
- apiGroups:
  - policy
  resources:
  - podsecuritypolicies
  resourceNames:
  - {{ template "kiam.fullname" . }}-agent
  verbs:
  - use
{{- end -}}
{{- end }}