@@ -40,6 +40,19 @@ If release name contains chart name it will be used as a full name.
4040{ {- end } }
4141{ {- end } }
4242
43+ { {- define " wiz-admission-controller-manager.name" -} }
44+ { {- if .Values.wizManager.nameOverride } }
45+ { {- .Values.wizManager.nameOverride | trunc 63 | trimSuffix " -" } }
46+ { {- else } }
47+ { {- $name := " wiz-admission-controller-manager" } }
48+ { {- if contains $name .Release.Name } }
49+ { {- .Release.Name | trunc 63 | trimSuffix " -" } }
50+ { {- else } }
51+ { {- printf " %s-%s" .Release.Name $name | trunc 63 | trimSuffix " -" } }
52+ { {- end } }
53+ { {- end } }
54+ { {- end } }
55+
4356{ {- define " wiz-hpa-enforcer.name" -} }
4457{ {- printf " %s-hpa" (include " wiz-admission-controller.fullname" .) | trunc 63 | trimSuffix " -" } }
4558{ {- end } }
@@ -99,6 +112,13 @@ Wiz kubernetes audit logs webhook server selector labels
99112app.kubernetes.io/name: { { include " wiz-kubernetes-audit-log-collector.name" . } }
100113{ {- end } }
101114
115+ { {/*
116+ Wiz manager selector labels
117+ */} }
118+ { {- define " wiz-admission-controller-manager.selectorLabels" -} }
119+ app.kubernetes.io/name: { { include " wiz-admission-controller-manager.name" . } }
120+ { {- end } }
121+
102122{ {- define " wiz-admission-controller-enforcement.labels" -} }
103123{ { include " wiz-admission-controller.labels" . } }
104124{ { include " wiz-admission-controller-enforcement.selectorLabels" . } }
@@ -109,6 +129,11 @@ app.kubernetes.io/name: {{ include "wiz-kubernetes-audit-log-collector.name" . }
109129{ { include " wiz-kubernetes-audit-log-collector.selectorLabels" . } }
110130{ {- end } }
111131
132+ { {- define " wiz-admission-controller-manager.labels" -} }
133+ { { include " wiz-admission-controller.labels" . } }
134+ { { include " wiz-admission-controller-manager.selectorLabels" . } }
135+ { {- end } }
136+
112137{ {/*
113138Wiz Horizontal Pod Autoscaler labels
114139*/} }
@@ -133,6 +158,11 @@ Create the name of the service account to use
133158{ { coalesce (.Values.serviceAccount.name) (include " wiz-admission-controller.fullname" .) } }
134159{ {- end } }
135160
161+ { {- define " wiz-admission-controller.manager.serviceAccountName" -} }
162+ { { coalesce (.Values.wizManager.serviceAccount.name) (include " wiz-admission-controller-manager.name" .) } }
163+ { {- end } }
164+
165+
136166{ {- define " wiz-admission-controller.secretApiTokenName" -} }
137167{ { coalesce (.Values.global.wizApiToken.secret.name) (.Values.wizApiToken.secret.name) (printf " %s-%s" .Release.Name " api-token" ) } }
138168{ {- end } }
@@ -249,3 +279,124 @@ scaleDown:
249279 periodSeconds: 300
250280{ {- end -} }
251281{ {- end -} }
282+
283+ { {- define " autoUpdate.deployments" -} }
284+ { {- $list := list -} }
285+ { {- if eq (include " wiz-admission-controller.isEnforcerEnabled" . | trim | lower) " true" } }
286+ { {- $list = append $list (include " wiz-admission-controller.fullname" . ) -} }
287+ { {- end -} }
288+ { {- if .Values.kubernetesAuditLogsWebhook.enabled -} }
289+ { {- $list = append $list (include " wiz-kubernetes-audit-log-collector.name" . ) -} }
290+ { {- end -} }
291+ { {- $list | toJson -} }
292+ { {- end -} }
293+
294+ { {/*
295+ Clean the list of deployments for the auto-update flag, removing quotes and brackets
296+ */} }
297+ { {- define " autoUpdate.deployments.arg" -} }
298+ { {- $deployments := include " autoUpdate.deployments" . -} }
299+ { {- $deployments = replace " [" " " $deployments -} }
300+ { {- $deployments = replace " ]" " " $deployments -} }
301+ { {- $deployments = replace " \" " " " $deployments -} }
302+ - "--update-deployments={ { $deployments } }"
303+ { {- end -} }
304+
305+ { {- define " spec.common.commandArgs" -} }
306+ # Cluster identification flags
307+ - "--cluster-external-id={ { coalesce .Values.global.clusterExternalId .Values.webhook.clusterExternalId .Values.opaWebhook.clusterExternalId } }"
308+ - "--subscription-external-id={ { coalesce .Values.global.subscriptionExternalId .Values.webhook.subscriptionExternalId } }"
309+ { {- with (coalesce .Values.global.clusterTags .Values.webhook.clusterTags) } }
310+ - --cluster-tags
311+ - { { . | toJson | quote } }
312+ { {- end } }
313+ { {- with (coalesce .Values.global.subscriptionTags .Values.webhook.subscriptionTags) } }
314+ - --subscription-tags
315+ - { { . | toJson | quote } }
316+ { {- end } }
317+ { {- end -} }
318+
319+ { {- define " spec.admissionControllerRunner.commandArgs" -} }
320+ # Server flags
321+ - "--port={ { .Values.service.targetPort } }"
322+ - "--tls-private-key-file=/var/server-certs/tls.key"
323+ - "--tls-cert-file=/var/server-certs/tls.crt"
324+ - "--readiness-port={ { .Values.healthPort } }"
325+ # Kubernetes API server flags
326+ - "--namespace-cache-ttl={ { .Values.kubernetesApiServer.cacheNamespaceLabelsTTL } }"
327+ { {- end -} }
328+
329+ { {- define " spec.common.envVars" -} }
330+ { {- if not .Values.wizApiToken.usePodCustomEnvironmentVariablesFile } }
331+ - name: WIZ_CLIENT_ID
332+ valueFrom:
333+ secretKeyRef:
334+ name: { { include " wiz-admission-controller.secretApiTokenName" . | trim } }
335+ key: clientId
336+ optional: false
337+ - name: WIZ_CLIENT_TOKEN
338+ valueFrom:
339+ secretKeyRef:
340+ name: { { include " wiz-admission-controller.secretApiTokenName" . | trim } }
341+ key: clientToken
342+ optional: false
343+ { {- end } }
344+ - name: WIZ_ENV
345+ value: { { coalesce .Values.global.wizApiToken.clientEndpoint .Values.wizApiToken.clientEndpoint | quote } }
346+ { {- if or .Values.global.httpProxyConfiguration.enabled .Values.httpProxyConfiguration.enabled } }
347+ - name: HTTP_PROXY
348+ valueFrom:
349+ secretKeyRef:
350+ name: { { include " wiz-admission-controller.proxySecretName" . | trim } }
351+ key: httpProxy
352+ optional: false
353+ - name: HTTPS_PROXY
354+ valueFrom:
355+ secretKeyRef:
356+ name: { { include " wiz-admission-controller.proxySecretName" . | trim } }
357+ key: httpsProxy
358+ optional: false
359+ - name: NO_PROXY
360+ valueFrom:
361+ secretKeyRef:
362+ name: { { include " wiz-admission-controller.proxySecretName" . | trim } }
363+ key: noProxyAddress
364+ optional: false
365+ { {- end } }
366+ { {- if .Values.logLevel } }
367+ - name: LOG_LEVEL
368+ value: { { .Values.logLevel } }
369+ { {- end } }
370+ { {- with .Values.podCustomEnvironmentVariables } }
371+ { {- toYaml . | nindent 14 } }
372+ { {- end } }
373+ { {- with .Values.global.podCustomEnvironmentVariables } }
374+ { {- toYaml . | nindent 14 } }
375+ { {- end } }
376+ { {- if .Values.podCustomEnvironmentVariablesFile } }
377+ - name: CLI_ENV_FILE
378+ value: { { .Values.podCustomEnvironmentVariablesFile } }
379+ - name: USE_CLI_ENV_FILE
380+ value: "true"
381+ { {- end } }
382+ - name: WIZ_RUNTIME_METADATA_POD_NAME
383+ valueFrom:
384+ fieldRef:
385+ fieldPath: metadata.name
386+ - name: WIZ_RUNTIME_METADATA_NODE_NAME
387+ valueFrom:
388+ fieldRef:
389+ fieldPath: spec.nodeName
390+ - name: K8S_NAMESPACE
391+ valueFrom:
392+ fieldRef:
393+ fieldPath: metadata.namespace
394+ - name: WIZ_TERMINATION_GRACE_PERIOD
395+ value: "{ { .Values.global.podTerminationGracePeriodSeconds } }s"
396+ { {- if .Values.global.istio.enabled } }
397+ - name: WIZ_ISTIO_PROXY_ENABLED
398+ value: "true"
399+ - name: WIZ_ISTIO_PROXY_PORT
400+ value: "{ { .Values.global.istio.proxySidecarPort } }"
401+ { {- end } }
402+ { {- end -} }
0 commit comments