-
Notifications
You must be signed in to change notification settings - Fork 43
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
Create new classes automatically in kr8s.get
#199
Comments
I know this isn't convenient quite yet, but is there a pattern to use to accomplish it? I tried to use some of the code you provided in this issue, but not having much luck. It works with the mutatingwebhookconfiguration snippet you provided, but when I try with a custom resource it doesn't work. My specific use case is Istio, which is pretty commonly used. I tried EDIT: Nevermind, I guess I can't just call |
It looks like the class that you generate with When I do |
Glad you figured out how to do it manually.
Yeah if you don't assign it then it will get garbage collected. Perhaps we should keep a reference internally in kr8s somewhere to avoid this happening. Would you mind opening a ticket to track this?
This sounds like a bug. Would you mind opening a separate issue for this? |
Which project are you requesting an enhancement for?
kr8s
What do you need?
In #198 I made a bunch of improvements around how we can specify resource names in
kr8s.get
.However, we still don't support getting objects that we don't have a base class representation for.
However, if we first create a container class for it with the class factory we can do it.
Alternatives
In the
kr8s.objects.object_from_spec(...)
method there is a kwarg calledallow_unknown_type
which if set toTrue
will callnew_class
automatically if it is passed a spec that it isn't aware of.We could do this in
kr8s.get
too so that we can get any API object that we haven't seen before. Given thatkr8s
is striving to provide a batteries included and close tokubectl
experience we may want to make this dynamic classing the default behaviour and switch the kwarg to enable folks to explicitly opt out.A couple of things to take into consideration:
namespaced=False
to make this work because I chose a non-namespaced resource. We would need to updatenew_class
to look this up automatically via the Kubernetes API.asyncio=False
because I wrote all the examples here with the sync API. We would potentially want to create both a sync and async class when callingnew_class
or havekr8s.objects.new_class
create sync objects by default andkr8s.asyncio.objects.new_class
continue to create async objects.The text was updated successfully, but these errors were encountered: