-
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
✨ add kustomize/v2-alpha plugin to support kustomize versions >= v4 (pinned version 4.5.3) #2583
✨ add kustomize/v2-alpha plugin to support kustomize versions >= v4 (pinned version 4.5.3) #2583
Conversation
b5c6838
to
7f6782c
Compare
7f6782c
to
2d8cc3d
Compare
@@ -0,0 +1,111 @@ | |||
# Kustomize v2-alpha Plugin | |||
|
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.
See here the documentation to better understand it.
Note that after we have this plugin, tools such as SDK (which provides many language plugins) will also be able to allow its users to try out kustomize v4 and support the new mac arch, doing things like:
operator-sdk init --plugins=kustomize/v2-alpha,base.operatorframework.helm.sdk/v1
Then, we can provide all support and advantages to the users without introducing breaking changes.
So that, when the plugins become mature and we no longer need to support k8s versions < 1.22 then we might want to have new languages plugins that adopt them by default.
c/c @jmrodri
@@ -23,6 +23,9 @@ import ( | |||
"sigs.k8s.io/kubebuilder/v3/pkg/plugins" | |||
) | |||
|
|||
// KustomizeVersion is the kubernetes-sigs/kustomize version to be used in the project | |||
const KustomizeVersion = "v3.8.7" | |||
|
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 kustomize version supported by the Kustomize plugin must leave in the Kustomize plugin. Otherwise, we are hurting concepts like single responsibility and cohesion.
break | ||
} | ||
} | ||
|
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.
Here is where we check if the kustomize/v2-alpha plugin was used in the chain to properly define what version of the kustomize should be added to the Makefile which is generated by the plugin language.
The language plugin is not responsible for the kustomize and it needs to ensure that will pin in the Makefile target to install the bin locally the version which was used by the kustomize plugin used with.
@@ -229,3 +229,164 @@ Count int `+"`"+`json:"count,omitempty"`+"`"+` | |||
_ = pluginutil.RunCmd("Update dependencies", "go", "mod", "tidy") | |||
} | |||
} | |||
|
|||
// GenerateV3 implements a go/v3(-alpha) plugin project defined by a TestContext. | |||
func GenerateV3WithKustomizeV2(kbc *utils.TestContext, crdAndWebhookVersion string) { |
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.
Here we have the test to check the new plugin scaffold working on the cluster with go/v3 one.
@@ -131,3 +131,4 @@ scaffold_test_project project-v3-multigroup | |||
scaffold_test_project project-v3-addon --plugins="go/v3,declarative" | |||
scaffold_test_project project-v3-config --component-config | |||
scaffold_test_project project-v3-v1beta1 | |||
scaffold_test_project project-v3-with-kustomize-v2 --plugins="kustomize/v2-alpha,base.go.kubebuilder.io/v3" |
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 is the line where we scaffold the sample under the testdata
60bd345
to
3e9b3e8
Compare
pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/kustomization.go
Show resolved
Hide resolved
pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/kustomization.go
Show resolved
Hide resolved
pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/kustomization.go
Show resolved
Hide resolved
pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/kustomization.go
Show resolved
Hide resolved
pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/kustomization.go
Show resolved
Hide resolved
pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/kustomization.go
Show resolved
Hide resolved
pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/kustomization.go
Show resolved
Hide resolved
pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/kustomization.go
Show resolved
Hide resolved
3e9b3e8
to
b727b1c
Compare
cc @AlmogBaku |
@camilamacedo86 @afritzler @rashmigottipati what is the projected timeframe for release of this PR after merge? we have been waiting for this update to support ppc64le as well to update kustomize to v4 in an external app |
27bdb67
to
fd52b7f
Compare
fd52b7f
to
61fb7c2
Compare
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.
Everything looks good to me. Just one minor docs typo.
61fb7c2
to
77ccefb
Compare
f2dc98c
to
792ba13
Compare
…pinned version 4.5.3)
792ba13
to
c062d27
Compare
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.
Changes look good to me.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: camilamacedo86, everettraven, rashmigottipati 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 |
Description
✨ add kustomize/v2-alpha plugin to support kustomize versions >= v4
Motivation
kubebuilder init --plugins=kustomize/v2-alpha,base.go.kubebuilder.io/v3
)Notes
Why can we not upgrade the kustomize stable v1 plugin to use the kustomize v4 version instead of creating a new alpha plugin?
We cannot introduce breaking changes for those who have a project scaffolded previously using kustomize/v1. See that kustomize must bump a major version v4 because it introduces breaking change and does NOT ensure backwards compatibility with the previous versions.
So let's think about the scenario and imagine that:
The user should NOT change their previous scaffolds to be able to still work with KB 3.Z and the plugin already used to scaffold their project kustomize/v1. See the policy: https://github.com/kubernetes-sigs/kubebuilder/blob/master/docs/book/src/plugins/plugins-versioning.md:
However, now when they call the command to create api to add its manifests on the project using the go/v3 and kustomize/v1 this subcommand will begin to scaffold the files using the new syntax (valid for kustomize dep v4 and not v3 necessarily) since the project are not implemented to work with kustomize v4 which indeed the user will not have installed locally since its Makefile target should still be downloading kustomize v3 its result will be:
That files scaffold with v4 today might work with v3 (not officially supported or guaranteed and etc). However, it can change a lot on the long journey since we can indeed add new features, also we do not know how other projects importing kustomize are using or taking advantage of it. Today it might work but can we ensure that will be the case tomorrow?`
Therefore, that shows for me a breaking change since can break the behaviour of any plugin language which has been using kustomize stable plugin v1 with kustomize v3 syntax as its binary.
See the policy example:
That shows our case here, we will need to let the users know what they need to do in their scaffolded project using kustomize/v1 with the syntax that works with the kustomize binary version v3 to then be able to work with v4 when this new kustomize/v2-alpha plugin becomes to be kustomize/v2 stable)
Do we not bump go versions? Why it is different?
So we bump the go versions, which means any new project scaffold using a new version of the plugin bumped with go 1.18 will have the go mod using go 1.18 with its deps. However, users that scaffold using go 1.15, for example, will NOT be affected by that, they do not need to change anything to be able to work with KB 3.Z and its new version of the go/v3 plugin, for example, they still able to run
create api
andcreate webhook
for the project scaffolded with any previous 3.Z version and using any previous go version supported.Closes: #2566
Closes: #2503
Motivations
Co -author: @afritzler