blob: b99325e03b3e272c3f833eb85e091be0e93f5a2e [file] [log] [blame]
gioc895c1d2026-07-23 17:18:25 +04001{{- if .Values.global.rbac.create }}
2apiVersion: rbac.authorization.k8s.io/v1
3kind: Role
4metadata:
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 }}
13rules:
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
34apiVersion: rbac.authorization.k8s.io/v1
35kind: RoleBinding
36metadata:
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 }}
45roleRef:
46 apiGroup: rbac.authorization.k8s.io
47 kind: Role
48 name: {{ template "webhook.fullname" . }}:dynamic-serving
49subjects:
50- kind: ServiceAccount
51 name: {{ template "webhook.serviceAccountName" . }}
52 namespace: {{ include "cert-manager.namespace" . }}
53
54---
55
56apiVersion: rbac.authorization.k8s.io/v1
57kind: ClusterRole
58metadata:
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 }}
66rules:
67- apiGroups: ["authorization.k8s.io"]
68 resources: ["subjectaccessreviews"]
69 verbs: ["create"]
70---
71
72apiVersion: rbac.authorization.k8s.io/v1
73kind: ClusterRoleBinding
74metadata:
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 }}
82roleRef:
83 apiGroup: rbac.authorization.k8s.io
84 kind: ClusterRole
85 name: {{ template "webhook.fullname" . }}:subjectaccessreviews
86subjects:
87- kind: ServiceAccount
88 name: {{ template "webhook.serviceAccountName" . }}
89 namespace: {{ include "cert-manager.namespace" . }}
90{{- end }}