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

Use of kustomize appears to prevent the use of operator-sdk #500

Closed
dhellmann opened this issue May 1, 2020 · 6 comments · Fixed by #503
Closed

Use of kustomize appears to prevent the use of operator-sdk #500

dhellmann opened this issue May 1, 2020 · 6 comments · Fixed by #503
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@dhellmann
Copy link
Member

dhellmann commented May 1, 2020

The changes started in 4c170b0 to add kustomize support seem to have broken the operator-sdk code generator, so adding a new API version to fix #434 is going to be harder.

$ operator-sdk add api --api-version metal3.io/v1beta1 --kind BareMetalHost
INFO[0000] Generating api version metal3.io/v1beta1 for kind BareMetalHost.
INFO[0000] Created pkg/apis/metal3/group.go
INFO[0000] Created pkg/apis/metal3/v1beta1/baremetalhost_types.go
INFO[0000] Created pkg/apis/addtoscheme_metal3_v1beta1.go
INFO[0000] Created pkg/apis/metal3/v1beta1/register.go
INFO[0000] Created pkg/apis/metal3/v1beta1/doc.go
INFO[0000] Created deploy/crds/metal3.io_v1beta1_baremetalhost_cr.yaml
FATA[0000] Failed to update the RBAC manifest for the resource (metal3.io/v1beta1, BareMetalHost): (failed to read role manifest /home/dhellmann/go/src/github.com/metal3-io/baremetal-operator/deploy/role.yaml: open /home/dhellmann/go/src/github.com/metal3-io/baremetal-operator/deploy/role.yaml: no such file or directory)

The role file has been moved

$ find deploy/ -name role.yaml
deploy/rbac/role.yaml
@dhellmann
Copy link
Member Author

/cc @Xenwar

dhellmann added a commit to dhellmann/baremetal-operator that referenced this issue May 1, 2020
The layout kustomize wants and the layout operator-sdk wants are
incompatible. It is possible to specify a different location for the
files for kustomize, so move those to their own directory and restore
the old versions of the deploy files from the operator-sdk.

Fixes metal3-io#500

Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
@dhellmann dhellmann self-assigned this May 1, 2020
@dhellmann dhellmann added the kind/bug Categorizes issue or PR as related to a bug. label May 1, 2020
@kashifest
Copy link
Member

@dhellmann is it not possible to instruct operator-sdk to use deploy/role.yaml instead?

@dhellmann
Copy link
Member Author

@dhellmann is it not possible to instruct operator-sdk to use deploy/role.yaml instead?

The problem is it wants deploy/role.yaml but the file is now deploy/rbac/role.yaml. We could, possibly, tell the SDK to change all of the files it produces, but I don't think that's what we want to do.

The SDK output is how we manage the generated code. The kustomize files are one particular way to deploy that code.

Ideally the kustomize stuff would be in its own repository, since there are going to be other opinionated ways to deploy (OpenShift has a different way, for example). But it's fine with me to keep everything here in this repository for convenience, as long as we don't have the tools fighting with each other over who owns which files.

@kashifest
Copy link
Member

kashifest commented May 1, 2020

deploy/rbac/role.yaml

Sorry my mistake, I meant is it not possible to instruct operator-sdk to use deploy/rbac/role.yaml

@dhellmann
Copy link
Member Author

deploy/rbac/role.yaml

Sorry my mistake, I meant is it not possible to instruct operator-sdk to use deploy/rbac/role.yaml

The point is that the contents of the deploy directory are owned by the operator-sdk. It generates those files and does not expect anything else to be moving them around or heavily modifying them.

Is there a technical reason for us to have the kustomize versions of the files also under the deploy directory?

@kashifest
Copy link
Member

Nope. It was a curious query. I was thinking would it be a good idea to keep multiple copies of same files in different locations and then it would also require back-porting the changes from one to the other (whenever there is any). Instead I am thinking if we can keep those files which operator-sdk needs in deploy/ folder instead of their own subdirectories and still use the same for kustomize. Kustomize is not modifying deploy/rbac/role.yaml by the way.

dhellmann added a commit to dhellmann/baremetal-operator that referenced this issue May 1, 2020
The layout kustomize wants and the layout operator-sdk wants are
incompatible. It is possible to specify a different location for the
files for kustomize, so move those to their own directory and restore
the old versions of the deploy files from the operator-sdk.

Fixes metal3-io#500

Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
dhellmann added a commit to dhellmann/baremetal-operator that referenced this issue May 1, 2020
Create a symlink from deploy/role.yaml to deploy/rbac/role.yaml so
that the operator-sdk will find the role file it needs for the `add
api` command.

We cannot make the link in the opposite direction because kustomize
refuses to follow symlinks outside of the directory where its
configuration is.

Fixes metal3-io#500
Related to metal3-io#434

Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
2 participants