Skip to content

relatedImages entry not populated in generated CSV when using Kustomize patches #6931

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

Open
ricardozanini opened this issue May 5, 2025 · 0 comments
Labels
language/go Issue is related to a Go operator project

Comments

@ricardozanini
Copy link

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 generated bundle/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:

  1. Define a patch with ${RELATED_IMAGE_KUBE_RBAC_PROXY} in your Kustomize overlay (manager_auth_proxy_patch.yaml).

  2. Set the env var before running:

    export RELATED_IMAGE_KUBE_RBAC_PROXY=gcr.io/kubebuilder/kube-rbac-proxy:v0.13.1
  3. Run:

    operator-sdk generate kustomize manifests
    kustomize build config/manifests | operator-sdk generate bundle --package=<your-package>
  4. 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

Possible Solution

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language/go Issue is related to a Go operator project
Projects
None yet
Development

No branches or pull requests

1 participant