-
Notifications
You must be signed in to change notification settings - Fork 23
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 support for processing Kubernetes list from "kubectl" #28
Comments
Hey @kohtala appreciate the report! This is an interesting one. Mainly because the output is not a "multi YAML" but instead a Kubernetes resource of type If you have any preference on that, happy to hear it! It's not a hard or difficult feature to implement at all! |
Thanks. The List is not any kind of resource. I searched for documentation and found some in the API Concepts
So I think it should be safe to perform this processing by default. I believe there also is never a name property. It is best if the A flag to disable the feature might become necessary, if someone finds they need to split lists out of a multi YAML. But I believe this to be rare. But I've been wrong before. |
Yes, sorry, I used the "Kubernetes object" very loosely. It is a definition/spec in the My main concern is also outlined in what you shared, especifically:
What this means is that the implementation might change. It could help us with the direction though, perhaps the way to go is having something like:
Where the My concern to not auto-add this feature is because we are parsing multi-yamls, so something like this: file1: true
---
file2: true
---
file3: false And the Open to hear your thoughts around it! You mention at the end to have the feature opt-out (as in, process List like if it was any other multi-yaml) while I suggest it as opt-in with |
I understood the reference
to refer to object validation and such automation. For example helm should not be used to generate kind Lists because Looking at the issues from where the documentation came (kubernetes/website#25944), I believe kubectl just happened to use List instead of a multi YAML for Since this program is already called kubectl-slice and it works invoked with |
Hey @kohtala, The only reason this program starts with (Side note, the original app was even called You mention "it would seem natural it supports the kubectl List without additional options" but if we look at the original intention of the software, which is to parse multi-YAML files (files separated by Adding this would mean the current people using this software would now magically receive the ability to process ---
first: true
---
apiVersion: v1
kind: List
metadata:
resourceVersion: ""
selfLink: ""
items:
- apiVersion: v1
kind: Service
metadata:
name: kubernetes
namespace: default
- apiVersion: v1
kind: Service
metadata:
name: kube-dns
namespace: kube-system ... Do we process the second file as a list and we get in return, say, 3 files instead of 2 just because there's a list inside? This is why I think we might need more feedback on this. As before, if you had a concrete use case scenario, please let me know, it would definitely help shape the direction of |
After watching the video from the SIG APIMachinery linked from kubernetes/website#25944 it's even more evident this seems a client-side only, specific to
Where the Still, would love to know what everyone else thinks. |
been keeping an eye on this discussion, and I think this should be a feature flag rather than built-in behavior... I wouldn't want the CLI to magically change how it parses resources either that or release a new major version and announce it as kind of a breaking change but not really? your last comment @patrickdappollonio makes sense, |
I agree that this should be a feature flag rather than the default behaviour. For me, keeping the CLI behaviour works with multi-yaml is more intuitive and familiar. |
I am a stranger to this project and definitely do not feel like I would need to tell you what to do. There must be lots of uses I do not know about. As someone that just found this utility, the naming got me thinking it had more to do with kubectl than you seem to think it has. I do not know if other users would find the option as much strange. I tried to see if kubectl passes some information to the plugin it is being invoked through it. I did not find it, but if the plugin has some way of knowing whether it was invoked through kubectl, I think that could be used to change the behavior to match kubectl apply etc. If there is a change to behaviour, a major version is a good point. |
I think based on the previous responses, it's better to leave it off as a feature flag.
I think this wouldn't work. If your easiest way to install the app is through Krew, then you really don't need
I would still be afraid of implementing it without a flag. It seems to me the flag is a better option overall and matches the other people's thoughts.
I appreciate the thought! Really do 😄 the reason why we're asking you for your feedback is not to tell me what to do, but instead, explain your requirement and your use case. Yes, at the end of the day it might be my decision, but I would rather leave it to the collective what would work best for everyone. You happen to run into a behaviour which is part of the process and even a misunderstanding for Kubernetes too, I wouldn't blame you for consider it standard behaviour. I would love to go forward, I've needed this feature myself as well, and as such, I would love to implement it, but based on everyone else's feedback, I would put it under a feature flag. |
My use case was really in the original post. I just get bunch of objects from a Kubernetes cluster, but need to have them in separate files. This time I was running A feature flag is fine. If there is a change of mind later, an opposite flag can be added when the major version is changed. What I ment with the telling you what to do was that I can't go into the solution in detail like if you should use a flag or not. I find some people make up their mind and insist on it. I do not. I try to offer the background that I have, which is not much. You have my blessing to go forward on which ever way you decide to do it based on your wider and deeper background. Thank you. |
Hello everyone (and @kohtala)! Sorry for the long pause. I had a recommendation from a coworker who proposed that the list-to-multi-yaml could be a subcommand rather than part of the expected behaviour of this program. For example, consider the following: kubectl get pods -o yaml | kubectl slice list-to-yaml -f - -o all.yaml This would read the list and parse it as a multi-YAML file. Then you could pipe its output to normal kubectl slice -f all.yaml Or everything done in a single shot with UNIX pipes: kubectl get pods -o yaml | kubectl slice list-to-yaml -f - --stdout | kubectl slice -f - --stdout This way:
Let me know what you all think! |
Since Kubernetes API does not have a kind named List, I think a single document YAML (as opposed to multi document YAML) with this kubectl specific kind does not need this complexity. But if it is how you feel you like it done, please do so. This does have the advantage, that there is a generic list-to-yaml tool should one be useful for any other tasks. |
True, but again, adding it to the main software part (the slicing) without a commitment from the Kubernetes org to have it be consistent seems wrong. Making it into a separate subcommand means you can just strip off that part of the command instead and/or produce fixes for just that part, without touching the main part of the software. |
100% agree with you @patrickdappollonio subcommand is good |
A practical solution with a simple pipe to
|
This is accurate, but I see the value of not bringing multiple tools/libraries and keeping a pipeline slim. All that said, looking back at the thread, I'm still unsure if we should proceed as a subcommand or as a feature flag. I have in writing that a handful of folks prefer the flag, but I can also see the value of having a standalone subcommand (which would entice people to download the app for generic purposes while at the same time serving the original goal; on the other end, I don't want to integrate a feature that it isn't "standard" into a "standard" tool). Will think about this a bit more (and if any of you have any opinion/preference that could skew the balance, happy to hear it too!) and come back once I have a plan to move forward. We recently added support for directory handling and that was, too, via a feature flag, and it seems well received, maybe this could vouch for a feature flag too. |
Input file example called 'input.yaml':
command using yq do slice Kind List:
|
What did you do?
It installed v1.1.0.
What did you expect to see?
The list items be split to individual files.
What did you see instead?
One
list-.yml
file equal to thek8s.yml
.The text was updated successfully, but these errors were encountered: