Skip to content

Commit e1ec78a

Browse files
committed
manager service account
1 parent 796fccb commit e1ec78a

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

wiz-admission-controller/templates/_helpers.tpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ Create the name of the service account to use
135135
{{ coalesce (.Values.serviceAccount.name) (include "wiz-admission-controller.fullname" .) }}
136136
{{- end }}
137137

138+
{{- define "wiz-admission-controller.manager.serviceAccountName" -}}
139+
{{ coalesce (.Values.wizManager.serviceAccount.name) (include "wiz-admission-controller-manager.name" .) }}
140+
{{- end }}
141+
142+
138143
{{- define "wiz-admission-controller.secretApiTokenName" -}}
139144
{{ coalesce (.Values.global.wizApiToken.secret.name) (.Values.wizApiToken.secret.name) (printf "%s-%s" .Release.Name "api-token") }}
140145
{{- end }}

wiz-admission-controller/templates/cronjobmanager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ spec:
3636
imagePullSecrets:
3737
{{- toYaml . | nindent 12 }}
3838
{{- end }}
39-
serviceAccountName: {{ include "wiz-admission-controller.serviceAccountName" . }}
39+
serviceAccountName: {{ include "wiz-admission-controller.manager.serviceAccountName" . }}
4040
securityContext:
4141
{{- if hasKey .Values.global "lowPrivilegePodSecurityPolicy" }}
4242
{{- toYaml .Values.global.lowPrivilegePodSecurityPolicy | nindent 12 }}

wiz-admission-controller/templates/serviceaccount.yaml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,24 @@ roleRef:
7474

7575
{{- if .Values.wizManager.enabled -}}
7676
---
77+
{{- if .Values.wizManager.serviceAccount.create -}}
78+
apiVersion: v1
79+
kind: ServiceAccount
80+
metadata:
81+
name: {{ include "wiz-admission-controller.manager.serviceAccountName" . }}
82+
namespace: {{ .Release.Namespace | quote }}
83+
labels:
84+
{{- include "wiz-admission-controller.labels" . | nindent 4 }}
85+
{{- with .Values.wizManager.serviceAccount.annotations }}
86+
annotations:
87+
{{- toYaml . | nindent 4 }}
88+
{{- end }}
89+
{{- end }}
90+
---
7791
apiVersion: rbac.authorization.k8s.io/v1
7892
kind: Role
7993
metadata:
80-
name: {{ printf "%s-pods-and-deployments-manager" (include "wiz-admission-controller.serviceAccountName" .) }}
94+
name: {{ printf "%s-pods-and-deployments-manager" (include "wiz-admission-controller.manager.serviceAccountName" .) }}
8195
namespace: {{ .Release.Namespace | quote }}
8296
labels:
8397
{{- include "wiz-admission-controller.labels" . | nindent 4 }}
@@ -93,16 +107,16 @@ rules:
93107
apiVersion: rbac.authorization.k8s.io/v1
94108
kind: RoleBinding
95109
metadata:
96-
name: {{ printf "%s-pods-and-deployments" (include "wiz-admission-controller.serviceAccountName" .) }}
110+
name: {{ printf "%s-pods-and-deployments" (include "wiz-admission-controller.manager.serviceAccountName" .) }}
97111
namespace: {{ .Release.Namespace | quote }}
98112
labels:
99113
{{- include "wiz-admission-controller.labels" . | nindent 4 }}
100114
subjects:
101115
- kind: ServiceAccount
102-
name: {{ include "wiz-admission-controller.serviceAccountName" . }}
116+
name: {{ include "wiz-admission-controller.manager.serviceAccountName" . }}
103117
namespace: {{ .Release.Namespace | quote }}
104118
roleRef:
105119
kind: Role
106-
name: {{ printf "%s-pods-and-deployments-reader-manager" (include "wiz-admission-controller.serviceAccountName" .) }}
120+
name: {{ printf "%s-pods-and-deployments-manager" (include "wiz-admission-controller.manager.serviceAccountName" .) }}
107121
apiGroup: rbac.authorization.k8s.io
108122
{{- end }}

wiz-admission-controller/values.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,17 @@ wizManager:
432432
schedule: "0 * * * *" # Every 1 hour
433433
timeoutSeconds: 240 # The timeout for the manager job in seconds.
434434
cleanupJobSeconds: 600 # The time in seconds after which the job should be deleted.
435+
436+
# K8s service account to be used by the manager
437+
serviceAccount:
438+
# If `create` is set to `false`` an existing service account will be used
439+
create: true
440+
# Annotations to add to the service account
441+
annotations: {}
442+
# The name of the service account to use.
443+
# If empty, a name is generated using the nameOverride
444+
name: ""
445+
435446
rolloutRestart:
436447
wizForceEnabled: true # Wiz initiated remote updates.
437448
interval: "168h" # 1 week

0 commit comments

Comments
 (0)