Client/API generation from CRDs

300 views
Skip to first unread message

Tomas Nozicka

unread,
Nov 7, 2022, 9:39:29 AM11/7/22
to kubernetes-sig...@googlegroups.com
Hi Sig API Machinery,

I was wondering whether there is a Kubernetes generator that can create type
definitions and clients based on a CRD.

To give you some background, when I create my own APIs, I start by writing
`types.go`, run `k8s.io/code-generator/cmd/client-gen` to give me a client and
create the CRD with `sigs.k8s.io/controller-tools/cmd/controller-gen crd`.

But when someone else creates the CRD, possibly in some other language then
Golang, writes it by hand, or couples unwanted dependencies in helper functions
- how can I get the same generated code based on the CRD? Technically, I think
the projection should be able to be done the other way as well, but I have no
idea whether someone has done it already.

Best I've have so far is using a dynamic client but I'd prefer a typed one if
possible.

Thanks,
Tomas

Eirik Albrigtsen

unread,
Nov 7, 2022, 10:52:09 PM11/7/22
to K8s API Machinery SIG
There's kopium that does this to generate rust structs:

It's a wip as it's hairy thing to get right (and does not work for all cases), but definitely seeing a lot of devs who want this type of thing to move between languages more easily.

Reply all
Reply to author
Forward
0 new messages