1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

feat: Implement global values for image registry in Kyverno Helm chart (#8625) (#8694)

* feat: Add image registry to global values



* Fix indentation



* Update documentation



---------

Signed-off-by: Franco <franco@giantswarm.io>
Co-authored-by: Franco Hielpos <48300215+fhielpos@users.noreply.github.com>
This commit is contained in:
gcp-cherry-pick-bot[bot] 2023-10-19 14:30:17 +00:00 committed by GitHub
parent cf65fc2f48
commit 6fcf2bc22b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 43 additions and 19 deletions

View file

@ -629,7 +629,10 @@ The chart values are organised per component.
| Key | Type | Default | Description | | Key | Type | Default | Description |
|-----|------|---------|-------------| |-----|------|---------|-------------|
| webhooksCleanup.enabled | bool | `true` | Create a helm pre-delete hook to cleanup webhooks. | | webhooksCleanup.enabled | bool | `true` | Create a helm pre-delete hook to cleanup webhooks. |
| webhooksCleanup.image | string | `"bitnami/kubectl:latest"` | `kubectl` image to run commands for deleting webhooks. | | webhooksCleanup.image.registry | string | `nil` | Image registry |
| webhooksCleanup.image.repository | string | `"bitnami/kubectl"` | Image repository |
| webhooksCleanup.image.tag | string | `"1.26.4"` | Image tag Defaults to `latest` if omitted |
| webhooksCleanup.image.pullPolicy | string | `nil` | Image pull policy Defaults to image.pullPolicy if omitted |
| webhooksCleanup.imagePullSecrets | list | `[]` | Image pull secrets | | webhooksCleanup.imagePullSecrets | list | `[]` | Image pull secrets |
| webhooksCleanup.podSecurityContext | object | `{}` | Security context for the pod | | webhooksCleanup.podSecurityContext | object | `{}` | Security context for the pod |
| webhooksCleanup.nodeSelector | object | `{}` | Node labels for pod assignment | | webhooksCleanup.nodeSelector | object | `{}` | Node labels for pod assignment |
@ -704,6 +707,7 @@ The chart values are organised per component.
| Key | Type | Default | Description | | Key | Type | Default | Description |
|-----|------|---------|-------------| |-----|------|---------|-------------|
| global.image.registry | string | `nil` | Global value that allows to set a single image registry across all deployments. When set, it will override any values set under `.image.registry` across the chart. |
| nameOverride | string | `nil` | Override the name of the chart | | nameOverride | string | `nil` | Override the name of the chart |
| fullnameOverride | string | `nil` | Override the expanded name of the chart | | fullnameOverride | string | `nil` | Override the expanded name of the chart |
| namespaceOverride | string | `nil` | Override the namespace the chart deploys to | | namespaceOverride | string | `nil` | Override the namespace the chart deploys to |

View file

@ -5,8 +5,9 @@
{{- if not (typeIs "string" $tag) -}} {{- if not (typeIs "string" $tag) -}}
{{ fail "Image tags must be strings." }} {{ fail "Image tags must be strings." }}
{{- end -}} {{- end -}}
{{- if .image.registry -}} {{- $imageRegistry := default .image.registry .globalRegistry -}}
{{- print .image.registry "/" (required "An image repository is required" .image.repository) ":" $tag -}} {{- if $imageRegistry -}}
{{- print $imageRegistry "/" (required "An image repository is required" .image.repository) ":" $tag -}}
{{- else -}} {{- else -}}
{{- print (required "An image repository is required" .image.repository) ":" $tag -}} {{- print (required "An image repository is required" .image.repository) ":" $tag -}}
{{- end -}} {{- end -}}

View file

@ -78,7 +78,7 @@ spec:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
- name: kyverno-pre - name: kyverno-pre
image: {{ include "kyverno.image" (dict "image" .Values.admissionController.initContainer.image "defaultTag" (default .Chart.AppVersion .Values.admissionController.container.image.tag)) | quote }} image: {{ include "kyverno.image" (dict "globalRegistry" ((.Values.global).image).registry "image" .Values.admissionController.initContainer.image "defaultTag" (default .Chart.AppVersion .Values.admissionController.container.image.tag)) | quote }}
imagePullPolicy: {{ default .Values.admissionController.container.image.pullPolicy .Values.admissionController.initContainer.image.pullPolicy }} imagePullPolicy: {{ default .Values.admissionController.container.image.pullPolicy .Values.admissionController.initContainer.image.pullPolicy }}
args: args:
{{- include "kyverno.features.flags" (pick (mergeOverwrite .Values.features .Values.admissionController.featuresOverride) {{- include "kyverno.features.flags" (pick (mergeOverwrite .Values.features .Values.admissionController.featuresOverride)
@ -124,7 +124,7 @@ spec:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
- name: kyverno - name: kyverno
image: {{ include "kyverno.image" (dict "image" .Values.admissionController.container.image "defaultTag" .Chart.AppVersion) | quote }} image: {{ include "kyverno.image" (dict "globalRegistry" ((.Values.global).image).registry "image" .Values.admissionController.container.image "defaultTag" .Chart.AppVersion) | quote }}
imagePullPolicy: {{ .Values.admissionController.container.image.pullPolicy }} imagePullPolicy: {{ .Values.admissionController.container.image.pullPolicy }}
args: args:
- --caSecretName={{ template "kyverno.admission-controller.serviceName" . }}.{{ template "kyverno.namespace" . }}.svc.kyverno-tls-ca - --caSecretName={{ template "kyverno.admission-controller.serviceName" . }}.{{ template "kyverno.namespace" . }}.svc.kyverno-tls-ca

View file

@ -19,8 +19,9 @@
{{- end -}} {{- end -}}
{{- define "kyverno.background-controller.image" -}} {{- define "kyverno.background-controller.image" -}}
{{- if .image.registry -}} {{- $imageRegistry := default .image.registry .globalRegistry -}}
{{ .image.registry }}/{{ required "An image repository is required" .image.repository }}:{{ default .defaultTag .image.tag }} {{- if $imageRegistry -}}
{{ $imageRegistry }}/{{ required "An image repository is required" .image.repository }}:{{ default .defaultTag .image.tag }}
{{- else -}} {{- else -}}
{{ required "An image repository is required" .image.repository }}:{{ default .defaultTag .image.tag }} {{ required "An image repository is required" .image.repository }}:{{ default .defaultTag .image.tag }}
{{- end -}} {{- end -}}

View file

@ -76,7 +76,7 @@ spec:
serviceAccountName: {{ template "kyverno.background-controller.serviceAccountName" . }} serviceAccountName: {{ template "kyverno.background-controller.serviceAccountName" . }}
containers: containers:
- name: controller - name: controller
image: {{ include "kyverno.background-controller.image" (dict "image" .Values.backgroundController.image "defaultTag" .Chart.AppVersion) | quote }} image: {{ include "kyverno.background-controller.image" (dict "globalRegistry" ((.Values.global).image).registry "image" .Values.backgroundController.image "defaultTag" .Chart.AppVersion) | quote }}
imagePullPolicy: {{ .Values.backgroundController.image.pullPolicy }} imagePullPolicy: {{ .Values.backgroundController.image.pullPolicy }}
ports: ports:
- containerPort: 9443 - containerPort: 9443

View file

@ -19,8 +19,9 @@
{{- end -}} {{- end -}}
{{- define "kyverno.cleanup-controller.image" -}} {{- define "kyverno.cleanup-controller.image" -}}
{{- if .image.registry -}} {{- $imageRegistry := default .image.registry .globalRegistry -}}
{{ .image.registry }}/{{ required "An image repository is required" .image.repository }}:{{ default .defaultTag .image.tag }} {{- if $imageRegistry -}}
{{ $imageRegistry }}/{{ required "An image repository is required" .image.repository }}:{{ default .defaultTag .image.tag }}
{{- else -}} {{- else -}}
{{ required "An image repository is required" .image.repository }}:{{ default .defaultTag .image.tag }} {{ required "An image repository is required" .image.repository }}:{{ default .defaultTag .image.tag }}
{{- end -}} {{- end -}}

View file

@ -76,7 +76,7 @@ spec:
serviceAccountName: {{ template "kyverno.cleanup-controller.serviceAccountName" . }} serviceAccountName: {{ template "kyverno.cleanup-controller.serviceAccountName" . }}
containers: containers:
- name: controller - name: controller
image: {{ include "kyverno.cleanup-controller.image" (dict "image" .Values.cleanupController.image "defaultTag" .Chart.AppVersion) | quote }} image: {{ include "kyverno.cleanup-controller.image" (dict "globalRegistry" ((.Values.global).image).registry "image" .Values.cleanupController.image "defaultTag" .Chart.AppVersion) | quote }}
imagePullPolicy: {{ .Values.cleanupController.image.pullPolicy }} imagePullPolicy: {{ .Values.cleanupController.image.pullPolicy }}
ports: ports:
- containerPort: 9443 - containerPort: 9443

View file

@ -31,7 +31,7 @@ spec:
{{- end }} {{- end }}
containers: containers:
- name: cleanup - name: cleanup
image: {{ (include "kyverno.image" .Values.cleanupJobs.admissionReports) | quote }} image: {{ (include "kyverno.image" (dict "globalRegistry" ((.Values.global).image).registry "image" .Values.cleanupJobs.admissionReports.image)) | quote }}
imagePullPolicy: {{ .Values.cleanupJobs.admissionReports.image.pullPolicy }} imagePullPolicy: {{ .Values.cleanupJobs.admissionReports.image.pullPolicy }}
command: command:
- /bin/sh - /bin/sh

View file

@ -31,7 +31,7 @@ spec:
{{- end }} {{- end }}
containers: containers:
- name: cleanup - name: cleanup
image: {{ (include "kyverno.image" .Values.cleanupJobs.clusterAdmissionReports) | quote }} image: {{ (include "kyverno.image" (dict "globalRegistry" ((.Values.global).image).registry "image" .Values.cleanupJobs.clusterAdmissionReports.image)) | quote }}
imagePullPolicy: {{ .Values.cleanupJobs.clusterAdmissionReports.image.pullPolicy }} imagePullPolicy: {{ .Values.cleanupJobs.clusterAdmissionReports.image.pullPolicy }}
command: command:
- /bin/sh - /bin/sh

View file

@ -26,7 +26,8 @@ spec:
{{- end }} {{- end }}
containers: containers:
- name: kubectl - name: kubectl
image: {{ .Values.webhooksCleanup.image }} image: {{ (include "kyverno.image" (dict "globalRegistry" ((.Values.global).image).registry "image" .Values.webhooksCleanup.image "defaultTag" (default .Chart.AppVersion .Values.webhooksCleanup.image.tag))) | quote }}
imagePullPolicy: {{ .Values.webhooksCleanup.image.pullPolicy }}
command: command:
- sh - sh
- '-c' - '-c'

View file

@ -19,8 +19,9 @@
{{- end -}} {{- end -}}
{{- define "kyverno.reports-controller.image" -}} {{- define "kyverno.reports-controller.image" -}}
{{- if .image.registry -}} {{- $imageRegistry := default .image.registry .globalRegistry -}}
{{ .image.registry }}/{{ required "An image repository is required" .image.repository }}:{{ default .defaultTag .image.tag }} {{- if $imageRegistry -}}
{{ $imageRegistry }}/{{ required "An image repository is required" .image.repository }}:{{ default .defaultTag .image.tag }}
{{- else -}} {{- else -}}
{{ required "An image repository is required" .image.repository }}:{{ default .defaultTag .image.tag }} {{ required "An image repository is required" .image.repository }}:{{ default .defaultTag .image.tag }}
{{- end -}} {{- end -}}

View file

@ -76,7 +76,7 @@ spec:
serviceAccountName: {{ template "kyverno.reports-controller.serviceAccountName" . }} serviceAccountName: {{ template "kyverno.reports-controller.serviceAccountName" . }}
containers: containers:
- name: controller - name: controller
image: {{ include "kyverno.reports-controller.image" (dict "image" .Values.reportsController.image "defaultTag" .Chart.AppVersion) | quote }} image: {{ include "kyverno.reports-controller.image" (dict "globalRegistry" ((.Values.global).image).registry "image" .Values.reportsController.image "defaultTag" .Chart.AppVersion) | quote }}
imagePullPolicy: {{ .Values.reportsController.image.pullPolicy }} imagePullPolicy: {{ .Values.reportsController.image.pullPolicy }}
ports: ports:
- containerPort: 9443 - containerPort: 9443

View file

@ -5,6 +5,12 @@ templating:
debug: false debug: false
version: ~ version: ~
global:
image:
# -- (string) Global value that allows to set a single image registry across all deployments.
# When set, it will override any values set under `.image.registry` across the chart.
registry: ~
# -- (string) Override the name of the chart # -- (string) Override the name of the chart
nameOverride: ~ nameOverride: ~
@ -322,8 +328,17 @@ webhooksCleanup:
# -- Create a helm pre-delete hook to cleanup webhooks. # -- Create a helm pre-delete hook to cleanup webhooks.
enabled: true enabled: true
# -- `kubectl` image to run commands for deleting webhooks. image:
image: bitnami/kubectl:latest # -- (string) Image registry
registry: ~
# -- Image repository
repository: bitnami/kubectl
# -- Image tag
# Defaults to `latest` if omitted
tag: '1.26.4'
# -- (string) Image pull policy
# Defaults to image.pullPolicy if omitted
pullPolicy: ~
# -- Image pull secrets # -- Image pull secrets
imagePullSecrets: [] imagePullSecrets: []