Skip to content
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

Configurable extension #459

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open

Conversation

gkurz
Copy link
Member

@gkurz gkurz commented Sep 11, 2024

This simplifies custom builds for OCP with respect to the CoreOS extension name.

This will be used to customize some YAML files in the generated bundle.

Signed-off-by: Greg Kurz <[email protected]>
People who want to build a custom operator for OCP usually modify
the extension name in `config/manager/manager.yaml`. This dirties
the repo which is a bit painful.

Add some `yq` magic to patch the generated CSV in the bundle
instead. People working with OCP can now do :

    $ export SANDBOXED_CONTAINERS_EXTENSION=sandboxed-containers
    $ make bundle

Signed-off-by: Greg Kurz <[email protected]>
operator-sdk generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle $(BUNDLE_GEN_FLAGS)
$(YQ) eval '(.spec.install.spec.deployments[].spec.template.spec.containers[].env.[] | select(.name == "SANDBOXED_CONTAINERS_EXTENSION") | .value) |= "$(SANDBOXED_CONTAINERS_EXTENSION)"' \
-i bundle/manifests/sandboxed-containers-operator.clusterserviceversion.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd actually prefer doing the replacement in config/manager/manager.yaml before kustomizing instead of in the generated file after kustomizing since the difference between the template and the resulting generated file will end up konfusing someone I'm afraid. But this works too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the replacement is done in config/manager/manager.yaml then it will be dirty... which basically negates the benefit of this commit or I am missing something ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There would still be benefit in setting this in Makefile and not having to know or find out where exactly you as a (new) developer need to make this change. As I said, I'm fine with this way, too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the confusion side : people still need to explicitly set SANDBOXED_CONTAINERS_EXTENSION to something != from the default value (kata-containers) to change the default behavior. They shouldn't be that much surprised.

Copy link
Contributor

@pmores pmores left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm thanks @gkurz !

Copy link
Contributor

@littlejawa littlejawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm
Thanks @gkurz !

@bpradipt
Copy link
Contributor

While technically this patch is fine, my worry is the more we deviate from a standard operator-sdk based Makefile, the harder it will be during sdk upgrades. This is from my personal experience when upgrading sdk.

An alternate is to set the extension name dynamically based on the environment by patching the CSV during start of the controller manager.
This is just a suggestion and in no way blocking this PR

Copy link

openshift-ci bot commented Sep 11, 2024

@gkurz: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/sandboxed-containers-operator-e2e cee1592 link false /test sandboxed-containers-operator-e2e
ci/prow/check cee1592 link false /test check

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants