| gio | d55d03a | 2026-07-23 16:57:48 +0400 | [diff] [blame] | 1 | {{- if .Values.global.rbac.create }} |
| 2 | apiVersion: rbac.authorization.k8s.io/v1 |
| 3 | kind: Role |
| 4 | metadata: |
| 5 | name: {{ template "webhook.fullname" . }}:dynamic-serving |
| 6 | namespace: {{ include "cert-manager.namespace" . }} |
| 7 | labels: |
| 8 | app: {{ include "webhook.name" . }} |
| 9 | app.kubernetes.io/name: {{ include "webhook.name" . }} |
| 10 | app.kubernetes.io/instance: {{ .Release.Name }} |
| 11 | app.kubernetes.io/component: "webhook" |
| 12 | {{- include "labels" . | nindent 4 }} |
| 13 | rules: |
| 14 | - apiGroups: [""] |
| 15 | resources: ["secrets"] |
| 16 | resourceNames: |
| 17 | - '{{ template "webhook.fullname" . }}-ca' |
| 18 | {{- $certmanagerNamespace := include "cert-manager.namespace" . }} |
| 19 | {{- with (.Values.webhook.config.metricsTLSConfig).dynamic }} |
| 20 | {{- if $certmanagerNamespace | eq .secretNamespace }} |
| 21 | # Allow webhook to read and update the metrics CA Secret when dynamic TLS is |
| 22 | # enabled for the metrics server and if the Secret is configured to be in the |
| 23 | # same namespace as cert-manager. |
| 24 | - {{ .secretName | quote }} |
| 25 | {{- end }} |
| 26 | {{- end }} |
| 27 | verbs: ["get", "list", "watch", "update"] |
| 28 | # It's not possible to grant CREATE permission on a single resourceName. |
| 29 | - apiGroups: [""] |
| 30 | resources: ["secrets"] |
| 31 | verbs: ["create"] |
| 32 | --- |
| 33 | |
| 34 | apiVersion: rbac.authorization.k8s.io/v1 |
| 35 | kind: RoleBinding |
| 36 | metadata: |
| 37 | name: {{ template "webhook.fullname" . }}:dynamic-serving |
| 38 | namespace: {{ include "cert-manager.namespace" . }} |
| 39 | labels: |
| 40 | app: {{ include "webhook.name" . }} |
| 41 | app.kubernetes.io/name: {{ include "webhook.name" . }} |
| 42 | app.kubernetes.io/instance: {{ .Release.Name }} |
| 43 | app.kubernetes.io/component: "webhook" |
| 44 | {{- include "labels" . | nindent 4 }} |
| 45 | roleRef: |
| 46 | apiGroup: rbac.authorization.k8s.io |
| 47 | kind: Role |
| 48 | name: {{ template "webhook.fullname" . }}:dynamic-serving |
| 49 | subjects: |
| 50 | - kind: ServiceAccount |
| 51 | name: {{ template "webhook.serviceAccountName" . }} |
| 52 | namespace: {{ include "cert-manager.namespace" . }} |
| 53 | |
| 54 | --- |
| 55 | |
| 56 | apiVersion: rbac.authorization.k8s.io/v1 |
| 57 | kind: ClusterRole |
| 58 | metadata: |
| 59 | name: {{ template "webhook.fullname" . }}:subjectaccessreviews |
| 60 | labels: |
| 61 | app: {{ include "webhook.name" . }} |
| 62 | app.kubernetes.io/name: {{ include "webhook.name" . }} |
| 63 | app.kubernetes.io/instance: {{ .Release.Name }} |
| 64 | app.kubernetes.io/component: "webhook" |
| 65 | {{- include "labels" . | nindent 4 }} |
| 66 | rules: |
| 67 | - apiGroups: ["authorization.k8s.io"] |
| 68 | resources: ["subjectaccessreviews"] |
| 69 | verbs: ["create"] |
| 70 | --- |
| 71 | |
| 72 | apiVersion: rbac.authorization.k8s.io/v1 |
| 73 | kind: ClusterRoleBinding |
| 74 | metadata: |
| 75 | name: {{ template "webhook.fullname" . }}:subjectaccessreviews |
| 76 | labels: |
| 77 | app: {{ include "webhook.name" . }} |
| 78 | app.kubernetes.io/name: {{ include "webhook.name" . }} |
| 79 | app.kubernetes.io/instance: {{ .Release.Name }} |
| 80 | app.kubernetes.io/component: "webhook" |
| 81 | {{- include "labels" . | nindent 4 }} |
| 82 | roleRef: |
| 83 | apiGroup: rbac.authorization.k8s.io |
| 84 | kind: ClusterRole |
| 85 | name: {{ template "webhook.fullname" . }}:subjectaccessreviews |
| 86 | subjects: |
| 87 | - kind: ServiceAccount |
| 88 | name: {{ template "webhook.serviceAccountName" . }} |
| 89 | namespace: {{ include "cert-manager.namespace" . }} |
| 90 | {{- end }} |