1

I have made a kubernetes operator using this framework https://github.com/operator-framework/operator-sdk in which I have a small custom resource definition defined and a clientset generated.

I create a client for this custom resource doing:

imports are (
    "k8s.io/client-go/kubernetes"
    "k8s.io/client-go/rest"
)

config, err := rest.InClusterConfig()
kubernetesClientset := kubernetes.NewForConfig(config)
// my generated CR clientset
v1alpha1.New(kubernetesClientset.RESTClient())

So I simply use the config kubernetes gives to pods and created a default k8s REST clientset and use that in my custom resource's clientset (Is that even a good practice?).

However when I try to use my custom resource clientset and try to create an instance of the custom resource the client errors with encoding is not allowed for this codec: *versioning.codec (I guess it comes from here https://github.com/kubernetes/apimachinery/blob/master/pkg/runtime/codec.go#L104).

What does that exactly mean? I thought the generated client is aware of the custom resource?

Thanks for help...

Robin B
  • 11
  • 5

1 Answers1

0

I had the same problem due to restclient misconfiguration. Have a look how restclient is created and configured in the example here.

Artem
  • 1
  • 2
    Hello and welcome to Stack Overflow! Could you include the relevant parts of the link you give in your answer (by [editing it](https://stackoverflow.com/posts/55385054/edit))? Links can become unavailable in the future. – Michaël Polla Mar 27 '19 at 19:53