-
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
✨ New plugin for config-gen as alpha. #2540
✨ New plugin for config-gen as alpha. #2540
Conversation
Welcome @Kavinjsir! |
Hi @Kavinjsir. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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/test-infra repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Kavinjsir The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/ok-to-test |
4db93a5
to
2e8b509
Compare
@@ -7,7 +7,7 @@ Supports: | |||
- Generating CRDs and RBAC from code | |||
- Generating webhook certificates for development | |||
- Selectively enabling / disabling components such as prometheus and webhooks | |||
- See [types.go](apis/v1alpha1/types.go) for a list of components | |||
- See [types.go](types.go) for a list of components |
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.
Regards its docs I think we need to move in the direction : #2542
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.
Yeah, that sounds good.
I can make the docs once the implementation is good.
See someone is working on the thread, if there is a successful one give out ahead of this pr, I can try attach the docs based on that.
Otherwise we may have a follow up?
Would you think this work?
86765d5
to
8a812c3
Compare
8a812c3
to
db95b77
Compare
} | ||
|
||
// FIXME: How can we customize makefile without overwrite it since it is language based? | ||
f.IfExistsAction = machinery.OverwriteFile |
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.
Need some help here:
This config-gen
plugin will generate a makefile that might overwrite the one from go/v3
. So there are two concerns:
- Most part of the template from both are duplicate. (The main difference is just
make deploy
andmake install
). - It potentially leads contradiction if another plugin is used to generate makefile.
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.
I suppose we may expect this plugin to be a more general one.(So to make it available in sdk)
I will get some references on the plugins from sdk to see how we can adjust this.
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.
The Makefile is part of the language plugin.
See that we have the kustomize and the base.go/v3 which are a composition to generate the = go/v3
IMO:
How it will work? We will need to call base.go. + config-gen such as we do now for go/v3: https://github.com/kubernetes-sigs/kubebuilder/blob/master/cmd/main.go#L35-L39
So, why does config-gen needs to scaffold the Makefile?
The makefile is scaffolded by the Golang one because it has specific targets which are related to the language ( see that the kustomize plugin is used with other languages such as in SDK with Helm/Ansible so that their specific language plugins do not have to go commands on the targets )
More info: See the plugin doc PR : #2569
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.
$kb create api --group crew --version v1 --kind Captain --controller=true --resource=true --make=false | ||
$kb create webhook --group crew --version v1 --kind Captain --defaulting --programmatic-validation | ||
$kb create api --group crew --version v1 --kind Admiral --plural=admirales --controller=true --resource=true --namespaced=false --make=false | ||
$kb create webhook --group crew --version v1 --kind Admiral --plural=admirales --defaulting |
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.
Just to clarify, all the data under testdata/project-v3-config-gen
is output by local make generate
based on the update here. I am not sure if this is the correct way to generate test cases.
They pass the e2e test
on my local laptop, but somehow failed in CI. It seems an issue of go version, so wondering how I can fix that.
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 here we would add a sample that runs:
`kubebuilder init --plugins=config-gen/v1-alpha,base.go.kubebuilder.io/v3 --domain example.org --repo example.org/guestbook-operator
Such as we are doing in the PR where we propose the new kustomize/v2-alpha see: #2583
`
@pwittrock could you give a hand on this one? |
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&Admiral{}, &AdmiralList{}) |
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.
Why config-gen needs to scaffold the files that are done by the go.base.v3 language?
See: https://github.com/kubernetes-sigs/kubebuilder/pull/2582/files
I'd expected, run :
kubebuilder init --plugins=config-gen/v1-alpha,base.go.kubebuilder.io/v3 --domain example.org --repo example.org/guestbook-operator
Then:
- The init command of config-gen would scaffold only the files which are required and specific for this plugin
- After that, in the chain the init subcommand of the base go v3 plugin will be called and scaffold all language files ( apis, controllers, makefile )
In this way we do not hurt concepts such as single responsibility, each plugin does only what is its responsibility.
&templates.Makefile{ | ||
BoilerplatePath: s.boilerplatePath, | ||
ControllerToolsVersion: ControllerToolsVersion, | ||
KustomizeVersion: KustomizeVersion, | ||
ControllerRuntimeVersion: ControllerRuntimeVersion, | ||
}, |
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.
That shows not required for config-gen
const ( | ||
// ControllerRuntimeVersion is the kubernetes-sigs/controller-runtime version to be used in the project | ||
ControllerRuntimeVersion = "v0.11.0" | ||
// ControllerToolsVersion is the kubernetes-sigs/controller-tools version to be used in the project | ||
ControllerToolsVersion = "v0.8.0" | ||
// KustomizeVersion is the kubernetes-sigs/kustomize version to be used in the project | ||
KustomizeVersion = "v4.0.5" | ||
) |
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.
That seems not required ether
} | ||
|
||
//nolint:lll | ||
const makefileTemplate = ` |
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.
What should be diff for config-gen in the Makefile?
Have we anything that is specific for config-gen that we need to change?
Have we anything that we should remove ?
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.
c/c @pwittrock
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.
Hey @camilamacedo86 , thx for the review!
So this is the main part that confuses me of how such alpha config-gen
get migrated to the plugin and worked by the integration with language specific plugins.
Because, once it becomes a plugin, the function of config-gen
can't be actively triggered.
Especially when we'd like to use it as:
kubebuilder init --plugins=config-gen/v1-alpha,base.go.kubebuilder.io/v3 --domain example.org --repo example.org/guestbook-operator
I understand that we don't expect the plugin to "update" makefile, as that is defined as "language specific".
And, it seems that most of the makefile templates(go/v3, go/v2, helm) have in common with the following lines:
.PHONY: install
install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl apply -f -
...
.PHONY: deploy
deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default | kubectl apply -f -
...
So, if I'm understanding correctly, the language specific plugin:
- assumes there is a
config/
folder - then defines
Makefile
- and determine how the CRD and its controller get installed.
In general, the config/
is generated by kustomize plugin
. (Though the language specific plugin does not care who create that folder.)
Consequently, I have this basic question:
Once the alpha plugin get triggered by
kb init
and generates:
- kubebuilderconfiggen.yaml
- controller_manager_config.yaml
How can users use these files to apply their configured controllers to the cluster?
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.
The temporary approach in the this commit is:
Add this Makefile-Scaffolding template to the alpha plugin. Then the ultimate Makefile
will have a difference in its make deploy
:
deploy: ## Deploy controller to the K8s cluster specified in ~/.kube/config.
kubebuilder alpha config-gen ./kubebuilderconfiggen.yaml | kubectl apply -f -
That's how config-gen
get used.
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.
This might not be a good one considering on the usage as:
kubebuilder init --plugins=config-gen/v1-alpha,<language-specific-plugin> ...
That makes the alpha plugin an alternative to the kustomize plugin.
IIUIC, the language plugins expect the config/
folder, regardless of who create that.
So maybe the alpha plugin should generate the config/
.
Then the language specific plugins won't necessary do/care additional things.
What do you think?
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.
Hi @Kavinjsir,
Thank you for working on this one, Following the comments inline.
I understand that we don't expect the plugin to "update" makefile, as that is defined as "language specific".
And, it seems that most of the makefile templates(go/v3, go/v2, helm) have in common with the following lines:
.The Makefile is scaffold by the language plugin.
Why it has specific targets which are by language (e.g controller-gen only work with Go, go fmt, and etc..)
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.
This might not be a good one considering on the usage as:
kubebuilder init --plugins=config-gen/v1-alpha, ...
That makes the alpha plugin an alternative to the kustomize plugin.
It is the goal. The purpose of config-gen would be to replace kustomize
That means users could choose if prefer the config-gen or kustomize approach.
db95b77
to
7dd528d
Compare
@Kavinjsir: PR needs rebase. 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/test-infra repository. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
I spoke with its author and he is ok with us deleting or moving config-gen from the project (looking for maintainability since this option does not seems that won atraction from the users). We will need to discuss the possibilities in the community meetings. However, I understand that with your help we came to the conclusion that we cannot easily move this implementation to a plugin since we need to generate/execute the config-gen to do the actions. In this way, I think we can close this PR and if we need we can re-open it. |
In respect to #issue2501, moving the package of
config-gen
frompkg/cli/alpha
towardspkg/plugins
.