Closed dbrat43 closed 3 years ago
Am I calling the createNamespacedCustomObject() method correctly?
i think so
Am I passing in my String json body into the object body correctly, or should I be using a different object to make it work?
no need to cast the resource to json content before calling createNamespacedCustomObject
, just passing the object as parameter will work.
I would also like to point out that I was able to manually apply the above yaml to my Kubernetes cluster which supports the Calico NetworkPolicy custom resource, validating that the yaml does not have any syntactical issues itself. Here is an example of what a Calico NetworkPolicy should look like: https://docs.projectcalico.org/reference/resources/networkpolicy
My basic understanding of the Go error listed above is that the custom yaml I am providing is being parsed into a struct, however since I am specifying NetworkPolicy as the kind, it is attempting to parse it into the kube-native network policy which has a different structure from the custom Calico policy object I am trying to create, thus failing, however please correct me if I'm wrong.
If it looks like I'm doing things correctly on my end, is there an end-to-end example (code, sample yaml / json) of the steps that need to be taken to dynamically create a custom object in Java to help me identify the deltas? And if there is no end-to-end example, can you please advise what my next steps should be to ensure that I can create this custom object?
You need to either write the custom object yourself just like any other Java class, or if Calico provides an openapi spec for their objects you can use the instructions here:
To create the CRD objects.
But it's probably just easier to hand-code the Java object corresponding to the calico network policy.
Will try it out. Thanks!
@brendanburns, what if you don't know the structure of the CRD so you can't create a POJO for it beforehand?
Is there something similar to the CustomResource Typeless API in the fabric8io kubernetes client?
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale
.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close
.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale
@mattsanta sorry, I missed this from a long time ago! There is the GenericAPI which can use for this.
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten
.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close
.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten
Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen
.
Mark the issue as fresh with /remove-lifecycle rotten
.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close
@fejta-bot: Closing this issue.
Hi,
I am trying to dynamically create a namespaced custom object using the documentation provided here: https://github.com/kubernetes-client/java/blob/master/kubernetes/docs/CustomObjectsApi.md#createNamespacedCustomObject
When attempting to pass in my json body as a String into the method, I get the following json parse error:
This is my helper method that I'm using to call the CustomObjectsApi:
This is the sample json that I'm attempting to create an object with:
I also attempted to pass in the below yaml itself, however I got the same error as above:
We are using the Kubernetes client library to generate Kube-native objects in the same class without any issues and I am confident that my json does not have any syntax issues, so I have the following questions: