-
Notifications
You must be signed in to change notification settings - Fork 231
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
output from kpt fn render -o unwrap cannot be piped with kubectl apply -f - #3844
output from kpt fn render -o unwrap cannot be piped with kubectl apply -f - #3844
Comments
Thanks for trying out kpt and for filing the issue. This is great feedback to get! I think there are several problems here:
@droot @yuwenma Is (2) intentional? I agree that it is correct and should be retaining these local-config resources, but it seems odd that we are documenting using kpt fn render -o unwrap | kubectl apply -f -, when it clearly cannot work in any case because it will try to apply the Kptfile to the cluster. I'm thinking we should instead update the documentation to @ericzzzzzzz For your use case, you can run add the |
Hi @natasha41575 Thank you for the reply.
Regarding my use case, I only use a subset of functionalities from kpt, I believe it is reasonable to make kpt fn render and kpt live apply ... decoupled, so users can use the result from |
Yes, this is fair. I agree that Another option for you is to create a |
@natasha41575 Thank you for the suggestion, but as I mentioned in the description, Example: apiVersion: kpt.dev/v1
kind: Kptfile
metadata:
name: apply-setters-simple
upstream:
type: git
git:
repo: https://github.com/GoogleContainerTools/kpt-functions-catalog
directory: /examples/apply-setters-simple
ref: apply-setters/v0.2.0
updateStrategy: resource-merge
upstreamLock:
type: git
git:
repo: https://github.com/GoogleContainerTools/kpt-functions-catalog
directory: /examples/apply-setters-simple
ref: apply-setters/v0.2.0
commit: 9b6ce80e355a53727d21b2b336f8da55e760e20ca
pipeline:
mutators:
- image: gcr.io/kpt-fn/set-labels:v0.2.0
configPath: fn-config.yaml error message: resource mapping not found for name: "my-config" namespace: "" from "STDIN": no matches for kind "SetLabels" in version "fn.kpt.dev/v1alpha1"
ensure CRDs are installed first
Error from server (Invalid): error when applying patch:
{"metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"metadata\":{\"annotations\":{},\"labels\":{\"app\":\"new\",\"color\":\"orange\",\"fruit\":\"apple\"},\"name\":\"my-nginx\",\"namespace\":\"default\"},\"spec\":{\"replicas\":3,\"selector\":{\"matchLabels\":{\"app\":\"new\",\"color\":\"orange\",\"fruit\":\"apple\"}},\"template\":{\"metadata\":{\"labels\":{\"app\":\"new\",\"color\":\"orange\",\"fruit\":\"apple\"}},\"spec\":{\"containers\":[{\"image\":\"nginx:1.16.2\",\"name\":\"nginx\",\"ports\":[{\"containerPort\":80,\"protocol\":\"TCP\"}]}]}}}}\n"},"labels":{"app":"new","color":"orange","fruit":"apple"}},"spec":{"selector":{"matchLabels":{"app":"new","color":"orange","fruit":"apple"}},"template":{"metadata":{"labels":{"app":"new","color":"orange","fruit":"apple"}}}}}
to:
Resource: "apps/v1, Resource=deployments", GroupVersionKind: "apps/v1, Kind=Deployment"
Name: "my-nginx", Namespace: "default"
for: "STDIN": error when patching "STDIN": Deployment.apps "my-nginx" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"new", "color":"orange", "fruit":"apple"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable if I include Package "a":
Kptfile is invalid:
Field: `pipeline.mutators[0].configPath`
Value: "fn-config.yaml"
Reason: functionConfig must exist in the current package Could you make the output go back to the previous state where output doesn't include the content from Kptfile and dataConfigFile or introduce a flag to control this ? |
Short answer@ericzzzzzzz All of your findings and conclusion are correct! Not only Kptfile, the other kpt metadata (the Long answerThis is related to kpt v1.0.0-beta.15, which treats The rationale for this change is related to Variant Constructor, @ericzzzzzzz you can find out more here. The variant constructor won't directly benefit skaffold but it gives some really nice patterns that the skaffold may eventually want to rely on. I think @droot has raised concerns about the potential regressions, and we tried hard to document the behavior well to warn users. Maybe some doc are missed out. Great findings about those missing docs @natasha41575 . Please go ahead and update them. |
@yuwenma Thank you for providing the context and detail explanation! I think I can use |
Catching up now on the issue. All the points are already covered here so nothing new to add, but wanted to thank everyone for detailed comments/analysis. I agree with @yuwenma suggestion of using |
Thanks @droot and @yuwenma! I wasn't aware of |
Expected behavior
kpt fn render -o unwrap | kubectl apply -f -
, according to https://kpt.dev/reference/cli/fn/render/?id=examples I'd expect the command succeeds.Actual behavior
error: resource mapping not found for name: "apply-setters-simple" namespace: "" from "STDIN": no matches for kind "Kptfile" in version "kpt.dev/v1" ensure CRDs are installed first
Information
kpt version: 1.0.0-beta.19
example : Kpt Package that can demonstrate the error. (https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/apply-setters-simple@apply-setters/v0.2.0)
The cause of this is not working is that
kpt fn render -o unwrap
now outputKptfile
andconfigMap files
defined ini Kptfile, those are not recognized by k8s cluster. Although, we can create.krmignore
to exclude Kptfile in output, but this trick cannot be used to configMap files defined in Kptfile, as that would cause dataMap being ignored by krm functions as well.Before certain version, those stuff are not included in the output from
kpt fn render -o unwrap
, reverting the behavior will probably introduce another breaking change, but could you add a flag to control the output not including Kptfile and congiMap files?Steps to reproduce the behavior
kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/apply-setters-simple@apply-setters/v0.2.0
with the latest kptapply-setters-simple
folder, runkpt fn render -o unwrap | kubectl apply -f -
The text was updated successfully, but these errors were encountered: