I have Karpenter running in my K8s Cluster.
I am trying to fetch the Karpenter resources from K8s and have it deserialized into a Model that I wrote and which extends CustomResource<Spec,Status>
.
One way to do this is using a CustomDeserialzier but I’m trying see if I can do without custom deserialization.
I tried to do
CustomResourceDefinition crd = v1CRDFromCustomResourceType(NodePool.class).editSpec().editVersion(0)
.withNewSchema().withNewOpenAPIV3Schema()
.withType("object").addToProperties("spec", new JSONSchemaPropsBuilder().withType("object")
.addToPatternProperties("weight", new JSONSchemaPropsBuilder().withType("integer").build())
.addToPatternProperties("template", new JSONSchemaPropsBuilder().withType("object")
.addToProperties("spec", new JSONSchemaPropsBuilder().withType("object")
.addToPatternProperties("nodeClassRef",
new JSONSchemaPropsBuilder().withType("object")
.addToProperties("apiVersion",
new JSONSchemaPropsBuilder().withType("string").build())
.addToProperties("kind",
new JSONSchemaPropsBuilder().withType("string").build())
.addToProperties("name",
new JSONSchemaPropsBuilder().withType("string").build())
.build())
.build()).build()).build())
.endOpenAPIV3Schema().endSchema().endVersion().endSpec().build();
client.apiextensions().v1().customResourceDefinitions().createOrReplace(crd);
MixedOperation<NodePool, KubernetesResourceList<NodePool>, Resource<NodePool>> karpenter = client.resources(
NodePool.class);
KubernetesResourceList<NodePool> list_one = karpenter.list();
However , it’s only able to populate weight and other objects such as nodeClassRef
are null
.
I suspect this is due to multiple levels of nesting in Karpenter spec and I say that because I tried the process on a different custom resource without using CRD and it populates the Object just fine and that resource doesn’t have nested spec.
Am I doing something wrong?
Any help would be appreciated.
Thanks.