lightkube icon indicating copy to clipboard operation
lightkube copied to clipboard

Better documentation on how to create Custom Resources

Open evilhamsterman opened this issue 1 year ago • 0 comments

The documentation about using and creating Custom Resources isn't that great. The documentation about loading Generic Resources is lacking in description and/or example of how to get from loading a generic resource from the cluster/yaml/crdspec to actually getting or creating an object of that resource. Also some of the example don't appear to work anymore, for example this is no longer valid

from lightkube.generic_resource import _created_resources

Plus the resources loaded from this method a lacking the type hinting for anything except the common fields like metadata and status. But often the spec field is the field you work with the most often and that lacks any hinting which is supposed to be a big part of Lightkube and throws errors in type checkers unless you use dict methods to access them. This may be ok for small things but it really sucks if you are say writing an operator.

Looking through the code and finding #54 in the issues list it is kind of possible to deduce how to create full proper models similar to the ones in the lightkube-models package but it would be nice if there were proper documentation on how to create full models

This appears to be a weakness of all the Python libraries for Kubernetes but I think Lightkube may be closest to being able to at least work with a project's models. Perhaps even document how to use your generator to generate models from an existing spec?

evilhamsterman avatar Jan 02 '25 21:01 evilhamsterman