envoyproxy / envoyproxy/gateway
global.imageRegistry with sub-path causes duplicated path segments in constructed image references
- Dominant language
- Go
- Stars
- 3k
- Forks
- 864
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 140
Description
*Description*:
>When global.imageRegistry contains a sub-path (e.g., myregistry.example.com:5443/my-subpath), the eg.image and eg.ratelimit.image helper templates produce an image reference with the sub-path duplicated, causing image pull failures.
*Repro steps*:
> Install the gateway-helm chart with the following values:
```yaml
global:
imageRegistry: "myregistry.example.com:5443/my-subpath"
images:
envoyGateway:
image: "myregistry.example.com:5443/my-subpath/envoyproxy/gateway:v1.7.0"
```
Or via the deployment-specific path:
```yaml
global:
imageRegistry: "myregistry.example.com:5443/my-subpath"
deployment:
envoyGateway:
image:
repository: "myregistry.example.com:5443/my-subpath/envoyproxy/gateway"
```
*Environment*:
>Envoy Gateway version: v1.7.0
Kubernetes version: N/A (template rendering issue)
Installation method: Helm
*Expected Result*:
>myregistry.example.com:5443/my-subpath/envoyproxy/gateway:v1.7.0
*Actual Result*:
>
```
myregistry.example.com:5443/my-subpath/my-subpath/envoyproxy/gateway:v1.7.0
^^^^^^^^^^
duplicated
```
*Root Cause*:
The image construction logic in [_helpers.tpl](vscode-file://vscode-app/c:/Users/Krishnan.Nadesan/AppData/Local/Programs/Microsoft%20VS%20Code/10c8e557c8/resources/app/out/vs/code/electron-browser/workbench/workbench.html) uses splitn "/" 2 to separate the registry from the repository path. This split assumes the registry is only host:port (everything before the first /). When global.imageRegistry includes a sub-path, the split doesn't account for it:
eg.image — global.images branch (lines ~83–91):
```
{{- $imageParts := splitn "/" 2 .Values.global.images.envoyGateway.image -}}
{{- $registryName := default $imageParts._0 .Values.global.imageRegistry -}}
{{- $repositoryTag := $imageParts._1 -}}
...
{{- printf "%s/%s:%s" $registryName $repositoryName $imageTag -}}
```
Given image: "myregistry.example.com:5443/my-subpath/envoyproxy/gateway:v1.7.0":
splitn "/" 2 produces _0 = "myregistry.example.com:5443" and _1 = "my-subpath/envoyproxy/gateway:v1.7.0"
$registryName is overridden to "myregistry.example.com:5443/my-subpath" (from global.imageRegistry)
$repositoryTag still contains "my-subpath/envoyproxy/gateway:v1.7.0"
printf joins them → "myregistry.example.com:5443/my-subpath/my-subpath/envoyproxy/gateway:v1.7.0"
The same issue exists in:
eg.image — deployment.envoyGateway.image.repository branch (lines ~71–77)
eg.ratelimit.image (lines ~122–133)
*Suggested Fix*:
Since global.images.*.image already contains the full registry/repo:tag reference, the simplest fix is to just swap out the first path segment (the original registry host) when global.imageRegistry is set, rather than decomposing and reconstructing the full path:
```
{{- define "eg.image" -}}
{{- if .Values.deployment.envoyGateway.image.repository -}}
{{- $imageTag := default .Chart.AppVersion .Values.deployment.envoyGateway.image.tag -}}
{{- if .Values.global.imageRegistry -}}
{{- $repoPath := (splitn "/" 2 .Values.deployment.envoyGateway.image.repository)._1 -}}
{{- printf "%s/%s:%s" .Values.global.imageRegistry $repoPath $imageTag -}}
{{- else -}}
{{- printf "%s:%s" .Values.deployment.envoyGateway.image.repository $imageTag -}}
{{- end -}}
{{- else if .Values.global.images.envoyGateway.image -}}
{{- if .Values.global.imageRegistry -}}
{{- $repoAndTag := (splitn "/" 2 .Values.global.images.envoyGateway.image)._1 -}}
{{- printf "%s/%s" .Values.global.imageRegistry $repoAndTag -}}
{{- else -}}
{{- .Values.global.images.envoyGateway.image -}}
{{- end -}}
{{- else -}}
docker.io/envoyproxy/gateway:{{ .Chart.Version }}
{{- end -}}
{{- end -}}
```
Same pattern for eg.ratelimit.image.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.