-
Is there any existing way to generate pkl from a k8s crd? Maybe I've missed something but it looks like the current k8s packages can really only generate pkl from the k8s openapi spec, and not crds. I'm very interested in trying out pkl for configuring my k8s cluster but without support for crds that's a hard sell. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You can generate the CRDs thanks to @jackkleeman's awesome work. The simplest usage is: pkl eval package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd@1.0.0#/generate.pkl \
-m . \
-p source="https://path/to/crd.yml" This will generate Pkl files in the current directory for the provided CRD specs. You can fine-tune this by creating your own generate script that amends the published generator. For example, this causes the generator to use generate.pkl amends "package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd@1.0.0#/generate.pkl"
import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/core/v1/ResourceRequirements.pkl"
source = "https://path/to/crd.yml"
converters {
["name.of.my.crd"] {
[List("spec", "resources")] = ResourceRequirements
}
} Then, use this version via Old answer: @jackkleeman is working on precisely this. This should be very similar to the JSON Schema generator, except not quite, because of minor divergence from JSON Schema of OpenAPI |
Beta Was this translation helpful? Give feedback.
-
Just saw that this is now available: apple/pkl-pantry#17 |
Beta Was this translation helpful? Give feedback.
You can generate the CRDs thanks to @jackkleeman's awesome work.
Docs here: https://pkl-lang.org/package-docs/pkg.pkl-lang.org/pkl-pantry/k8s.contrib.crd/current/generate/index.html
The simplest usage is:
This will generate Pkl files in the current directory for the provided CRD specs.
You can fine-tune this by creating your own generate script that amends the published generator. For example, this causes the generator to use
module ResourceRequirements
for thespec.resources
property of your CRD:generate.pkl