diff --git a/changelog/fragments/fix.yaml b/changelog/fragments/fix.yaml new file mode 100644 index 0000000000..6dcf881744 --- /dev/null +++ b/changelog/fragments/fix.yaml @@ -0,0 +1,8 @@ +# entries is a list of entries to include in +# release notes and/or the migration guide +entries: + - description: > + Fix operator-sdk generate kustomize manifests to respect changes made by users in the config/manifests + kind: "bugfix" + breaking: false + diff --git a/internal/plugins/manifests/v2/templates/config/manifests/kustomization.go b/internal/plugins/manifests/v2/templates/config/manifests/kustomization.go index 7e7b090a80..87c6122d72 100644 --- a/internal/plugins/manifests/v2/templates/config/manifests/kustomization.go +++ b/internal/plugins/manifests/v2/templates/config/manifests/kustomization.go @@ -36,6 +36,12 @@ func (f *Kustomization) SetTemplateDefaults() error { f.Path = filepath.Join("config", "manifests", "kustomization.yaml") } + // We cannot overwiting the file after it be created because + // it might contain user changes (i.e to work with Kustomize 4.x + // the target /spec/template/spec/containers/1/volumeMounts/0 + // needs to be replaced with /spec/template/spec/containers/0/volumeMounts/0 + f.IfExistsAction = machinery.SkipFile + f.TemplateBody = kustomizationTemplate return nil diff --git a/website/content/en/docs/faqs/_index.md b/website/content/en/docs/faqs/_index.md index 35aff6aacb..2adc81dff9 100644 --- a/website/content/en/docs/faqs/_index.md +++ b/website/content/en/docs/faqs/_index.md @@ -331,5 +331,19 @@ Here are a couple workarounds to try to resolve the issue: If neither of those solutions work for you, please [open an issue][open-issue] +## After updating my project to use a Kustomize 4.x version, 'make bundle' does not work + +**Valid only for Golang/Hybrid projects using webhooks** + +> `Error: remove operation does not apply:doc is missing path: "/spec/template/spec/containers/1/volumeMounts/0": missing value` + +The error occurs due to a change in the Kustomize 4.x versions where the containers used in the Deployment spec of your CSV +are no longer added at the same order. To sort it out you can update replace the target `/spec/template/spec/containers/1/volumeMounts/0` +with `/spec/template/spec/containers/0/volumeMounts/0` in `config/manifest/kustomization.yaml`. + +**NOTE** You MUST use SDK CLI versions > 1.22. Previous versions have a bug +where the command `operator-sdk generate kustomize manifests` is not respecting the changes +made on this manifest. + [cgo-docs]: https://pkg.go.dev/cmd/cgo [open-issue]: https://github.com/operator-framework/operator-sdk/issues/new/choose \ No newline at end of file