-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
🏃 Design for Simplified Scaffolding #620
🏃 Design for Simplified Scaffolding #620
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: DirectXMan12 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
see also #603. Holding off on a full-on prototype for a bit, but this looks quite a bit similar to how I structure the controllers when I'm developing or prototyping with CR. |
e382092
to
35897e9
Compare
designs/simplified-scaffolding.md
Outdated
#### Use a single types.go file | ||
|
||
This works fine when you have a single "major" Kind, but quickly grows | ||
unweildy when you have multiple major kinds and end up with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unweildy
Typo?
│ ├── mykind_controller_test.go | ||
│ └── controllers_suite_test.go | ||
├── api | ||
│ └── v1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds like this is the proposed structure if we have more than one versions.
├── api
│ ├── v1
│ │ └── foo_types.go
│ │ └── groupversion_info.go
│ └── v2
│ └── foo_types.go
│ └── groupversion_info.go
It sounds like the info about group will be duplicated across versions.
Given we assume only one group in this structure, does it make sense to have structure like
├── api
│ ├── group_info.go
│ ├── v1
│ │ └── foo_types.go
│ │ └── version_info.go
│ └── v2
│ └── foo_types.go
│ └── version_info.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... the group info is the same, but the version is not, and you're adding different types to each. The amount shared between groups is relatively minimal (just group name), so I'm not sure it makes sense to have the extra file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, repeating the group-info in this case is reasonable. Adding extra files just for that will lead to the similar problems that we have today.
3. Tell users to move things, and scaffold out with the new structure. | ||
This is fairly messy for the user. | ||
|
||
Since growing to multiple API groups seems to be fairly uncommon, it's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fairly uncommon
IIUC you mentioned that you have some data to back this when we chat offline. If you put the number here it's more convincing to make the decision :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swear I had this somewhere, but can't seem to find the data now. I'll see what I can put together
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... reproducing what I had before is proving difficult (the query I was using before is now returning wildly truncated results), but with a random sampling of smaller projects on github using kubebuilder (presence of manager.yaml) and larger projects that I know of that make use of controller runtime or just CRDs in general (e.g. kubeflow, knative, cluster-api, cert-manager, app-crd, prometheus operator, etcd operator) most seem to follow the pattern of 1 API group per repo. The main exception was a couple of the knative repositories (but not all of them) and openshift, which puts all of its types in a single repo anyway, so isn't relevant to us.
This makes some amount of sense -- most operators or controllers logically operate on a single set of resources (the CRD defining the operator, a collection of related resources that work together) which would generally be grouped into a single API group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm...another crazy idea :)
What if we removed the api
and introduced the group hierarchy.
./test/project
- groupa/v1/....
- groupb/v2/...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proposal looks reasonable to me. Have a few comments.
designs/simplified-scaffolding.md
Outdated
([GoDoc](https://godoc.org/sigs.k8s.io/controller-runtime/pkg/builder#ControllerManagedBy)) | ||
as a way to simplify construction of controllers and reduce boilerplate | ||
for the common cases of controller construction. Informal feedback from | ||
this has been positive, and it enables fairly rapid, clear, and consice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/consice/concise
designs/simplified-scaffolding.md
Outdated
|
||
This proliferation of files makes it difficult for users to understand how | ||
their code relates to the library, posing some barier for initial adoption | ||
and moving beyond a basic knowelege of functionality to actual |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: knowledge
│ ├── mykind_controller_test.go | ||
│ └── controllers_suite_test.go | ||
├── api | ||
│ └── v1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, repeating the group-info in this case is reasonable. Adding extra files just for that will lead to the similar problems that we have today.
(`main.go` is the defacto standard entrypoint for many go programs), and | ||
simplifies the levels of hierarchy. Furthermore, since `main.go` actually | ||
instantiates an instance of the reconciler, users are able to add custom | ||
logic having to do with flags. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
designs/simplified-scaffolding.md
Outdated
the current structure. | ||
|
||
Option 1 should be fairly simple, since the logic is already needed for | ||
registering types to the scheme. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case where user has removed that particular code comment (or we are unable to wire second controller for some reason), we can always fallback to option 2 where we just emit the snippet which user can copy-paste in their main.go.
3. Tell users to move things, and scaffold out with the new structure. | ||
This is fairly messy for the user. | ||
|
||
Since growing to multiple API groups seems to be fairly uncommon, it's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm...another crazy idea :)
What if we removed the api
and introduced the group hierarchy.
./test/project
- groupa/v1/....
- groupb/v2/...
hmm... in this case, would controllers go under this hierarchy as well? I'm not certain this would be clear, depending on the group name -- e.g. with a group name of |
This introduces a design for a simplified scaffolding that addresses both persistent pedagogical issues and dependency injection issues with our current scaffolding.
35897e9
to
9d5d401
Compare
Yeah, removing |
This introduces a design for a simplified scaffolding that addresses
both persistent pedagogical issues and dependency injection issues with
our current scaffolding.