tintoy / dotnet-kube-client

A Kubernetes API client for .NET Standard / .NET Core
MIT License
192 stars 32 forks source link

Support for API groups in CustomResourceDefinitions #114

Open matt-psaltis opened 4 years ago

matt-psaltis commented 4 years ago

Thanks for a great library, its been very easy to get up and going and connected to my AKS cluster.

I thought I'd drop a quick issue in to describe a problem I face with the current implementation. Microsoft provides extensions to their Azure Kubernetes configuration such as the one below.

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: azureidentities.aadpodidentity.k8s.io
spec:
  group: aadpodidentity.k8s.io
  version: v1
  names:
    kind: AzureIdentity
    singular: azureidentity
    plural: azureidentities
  scope: Namespaced

Creating a new AzureIdentity based on the above definition:

apiVersion: "aadpodidentity.k8s.io/v1"
kind: AzureIdentity
metadata:
  name: {{identity-name}}
  namespace: {{namespace}}
spec:
  type: 0
  ResourceID: {{identity-resource-id}}
  ClientID: {{identity-client-id}}

I'm using the DynamicResourceClient and the ApplyYaml call to apply the above configuration however the ApiMetadata loaded into the DynamicResourceClient does not include the group into the apiVersion lookup, instead the version is simply 'v1'. This results in a KubeClientException: Cannot find resource API for kind 'AzureIdentity', apiVersion 'aadpodidentity.k8s.io/v1'.

Its difficult to extend the current implementation as these classes are sealed and members like ApiMetadata cannot be extended to teach it about these types of extensions. Just wanted to provide that feedback as a potential opportunity for further extension points would make this very helpful!

Thanks again.

tintoy commented 4 years ago

Hi! Thanks for the feedback - let me have a think about this and I’ll see what can be done :)

tintoy commented 4 years ago

Ok, I'll have to get an Azure K8s cluster set up to scrape the API metadata so I can see where it's going wrong with interpreting it; I'll try to have a go at doing this over the weekend but if not I should have some time next week to do it.