Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add global image settings for all images in the EG chart #3389

Merged
merged 26 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions charts/gateway-helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,56 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
The name of the Envoy Gateway image.
*/}}
{{- define "eg.image" -}}
{{- if .Values.deployment.envoyGateway.image.repository }}
{{- .Values.deployment.envoyGateway.image.repository }}:{{ .Values.deployment.envoyGateway.image.tag | default .Values.global.images.envoyGateway.tag | default .Chart.AppVersion }}
{{- else if .Values.global.images.envoyGateway.image }}
{{- .Values.global.images.envoyGateway.image }}
{{- else }}
docker.io/envoyproxy/gateway:{{ .Chart.Version }}
{{- end }}
{{- end }}

{{/*
Pull policy for the Envoy Gateway image.
*/}}
{{- define "eg.image.pullPolicy" -}}
{{ .Values.deployment.envoyGateway.imagePullPolicy | default .Values.global.images.envoyGateway.pullPolicy | default "IfNotPresent" }}
{{- end }}

{{/*
Pull secrets for the Envoy Gateway image.
*/}}
{{- define "eg.image.pullSecrets" -}}
{{- if .Values.deployment.envoyGateway.imagePullSecrets -}}
imagePullSecrets:
{{ toYaml .Values.deployment.envoyGateway.imagePullSecrets }}
{{- else if .Values.global.images.envoyGateway.imagePullSecrets -}}
imagePullSecrets:
{{ toYaml .Values.global.images.envoyGateway.imagePullSecrets }}
{{- else -}}
imagePullSecrets: []
{{- end }}
{{- end }}

{{/*
The default Envoy Gateway configuration.
*/}}
{{- define "eg.default-envoy-gateway-config" -}}
provider:
type: Kubernetes
kubernetes:
rateLimitDeployment:
container:
{{- if .Values.global.images.ratelimit.image }}
image: {{ .Values.global.images.ratelimit.image }}
{{- else }}
image: "docker.io/envoyproxy/ratelimit:master"
{{- end }}
shutdownManager:
image: {{ include "eg.image" . }}
{{- end }}
9 changes: 3 additions & 6 deletions charts/gateway-helm/templates/certgen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,14 @@ spec:
fieldPath: metadata.namespace
- name: KUBERNETES_CLUSTER_DOMAIN
value: {{ .Values.kubernetesClusterDomain }}
image: {{ .Values.deployment.envoyGateway.image.repository }}:{{ .Values.deployment.envoyGateway.image.tag | default .Chart.AppVersion }}
imagePullPolicy: {{ .Values.deployment.envoyGateway.imagePullPolicy }}
image: {{ include "eg.image" . }}
imagePullPolicy: {{ include "eg.image.pullPolicy" . }}
name: envoy-gateway-certgen
{{- with .Values.certgen.job.resources }}
resources:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.deployment.envoyGateway.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "eg.image.pullSecrets" . | nindent 6 }}
restartPolicy: Never
securityContext:
runAsGroup: 65534
Expand Down
5 changes: 4 additions & 1 deletion charts/gateway-helm/templates/envoy-gateway-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ data:
envoy-gateway.yaml: |
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyGateway
{{- toYaml .Values.config.envoyGateway | nindent 4 }}
{{- $baseEnvoyGatewayConfig := include "eg.default-envoy-gateway-config" . | fromYaml }}
{{- $userEnvoyGatewayConfig := .Values.config.envoyGateway }}
{{- $mergedEnvoyGatewayConfig := merge $userEnvoyGatewayConfig $baseEnvoyGatewayConfig }}
{{- toYaml $mergedEnvoyGatewayConfig | nindent 4 }}
9 changes: 3 additions & 6 deletions charts/gateway-helm/templates/envoy-gateway-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ spec:
fieldPath: metadata.namespace
- name: KUBERNETES_CLUSTER_DOMAIN
value: {{ .Values.kubernetesClusterDomain }}
image: {{ .Values.deployment.envoyGateway.image.repository }}:{{ .Values.deployment.envoyGateway.image.tag | default .Chart.AppVersion }}
imagePullPolicy: {{ .Values.deployment.envoyGateway.imagePullPolicy }}
image: {{ include "eg.image" . }}
imagePullPolicy: {{ include "eg.image.pullPolicy" . }}
livenessProbe:
httpGet:
path: /healthz
Expand Down Expand Up @@ -80,10 +80,7 @@ spec:
- mountPath: /certs
name: certs
readOnly: true
{{- with .Values.deployment.envoyGateway.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "eg.image.pullSecrets" . | nindent 6 }}
securityContext:
runAsNonRoot: true
serviceAccountName: envoy-gateway
Expand Down
32 changes: 26 additions & 6 deletions charts/gateway-helm/values.tmpl.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
# The global settings for the Envoy Gateway Helm chart.
# These values will be used if the values are not overridden in the other sections.
global:
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
images:
envoyGateway:
# This is the full image name including the hub, repo, and tag.
image: ${GatewayImage}
# Specify image pull policy if default behavior isn't desired.
# Default behavior: latest images will be Always else IfNotPresent.
pullPolicy: ${GatewayImagePullPolicy}
# List of secrets in the same namespace of the component that can be used to pull images from private repositories.
imagePullSecrets: []
ratelimit:
# This is the full image name including the hub, repo, and tag.
image: "docker.io/envoyproxy/ratelimit:master"
# TODO: zhaohuabing add support for imagePullSecrets for ratelimit
# Specify image pull policy if default behavior isn't desired.
# Default behavior: latest images will be Always else IfNotPresent.
# pullPolicy: IfNotPresent
# List of secrets in the same namespace of the component that can be used to pull images from private repositories.
# imagePullSecrets: []
# statsd: TODO: zhaohuabing add custom image support for statsd image

deployment:
envoyGateway:
image:
repository: ${ImageRepository}
tag: '${ImageTag}'
imagePullPolicy: ${ImagePullPolicy}
repository: ""
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
tag: ""
imagePullPolicy: ""
imagePullSecrets: []
resources:
limits:
Expand Down Expand Up @@ -36,9 +59,6 @@ config:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
provider:
type: Kubernetes
kubernetes:
shutdownManager:
image: ${ImageRepository}:${ImageTag}
logging:
level:
default: info
Expand Down
11 changes: 7 additions & 4 deletions site/content/en/latest/install/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ The Helm chart for Envoy Gateway
| certgen.rbac.labels | object | `{}` | |
| config.envoyGateway.gateway.controllerName | string | `"gateway.envoyproxy.io/gatewayclass-controller"` | |
| config.envoyGateway.logging.level.default | string | `"info"` | |
| config.envoyGateway.provider.kubernetes.shutdownManager.image | string | `"docker.io/envoyproxy/gateway:latest"` | |
| config.envoyGateway.provider.type | string | `"Kubernetes"` | |
| createNamespace | bool | `false` | |
| deployment.envoyGateway.image.repository | string | `"docker.io/envoyproxy/gateway"` | |
| deployment.envoyGateway.image.tag | string | `"latest"` | |
| deployment.envoyGateway.imagePullPolicy | string | `"IfNotPresent"` | |
| deployment.envoyGateway.image.repository | string | `""` | |
Copy link
Contributor

@arkodg arkodg May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we delete these fields then ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just keep this for back compatibility. If removed, the existing helm value file containing these values won't work, which will surprise users.

| deployment.envoyGateway.image.tag | string | `""` | |
| deployment.envoyGateway.imagePullPolicy | string | `""` | |
| deployment.envoyGateway.imagePullSecrets | list | `[]` | |
| deployment.envoyGateway.resources.limits.cpu | string | `"500m"` | |
| deployment.envoyGateway.resources.limits.memory | string | `"1024Mi"` | |
Expand All @@ -56,5 +55,9 @@ The Helm chart for Envoy Gateway
| deployment.ports[2].port | int | `19001` | |
| deployment.ports[2].targetPort | int | `19001` | |
| deployment.replicas | int | `1` | |
| global.images.envoyGateway.image | string | `nil` | |
| global.images.envoyGateway.imagePullSecrets | list | `[]` | |
| global.images.envoyGateway.pullPolicy | string | `nil` | |
| global.images.ratelimit.image | string | `"docker.io/envoyproxy/ratelimit:master"` | |
| kubernetesClusterDomain | string | `"cluster.local"` | |

5 changes: 5 additions & 0 deletions test/helm/default-config.in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
global:
images:
envoyGateway:
image: "docker.io/envoyproxy/gateway-dev:latest"
pullPolicy: Always
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ data:
default: info
provider:
kubernetes:
rateLimitDeployment:
container:
image: docker.io/envoyproxy/ratelimit:master
shutdownManager:
image: docker.io/envoyproxy/gateway-dev:latest
type: Kubernetes
Expand Down Expand Up @@ -372,7 +375,7 @@ spec:
- name: KUBERNETES_CLUSTER_DOMAIN
value: cluster.local
image: docker.io/envoyproxy/gateway-dev:latest
imagePullPolicy: IfNotPresent
imagePullPolicy: Always
livenessProbe:
httpGet:
path: /healthz
Expand Down Expand Up @@ -409,6 +412,7 @@ spec:
- mountPath: /certs
name: certs
readOnly: true
imagePullSecrets: []
securityContext:
runAsNonRoot: true
serviceAccountName: envoy-gateway
Expand Down Expand Up @@ -520,8 +524,9 @@ spec:
- name: KUBERNETES_CLUSTER_DOMAIN
value: cluster.local
image: docker.io/envoyproxy/gateway-dev:latest
imagePullPolicy: IfNotPresent
imagePullPolicy: Always
name: envoy-gateway-certgen
imagePullSecrets: []
restartPolicy: Never
securityContext:
runAsGroup: 65534
Expand Down
11 changes: 11 additions & 0 deletions test/helm/deployment-images-config.in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# The image in the deployment is replaced with the image from the global configuration.
# It's retained for backwards compatibility.
deployment:
envoyGateway:
image:
repository: private-hub/envoyproxy/gateway
tag: abcdef12
imagePullPolicy: IfNotPresent
imagePullSecrets:
- name: "secret1"
- name: "secret2"
Loading
Loading