Skip to content

Commit e31b9f7

Browse files
committed
Grant cert-manager RBAC to use all policies by default
Signed-off-by: Erik Godding Boye <[email protected]>
1 parent dabc23b commit e31b9f7

File tree

5 files changed

+126
-0
lines changed

5 files changed

+126
-0
lines changed

deploy/charts/approver-policy/README.md

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{ if .Values.app.usePoliciesRbac.enabled }}
2+
kind: ClusterRole
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
metadata:
5+
labels:
6+
{{- include "cert-manager-approver-policy.labels" . | nindent 4 }}
7+
name: {{ printf "%s:%s" (include "cert-manager-approver-policy.name" .) "use" }}
8+
rules:
9+
- apiGroups: ["policy.cert-manager.io"]
10+
resources: ["certificaterequestpolicies"]
11+
verbs: ["use"]
12+
{{- with .Values.app.usePoliciesRbac.policyNames }}
13+
resourceNames:
14+
{{- range . }}
15+
- "{{ . }}"
16+
{{- end }}
17+
{{- end }}
18+
{{ end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{ if .Values.app.usePoliciesRbac.enabled }}
2+
kind: ClusterRoleBinding
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
metadata:
5+
labels:
6+
{{- include "cert-manager-approver-policy.labels" . | nindent 4 }}
7+
name: {{ printf "%s:%s" (include "cert-manager-approver-policy.name" .) "use" }}
8+
roleRef:
9+
apiGroup: rbac.authorization.k8s.io
10+
kind: ClusterRole
11+
name: {{ printf "%s:%s" (include "cert-manager-approver-policy.name" .) "use" }}
12+
subjects:
13+
- kind: ServiceAccount
14+
name: {{ .Values.app.usePoliciesRbac.serviceAccount.name }}
15+
namespace: {{ .Values.app.usePoliciesRbac.serviceAccount.namespace }}
16+
{{ end }}

deploy/charts/approver-policy/values.schema.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@
104104
"readinessProbe": {
105105
"$ref": "#/$defs/helm-values.app.readinessProbe"
106106
},
107+
"usePoliciesRbac": {
108+
"$ref": "#/$defs/helm-values.app.usePoliciesRbac"
109+
},
107110
"webhook": {
108111
"$ref": "#/$defs/helm-values.app.webhook"
109112
}
@@ -234,6 +237,54 @@
234237
"description": "The container port to expose approver-policy HTTP readiness probe on default network interface.",
235238
"type": "number"
236239
},
240+
"helm-values.app.usePoliciesRbac": {
241+
"additionalProperties": false,
242+
"properties": {
243+
"enabled": {
244+
"$ref": "#/$defs/helm-values.app.usePoliciesRbac.enabled"
245+
},
246+
"policyNames": {
247+
"$ref": "#/$defs/helm-values.app.usePoliciesRbac.policyNames"
248+
},
249+
"serviceAccount": {
250+
"$ref": "#/$defs/helm-values.app.usePoliciesRbac.serviceAccount"
251+
}
252+
},
253+
"type": "object"
254+
},
255+
"helm-values.app.usePoliciesRbac.enabled": {
256+
"default": true,
257+
"description": "Create RBAC to grant permission to use policies.",
258+
"type": "boolean"
259+
},
260+
"helm-values.app.usePoliciesRbac.policyNames": {
261+
"default": [],
262+
"description": "List of policies that the referenced service account will be given permission to use. Defaults to an empty array, allowing use of all policies.",
263+
"items": {},
264+
"type": "array"
265+
},
266+
"helm-values.app.usePoliciesRbac.serviceAccount": {
267+
"additionalProperties": false,
268+
"properties": {
269+
"name": {
270+
"$ref": "#/$defs/helm-values.app.usePoliciesRbac.serviceAccount.name"
271+
},
272+
"namespace": {
273+
"$ref": "#/$defs/helm-values.app.usePoliciesRbac.serviceAccount.namespace"
274+
}
275+
},
276+
"type": "object"
277+
},
278+
"helm-values.app.usePoliciesRbac.serviceAccount.name": {
279+
"default": "cert-manager",
280+
"description": "Name of ServiceAccount.",
281+
"type": "string"
282+
},
283+
"helm-values.app.usePoliciesRbac.serviceAccount.namespace": {
284+
"default": "cert-manager",
285+
"description": "Namespace of ServiceAccount.",
286+
"type": "string"
287+
},
237288
"helm-values.app.webhook": {
238289
"additionalProperties": false,
239290
"properties": {

deploy/charts/approver-policy/values.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,19 @@ app:
7575
# +docs:property
7676
approveSignerNames: []
7777

78+
usePoliciesRbac:
79+
# Create RBAC to grant permission to use policies.
80+
enabled: true
81+
# List of policies that the referenced service account will be given permission to
82+
# use. Defaults to an empty array, allowing use of all policies.
83+
policyNames: []
84+
# The ServiceAccount granted permission to use policies.
85+
serviceAccount:
86+
# Name of ServiceAccount.
87+
name: cert-manager
88+
# Namespace of ServiceAccount.
89+
namespace: cert-manager
90+
7891
metrics:
7992
# Port for exposing Prometheus metrics on 0.0.0.0 on path '/metrics'.
8093
port: 9402

0 commit comments

Comments
 (0)