plugin: write Makefile recipes for generate bundle subcommand#2860
plugin: write Makefile recipes for generate bundle subcommand#2860estroz merged 1 commit intooperator-framework:masterfrom
generate bundle subcommand#2860Conversation
bf718cb to
e73639e
Compare
e73639e to
7d0f684
Compare
|
Overall looks like a great start! A few comments:
|
|
@joelanford Perhaps it would be better to fold As for CSV file suffix: do you mean that is a requirement in the SDK ( |
I think the make target in this PR is pretty close to what I imagined. I'm just wondering if the entrypoint can be
So the make target could be: bundle: manifests
kustomize build config/default | operator-sdk generate bundle manifests
kustomize build config/bundle | operator-sdk generate bundle directory
I swear I read something about OLM or the operator-registry knowing what a bundle directory is by searching for a file with a |
|
I think we're on the right track. I'd still like to initially separate the timing of metadata generation from actually creating the bundle, even if Normal kubebuilder workflowThe following few commands are no different than the normal kubebuilder workflow; their behavior differs slightly: Interactive prompt for UI metadata on $ operator-sdk init
Interactive CSV metadata prompt. Please fill in the following UI fields:
DisplayName: Memcached Operator
...
Icon file path: path/to/icon.pngCreate APIs: $ operator-sdk create api --group cache --version v1 --kind MemcachedCreate or update all CRD bases after Go types are created or modified, and update the CSV base: $ make manifests
controller-gen "crd:trivialVersions=true" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
operator-sdk generate bundle --update-bases --interactive=falseAdditional bundle workflowHere's where we add to the normal kubebuilder workflow, after we've added APIs. We can run the following SDK-specific Generate a bundle on disk: $ make manifests-olm
## Calls the 'manifests' recipe
controller-gen "crd:trivialVersions=true" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
operator-sdk generate bundle --update-bases
## Generate the bundle and metadata.
kustomize build config/olm-catalog | operator-sdk generate bundle --output-dir config/olm-catalogCreate a bundle image: $ make bundle-build IMG=quay.io/example/memcached-operator:v0.0.1
## Calls the 'manifests' recipe
controller-gen "crd:trivialVersions=true" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
operator-sdk generate bundle --update-bases
## Creates a bundle in-memory then builds an image.
kustomize build config/olm-catalog | operator-sdk generate bundle --stdout | operator-sdk bundle create $(IMG)Run directly with OLM: $ make run-olm
## Calls the 'manifests' recipe
controller-gen "crd:trivialVersions=true" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
operator-sdk generate bundle --update-bases --interactive=false
## Creates a bundle in-memory then installs it with OLM.
kustomize build config/olm-catalog | operator-sdk generate bundle --stdout | operator-sdk run --olm
One drawback is a potentially confusing CLI if you run |
|
Thoughts on the above two CLI proposals? |
7d0f684 to
e9fbc11
Compare
dd7b458 to
6211e8d
Compare
|
@hasbro17 can you take another look at this? Changes:
|
@estroz Don't you mean |
hasbro17
left a comment
There was a problem hiding this comment.
LGTM to scaffolding config/bundle/kustomize on init since it's not API specific.
|
The current behaviour to follow the Quick Start should not be affected I am as a user would like to create the project and not a bundle. However, the basic steps are asking the bundle/CSV info when I run
The See: See here all stepsThe make bundle is not working it is fixed now 👍 |
| const ( | ||
| //nolint:lll | ||
| examples = ` | ||
| # Using the example 'memcached-operator' and assuming a directory structure |
There was a problem hiding this comment.
Is required to add the tree? What value does it bring?
There was a problem hiding this comment.
It isn't strictly necessary, although other commands show trees.
| operator-sdk generate bundle -q --kustomize | ||
|
|
||
| Display name for the operator (required): | ||
| > memcached-operator |
There was a problem hiding this comment.
Is required to add its output?
There was a problem hiding this comment.
Nope, just helps the user know what expected output should be. I can see this drifting from actual output though.
| $ operator-sdk bundle validate config/bundle | ||
| $ docker build -f bundle.Dockerfile -t quay.io/$USERNAME/memcached-operator-bundle:v0.0.1 . | ||
| Sending build context to Docker daemon 42.33MB | ||
| Step 1/9 : FROM scratch |
There was a problem hiding this comment.
Is required to add the output?
| } | ||
|
|
||
| // kustomization for bundles. | ||
| const bundleKustomization = `resources: |
There was a problem hiding this comment.
Could we add a note for we try to improve its structure and have something that will follow up the KB layout?
E.g pkg/scaffold/internal/templates/bundle/makefile.go where would have the new bundle targets.
There was a problem hiding this comment.
These should live here now, then can be moved if we change anything else about the Makefile.
|
@camilamacedo86 lets have UX discussions in operator-framework/enhancements#16. |
|
@estroz Actually I just tested what @camilamacedo86 pointed out and I'm not sure if this was always the case but after scaffolding a basic project without intending to write CSVs or bundles I'm still forced to input the metadata for the CSV bases on $ operator-sdk init --repo=github.com/hasbro17/memcached-operator --domain=example.com
...
$ operator-sdk create api --group cache --version v1alpha1 --kind Memcached
...
$ make manifests
/Users/haseeb/work/go-space/bin//controller-gen "crd:trivialVersions=true" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
operator-sdk generate bundle -q --kustomize
Display name for the operator (required):
...This kind of forces CSVs and bundles into the workflow by default rather than making it opt-in like we had with |
|
@estroz Nvm just saw the comment for UX discussions. Ignore my previous comment. |
There was a problem hiding this comment.
Just to clarifies:
- I think we cold just centralized the code. https://github.com/operator-framework/operator-sdk/pull/2860/files#r431067951.
- I do not think that we should change the makefile targets which are done/used by Kubebuilder and in this way, break the compatibility with and force the user to provide the CSV info when is just looking for creating a new project (following the quick-start). https://github.com/operator-framework/enhancements/pull/16/files#r431432999 which I understand that @estroz also agreed to change as well
IMO it is the broker to move forward with this PR. Any other required change/improvements could indeed be done in a follow-up.
3e596f9 to
004be66
Compare
project layout to use to generate bundles cmd/operator-sdk/generate: generate a kustomization.yaml in config/bundle so a user can 'kustomize build config/bundle' to generate generator input internal/plugins: the Init plugin will append 'bundle' and 'bundle-build' recipes to the Makefile to generate a bundle on-disk and build a bundle image, respectively, using 'generate bundle'; it will also modify the 'manifests' recipe so it runs 'generate bundle --kustomize'; the CreateAPI plugin will scaffold a kustomization.yaml in config/samples so they are included in bundle generator input
camilamacedo86
left a comment
There was a problem hiding this comment.
I executed the quick start steps and the steps described https://github.com/operator-framework/enhancements/pull/16/files and I could not face issues with. So, it shows OK for me.
/lgtm
/approve
Description of the change:
Changes:
operator-sdk initwritesconfig/bundle/kustomization.yamland addsbundleandbundle-buildrecipes that generate a bundle on disk and build a bundle image, respectively.operator-sdk create apimanagesconfig/samples/kustomization.yamlsokustomize build config/bundleretrieves custom resource samples.Motivation for the change:
Example workflow:
Then invoke:
TODO:
[x] better testdata for current and new project layouts.[x] rewrite tests (currently broken) in BDD style using gomega/ginkgo.generatecommands #3018, generate csv: move manifest collector to its own package #3064, generate: addbundlesubcommand for new project layouts #3065Reference PR: #2956
/kind feature