Description
Bug Report
What did you do?
While generating the Operator bundle using operator-sdk
(v1.35.0) with Kustomize and RELATED_IMAGE_*
environment variables set, I noticed that the generated ClusterServiceVersion (CSV) does not correctly resolve and populate the relatedImages
section unless I hardcode the image value directly in the manifest patch.
This behavior breaks the expected design, where:
- A Kustomize patch uses a variable such as
${RELATED_IMAGE_KUBE_RBAC_PROXY}
. - The environment variable is set prior to running the SDK commands.
- The Operator SDK should substitute that variable and automatically populate the
relatedImages
block accordingly in the generatedbundle/manifests/*.clusterserviceversion.yaml
.
However, unless the image is hardcoded in the patch file, the relatedImages
array in the CSV is either missing or incomplete. This makes the usage of environment-variable-driven workflows brittle and defeats the purpose of using Kustomize + envs for reproducible builds.
Reproduction Steps:
-
Define a patch with
${RELATED_IMAGE_KUBE_RBAC_PROXY}
in your Kustomize overlay (manager_auth_proxy_patch.yaml
). -
Set the env var before running:
export RELATED_IMAGE_KUBE_RBAC_PROXY=gcr.io/kubebuilder/kube-rbac-proxy:v0.13.1
-
Run:
operator-sdk generate kustomize manifests kustomize build config/manifests | operator-sdk generate bundle --package=<your-package>
-
Check the generated CSV under
bundle/manifests/*.clusterserviceversion.yaml
.
Additional context:
The CSV does correctly reference the env var inside the env
array (e.g., value: ${RELATED_IMAGE_KUBE_RBAC_PROXY}
), but the image
field itself does not seem to get substituted during CSV generation for relatedImages
.
What did you expect to see?
The relatedImages
section should include:
relatedImages:
- name: kube-rbac-proxy
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.1
What did you see instead? Under which circumstances?
relatedImages
is either empty or not populated unless the image is hardcoded. So if I have:
containers:
- name: kube-rbac-proxy
image: ${RELATED_IMAGE_KUBE_RBAC_PROXY}
env:
- name: RELATED_IMAGE_KUBE_RBAC_PROXY
value: ${RELATED_IMAGE_KUBE_RBAC_PROXY}
The spec.relatedImages
field will have something like:
relatedImages:
- name: kube-rbac-proxy
image: ${RELATED_IMAGE_KUBE_RBAC_PROXY}
How can we use variable substitution in this scenario?
Environment
- Operator SDK version:
v1.35.0
- Kustomize used via:
operator-sdk generate kustomize manifests
- Image reference format:
${RELATED_IMAGE_KUBE_RBAC_PROXY}
inside patch YAML
Operator type:
/language go
Kubernetes cluster type:
OpenShift
$ operator-sdk version
operator-sdk version: "v1.35.0", commit: "e95abdbd5ccb7ca0fd586e0c6f578e491b0a025b", kubernetes version: "1.28.0", go version: "go1.21.11", GOOS: "darwin", GOARCH: "arm64"
$ go version
(if language is Go)
$ kubectl version