-
Notifications
You must be signed in to change notification settings - Fork 32
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
Respect groupVersion when dynamically loading resource-type metadata from cluster API #139
base: develop
Are you sure you want to change the base?
Conversation
Ok, I’ll have a look this morning and see if I can figure out what’s going on. |
Just to confirm - you’re calling |
Ah I wasn't, but with that added I am getting a different error for both the custom resource and HorizontalPodAutoscalers which was previously working: HPA:
Istio CRD:
I've tried tweaking a few things, like not passing in the API group in the version (ie just v1beta1) to the annotations and List call, same result in all cases. Interesting this does work tho:
Any ideas? Thanks again for the time, no real rush on this. Istio classes (tried using
|
The error clientOptions.ModelTypeAssemblies.Add(
typeof(DestinationRuleV1).Assembly
); |
To be honest, I'm not entirely happy with how the dynamic resource client works; it was originally built to support the Powershell provider (where specifying type info is more painful) and has plenty of room for improvement in terms of ergonomics :) Philosophically speaking, KubeClient is mainly designed for use with strongly-typed models and clients and I suspect what has led you to the dynamic client is that there is no client defined for the Istio resource types (feel free to correct me if I'm wrong on this). The way the library was originally envisioned, you'd extend the client by creating some models and an additional But perhaps the dynamic client provides a halfway point in terms of investment of effort so it might be worth refining its ergonomics for this sort of use case. I'll keep thinking about that 🙂 |
ahh got it, yeah this was a while ago I think there were no statically typed options for HPA v2 so I ended up using the dynamic client. I forget exactly as it was a while ago, but this is a new but similar use case for Istio resources so I started with the same approach. I took a look at the docs you linked and switched to the statically typed approach, may as well since I need to declare classes for the CRD resources anyway. It's working well now, so thank you for the help and suggestions! |
Great, glad to hear it! 🙂 I’ll see what I can do to improve that error message, BTW - it doesn’t really give a good indication of how to resolve the problem. |
Currently, resource type metadata for the dynamic resource client ignores groupVersion (e.g.
networking.istio.io/v1beta1
) in favour of version (e.g.v1beta1
) when loading resource type metadata from the k8s API (loading from type annotations on model metadata works correctly however).The end result of this is that resource types that have a
groupVersion
rather than just aversion
(i.e.version != groupVersion
) don't seem to work correctly with the dynamic client.I think the original idea was to enable consumers to specify
kind
andapiVersion
without having to specifygroup
as well (i.e.kind
andapiGroupVersion
) but this was probably due to a lack of understanding (on my part, I suspect) of the semantics of API group and version.I have some mild concerns that this may constitute a breaking change but considering that the existing behaviour was both wrong and non-functional I think I am OK with that 🙂
PS. @felixfbecker - figured you might care since the powershell stuff was one of the original consumers of this functionality 🙂
Relates to #114 and #138