Skip to content

Commit

Permalink
helm: support ratelimit image pull secrets and pull policy (envoyprox…
Browse files Browse the repository at this point in the history
…y#3454)

* support ratelimit image pull secrets

Signed-off-by: huabing zhao <[email protected]>

* support ratelimit image pull policy

Signed-off-by: huabing zhao <[email protected]>

* fix gen check

Signed-off-by: Huabing Zhao <[email protected]>

---------

Signed-off-by: huabing zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
  • Loading branch information
zhaohuabing authored May 29, 2024
1 parent fc853ce commit 62f1abf
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 12 deletions.
4 changes: 3 additions & 1 deletion charts/gateway-helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ To uninstall the chart:
| 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.envoyGateway.pullSecrets | list | `[]` | |
| global.images.ratelimit.image | string | `"docker.io/envoyproxy/ratelimit:master"` | |
| global.images.ratelimit.pullPolicy | string | `"IfNotPresent"` | |
| global.images.ratelimit.pullSecrets | list | `[]` | |
| kubernetesClusterDomain | string | `"cluster.local"` | |

20 changes: 18 additions & 2 deletions charts/gateway-helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ Pull secrets for the Envoy Gateway image.
{{- if .Values.deployment.envoyGateway.imagePullSecrets -}}
imagePullSecrets:
{{ toYaml .Values.deployment.envoyGateway.imagePullSecrets }}
{{- else if .Values.global.images.envoyGateway.imagePullSecrets -}}
{{- else if .Values.global.images.envoyGateway.pullSecrets -}}
imagePullSecrets:
{{ toYaml .Values.global.images.envoyGateway.imagePullSecrets }}
{{ toYaml .Values.global.images.envoyGateway.pullSecrets }}
{{- else -}}
imagePullSecrets: []
{{- end }}
Expand All @@ -110,6 +110,22 @@ provider:
{{- else }}
image: "docker.io/envoyproxy/ratelimit:master"
{{- end }}
{{- with .Values.global.images.ratelimit.pullSecrets }}
pod:
imagePullSecrets:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.global.images.ratelimit.pullPolicy }}
patch:
type: StrategicMerge
value:
spec:
template:
spec:
containers:
- name: envoy-ratelimit
imagePullPolicy: {{ . }}
{{- end }}
shutdownManager:
image: {{ include "eg.image" . }}
{{- end }}
8 changes: 3 additions & 5 deletions charts/gateway-helm/values.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ global:
# 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: []
pullSecrets: []
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
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
pullSecrets: []

deployment:
envoyGateway:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,9 @@ func (r *ResourceRender) Deployment() (*appsv1.Deployment, error) {
}

// apply merge patch to deployment
if merged, err := r.rateLimitDeployment.ApplyMergePatch(deployment); err == nil {
deployment = merged
var err error
if deployment, err = r.rateLimitDeployment.ApplyMergePatch(deployment); err != nil {
return nil, err
}

return deployment, nil
Expand Down
4 changes: 3 additions & 1 deletion site/content/en/latest/install/gateway-helm-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ The Helm chart for Envoy Gateway
| 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.envoyGateway.pullSecrets | list | `[]` | |
| global.images.ratelimit.image | string | `"docker.io/envoyproxy/ratelimit:master"` | |
| global.images.ratelimit.pullPolicy | string | `"IfNotPresent"` | |
| global.images.ratelimit.pullSecrets | list | `[]` | |
| kubernetesClusterDomain | string | `"cluster.local"` | |

9 changes: 9 additions & 0 deletions test/helm/default-config.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ data:
rateLimitDeployment:
container:
image: docker.io/envoyproxy/ratelimit:master
patch:
type: StrategicMerge
value:
spec:
template:
spec:
containers:
- imagePullPolicy: IfNotPresent
name: envoy-ratelimit
shutdownManager:
image: docker.io/envoyproxy/gateway-dev:latest
type: Kubernetes
Expand Down
9 changes: 9 additions & 0 deletions test/helm/deployment-images-config.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ data:
rateLimitDeployment:
container:
image: docker.io/envoyproxy/ratelimit:master
patch:
type: StrategicMerge
value:
spec:
template:
spec:
containers:
- imagePullPolicy: IfNotPresent
name: envoy-ratelimit
shutdownManager:
image: private-hub/envoyproxy/gateway:abcdef12
type: Kubernetes
Expand Down
9 changes: 9 additions & 0 deletions test/helm/envoy-gateway-config.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ data:
rateLimitDeployment:
container:
image: private-hub/envoyproxy/ratelimit:master
patch:
type: StrategicMerge
value:
spec:
template:
spec:
containers:
- imagePullPolicy: IfNotPresent
name: envoy-ratelimit
shutdownManager:
image: docker.io/envoyproxy/gateway-dev:latest
type: Kubernetes
Expand Down
6 changes: 5 additions & 1 deletion test/helm/global-images-config.in.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ global:
envoyGateway:
image: "private-hub/envoyproxy/gateway:abcdef12"
pullPolicy: Always
imagePullSecrets:
pullSecrets:
- name: "secret1"
- name: "secret2"
ratelimit:
image: "private-hub/envoyproxy/ratelimit:test"
pullPolicy: Always
pullSecrets:
- name: "secret3"
- name: "secret4"
13 changes: 13 additions & 0 deletions test/helm/global-images-config.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ data:
rateLimitDeployment:
container:
image: private-hub/envoyproxy/ratelimit:test
patch:
type: StrategicMerge
value:
spec:
template:
spec:
containers:
- imagePullPolicy: Always
name: envoy-ratelimit
pod:
imagePullSecrets:
- name: secret3
- name: secret4
shutdownManager:
image: private-hub/envoyproxy/gateway:abcdef12
type: Kubernetes
Expand Down

0 comments on commit 62f1abf

Please sign in to comment.