headlamp icon indicating copy to clipboard operation
headlamp copied to clipboard

Generate Forms from Kubernetes Schema to Create and Edit Resources

Open Guilamb opened this issue 2 months ago • 1 comments

Objective:

The objective is to have a simple way to create CR/Kubernetes resources without using YAML.

Solution:

My solution is to generate a form from the Custom Resource Definition (CRD) schema using an existing library that can generate forms from a JSON schema. On CRD, json schema are defined in the base definition. CRD schema doc

This could be extended to other Kubernetes resources to simplify resource creation and make it more accessible since we can retrieve kubernetes resources schemas from the Kubernetes API.

What I Have Done So Far:

I have developed an initial version of this feature, only for CRD, in our plugin, which is available at Headlamp-plugin. All elements used to dynamically create the form are located under Headlamp-plugin/src/Components/Form/.

To create this version, I've used react-jsonschema-form (@rjsf-core) to generate the forms. Currently, I couldn't use the Material 5 theme, but it is available with react-Jsonschema-form, as mentioned here: RJSF/Themes.

I've added a simple "plus" button on the CRD details page that, when pressed, makes a popup with the form appear.

Here is what it looks like on a simple example CRD, with a basic name and description string: image

I think this would be an interesting feature for base Headlamp that would make the creation of CR and Kubernetes resources more user-friendly. I've just remembered this related issue : https://github.com/headlamp-k8s/headlamp/issues/1220

Guilamb avatar Jun 26 '24 12:06 Guilamb