Open linjmeyer opened 3 years ago
Possibly related #114
Hi :)
It's been a while since I looked through the dynamic resource client, but from what I remember it doesn't dynamically query the cluster's list of available resource types unless you explicitly ask it to (as this can add an unexpected degree of startup cost depending on how much configuration data is returned by the API and so default behaviour is to pre-populate it from type annotations on well-known resource models).
DynamicResourceClient
has an ApiMetadata
property which contains information about all known resource APIs, and you can tell it to load all resource type definitions from from the cluster using something like:
await _kubeApiClient.Dynamic().ApiMetadata.Load(_kubeApiClient, clearExisting: true);
(there should probably be an extension method on IDynamicResourceClient
to do this)
You can also define API models with annotations if you prefer and use them to populate the API metadata, using:
Assembly modelAssembly = typeof(MyModel).Assembly;
_kubeApiClient.Dynamic().ApiMetadata.LoadFromMetadata(modelAssembly, clearExisting: false);
Ah, sorry, just had a closer look and the issue may be that the API version (v1beta1
) is being used in preference to the API group-version (networking.isio.io/v1beta1
). I'll see what I can do about that.
Ok, I have a pull request open that will hopefully fix your problem, but I need to run it by a couple of our existing consumers / contributors to get their take on this 🙂
Awesome thanks! Appreciate the quick turn around time on that, and the tip for the custom models is great too. Right now I just need the labels from the CRD resources but I'll likely need to extend that in the future.
Hi there, I use this client and have had really good luck with it, so thanks for providing this!
I tried to extend an internal tool to grab Istio DestinationRule resources but I am getting this error:
KubeClient.KubeClientException: Cannot find resource API for kind 'DestinationRule', apiVersion 'networking.istio.io/v1beta1'
I'm fairly sure the code and API/kind is correct:
An example object shows the API and Kind are correct:
This same code works for HPAs using
HorizontalPodAutoscaler
andautoscaling/v1
but happy to adjust if I am doing anything wrong here.Thanks!