-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix and cleanup Kpt fn integration #5886
Conversation
hi @yhrn , thanks for opening up this pr. Is it ready to be reviewed? Asking since you have it marked as draft :) |
Hi @MarlonGamez , The reason I marked it as draft is because I haven't looked at the tests yet because I first wanted to confirm that you would accept the user facing changes, mainly the change in order of execution for |
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 Mattias, Thank you so much for improving kpt deployer! I didn't realize the workaround is no longer needed (and actually add bugs).
I have several questions want to confirm:
-
kpt and kustomize are decided to not be unified for now 🤷 . Thus the directories of kustomize and kpt are better not be overlapped when used together. Technically they can, this requires users to handle the potential issues themselves and better use kustomize as a kpt fn (and we will support that in the skaffold v2). So it seems the "removing comments" and "the kpt relative file breakage" are less of a concern.
-
kustomize build
is considered as the generator, and kpt fn provides the functions to validate and transform these resources. So the order is 1) generate, 2) validate 3) mutate. From this perspective, ignoring whether doing kustomize first may break kpt features or vice versa, runningkustomize build
first seems to be the right approach. And if anything's broken during the process, we shall fix the breakage. -
Does this PR fix the bug that "using --fn-path will cause function configs to be used only from the specified path whereas the workaround added those to whatever was in kpt.dir"? Maybe I miss something but it seems that this issue still exists. Do you mind updating the PR to filter out the kptFn from
.kpt.dir
if--fnPath
is given? somewhere after the kpt source. -
I feel sorry that the kpt deployer breaks. The kpt v0.X.X are not guaranteed to be backward compatible (but kpt v1.0 will do much better on this). Thus, instead of fixing kpt deployer in skaffold everytime it breaks (I've done similar fixes a couple of times), do you think it may actually make users life easier if we require a specific kpt version? e.g. here we ask users to install kpt 0.34.0 and do not upgrade to newer kpt 0.X.XX versions until the skaffold kpt v1.0 is ready (I'm currently implementing the new kpt hydration/deployment based on kpt v1.0).
flags, err := k.getKptFnRunArgs() | ||
if err != nil { | ||
return nil, err | ||
} |
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 like this change. renderManifests is the right place for this code.
Thanks Mattias, open to further discussions about the
kpt/kustomize behavior
…On Tue, May 25, 2021 at 11:24 AM Mattias Öhrn ***@***.***> wrote:
Hi @marlon-gamez <https://github.com/marlon-gamez>,
The reason I marked it as draft is because I haven't looked at the tests
yet because I first wanted to confirm that you would accept the user facing
changes, mainly the change in order of execution for kpt fn run and kustomize
build. I tried to describe this and my reasoning behind it in the PR
description.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#5886 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABKYVUWJWOTMSTREGAIDIVTTPPTPDANCNFSM45I5XXRQ>
.
--
Yuwen Ma | Software Engineer - Google Cloud | ***@***.***
***@***.***>
|
I don't understand what you mean with "not unified" and that "directories should not be overlapped". Do you mean that one shouldn't really use both? That would contradict the next item a bit where you explain why you think the existing order is the right one. Could you also elaborate on why you think "removing comments" and "the kpt relative file breakage" are less of a concern? Especially the former is a blocker for us. Running kustomize as a kpt fn sounds very interesting though. Can you provide any more information on this? I assume that is not going to be a Skaffold specific feature but rather something that Kustomize will support, or?
Kpt functions that are validators and should run last is a fair point. For me the ability to use functions that require comments and the ability for the functions to modify Kustomizations is more important, but I realize that this will not apply to everybody. If you believe that changing the order is the wrong thing to do then I'll drop this PR.
No, but I don't think this is a bug,
I'm not sure if that would make things better, it's also pretty inconvenient to not be able to upgrade to the latest version for other use cases. |
Unified --> See comment basically once they are unified, kpt can understand and work with kustomize config by default. I just want to make sure the previous comment is not misleading. The new kpt v1.0 is going to update the hydrated config in-place (the config is updated in its original file) while kustomize outputs the config to stdout. From that perspective, the
Here's the issue. Eventually, we agree to have a skaffold specific kustomize kpt fn rather than a generic one (which needs to handle all possible use cases and we don't have many user requests yet).
The expected behavior of skaffold kpt deployer should be: If
yeah, and this is the common problem for most non-GA (v1.0) CLIs. |
Ok, the comment you are referencing wasn't added by me, it was just moved around as part of the refactoring I did. But if I understand you correctly there has been some decision somewhere that the "unification" mentioned there is not going to happen so we should probably just remove the comment? As a side note, I don't fully understand why the Kustomize temp dir workaround was there in the first place? It's needed in this PR because of doing
I'm not sure how a Skaffold specific kpt function would look. In my mind it would mainly be an improvement if it would work as a transformer fn rather than a generator so that I could include it in my kpt v1 fn pipeline definition and thereby control the order, e.g. run generator fn A, then Kustomize fn (retaining comments), then generator fn B and finally some validator fns. But this sounds like it might require significant changes to Kustomize but it would also generally useful, not just for Skaffold. Also reading through the linked issue and the Kpt as well as the Kpt v1 alpha docs it seems to me like Kpt v1 (at least the fn pipeline functionality) will be harder to compose with Kustomize, especially using Kustomize as a generator.
Ok, then yes this PR fixes the bug. There is no need to filter out the functions in To summarize a bit, I don't see much that should change in this PR as a result of the discussion so far - we either agree to change the order and then I'll fix comments and tests or you decide you want to keep the current order, in which case I'll close this PR. |
+1
ah, because we want to use kustomize as a kpt fn at the very beginning, and this
Well, actually v1 is very different. For instance, the WET config will change in place (the original file where the kpt fn works on) rather than to stdout. FYI, the cmd
Have you tried
I recalled kustomize fn was used to be placed in the kpt generator catalog, so as helm-inflator.
You are right. We will try the best we can in skaffold v2. here's a trade-off doc, if you are interested.
Totally understand the questions you asked. I think most of them are due to the changes and decisions we made when designing kpt 1.0 from 0.X, and the changes in kpt/kustomzie unification. In short, go ahead and change the order if that can unblock you from using kpt deployer. Just a reminder that we are working on skaffold v2, which:
|
@yuwenma Thank you! And I'm totally fine with having to rework our setup once Kpt v1/Skaffold v2 lands. I'll go ahead and fix tests, update comments and rebase the PR on the latest release as soon as I get the chance. |
Hi again, I finally found time to make the comment changes and fix the tests so I've marked the PR as ready for review. |
@@ -73,7 +74,7 @@ $(BUILD_DIR)/$(PROJECT): $(STATIK_FILES) $(GO_FILES) $(BUILD_DIR) | |||
.PHONY: install | |||
install: $(BUILD_DIR)/$(PROJECT) | |||
mkdir -p $(GOPATH)/bin | |||
cp $(BUILD_DIR)/$(PROJECT) $(GOPATH)/bin/$(PROJECT) | |||
cp $(BUILD_DIR)/$(PROJECT) $(GOBIN)/$(PROJECT) |
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'm sneaking this in because not being able to control where make install
puts the binary was annoying. Changing GOPATH
isn't really feasible as that means go build
will start pulling down dependencies in that location so honoring GOBIN
seemed like the natural way to go.
Now one can do GOBIN=mypath make install
similar to how one can do GOBIN=mypath go install
and the default behavior remains unchanged. Let me know if this is problematic somehow and I'll remove it.
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.
Codecov Report
@@ Coverage Diff @@
## master #5886 +/- ##
==========================================
- Coverage 70.66% 70.64% -0.03%
==========================================
Files 454 457 +3
Lines 17399 17475 +76
==========================================
+ Hits 12295 12345 +50
- Misses 4196 4220 +24
- Partials 908 910 +2
Continue to review full report at Codecov.
|
pkg/skaffold/deploy/kpt/kpt.go
Outdated
@@ -53,7 +52,7 @@ const ( | |||
kptFnLocalConfig = "config.kubernetes.io/local-config" | |||
|
|||
kptDownloadLink = "https://googlecontainertools.github.io/kpt/installation/" | |||
kptMinVersion = "0.34.0" | |||
kptMinVersion = "0.38.1" |
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.
Do you mind also adding a check to make sure the kptMaxVersion is less than 1.0.0 which does not have kpt fn run
?
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.
Head branch was pushed to by a user without write access
Description
This PR attempts to fix and clean up Kpt hydration.
kpt.fn.fnPath
and the inputSkaffold gave to my function was just the first resource in
kpt.dir
and the function config.kpt fn run --fn-path
which will cause function configs to be used only from thespecified path whereas the workaround added those to whatever was in
kpt.dir
kpt fn run
andkustomize build
are executed has been reversed. I have outlined my reasoningin code comments.
to
kpt.live.apply.dir
is now using the same mechanism as when writing tokpt.fn.sinkDir
and the kustomize temp dir(
kpt fn sink
instead ofmanifest.Write
) so this directory will contain one file per resource instead of a single file.User facing changes (remove if N/A)
The order in which
kpt fn run
andkustomize build
are executed has changed from Kustomize first to Kpt first. I don't believe there is any user facing documentation for this.Follow-up Work (remove if N/A)
I have not updated any tests yet because I want to first see if these changes have a chance of being accepted, which is also why I'm publishing it as a draft.
Also after cleaning stuff up I wonder if there is any point to
kpt.fn.sinkDir
or if should be deprecated? If you doskaffold render
you get the same stuff on on stdout and if you doskaffold deploy
you get the same plus the inventory template inkpt.live.apply.dir