openkruise / client-java Goto Github PK
View Code? Open in Web Editor NEWClient java for Kruise
License: Apache License 2.0
Client java for Kruise
License: Apache License 2.0
It appears that files like src/main/java/io/openkruise/client/JSON.java was deleted on 2021-12-07. Usage of such file is to parse the customized JSON object like cloneset. Wonder what's the replacement object to use for such purpose? @FillZpp
I like to patch a cloneset using the CustomObjectsApi.patchNamespacedCustomObject() Java API to update the number of replicas with podsToDelete. Like the patch_file.yaml example below:
spec:
replicas: 5
scaleStrategy:
podsToDelete:
- node-0f03b-kcgbt
The kubectl --patch command below works fine:
> kubectl patch clone/mycloneset --type merge --patch "$(cat patch_file.yaml)"
I am trying to figure out how to do it through the Java API. Code below works to update the replicas to be 5.
String jsonPatchStr="[{\"op\":\"replace\",\"path\":\"/spec/replicas\",\"value\":5}]";
V1Patch body = new V1Patch(jsonPatchStr);
customObjectsApi.patchNamespacedCustomObject(
"apps.kruise.io", // group
"v1alpha1", // version
cluster, // namespace
"clonesets", // plural
cloneset, // name
body, // Object body
null, // dryRun
null, // fieldManager
null // force
);
How do I include the podsToDelete into the jsonPatchStr? Or is there another simpler way to prepare the body parameter given patch_file.yaml?
The models included, like KruiseAppsV1alpha1CloneSet, are compatible with io.kubernetes client-java 5.0.0. It will lead to error like java.lang.ClassNotFoundException: io.kubernetes.client.models.V1ObjectMeta if later version of io.kubernetes client-java is used.
Comments in the model code suggest they were generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen. However I don't see clear instructions on how to re-generate the models based on newer version of io.kubernetes client-java, like 11.0.0.
How to generate new models that are compatible with more recent io.kubernetes client-java?
@FillZpp i want to watch on delete event of cloneset. Can you help me with some code snippet around watch.
Hit following error to parse getNamespacedCustomObject() result into KruiseAppsV1alpha1CloneSet (gson 2.8.9).
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at path $.status.conditions[0].lastTransitionTime
unfortunately I don't have the status.conditions[0].lastTransitionTime field as it does not normally exists in the cloneset object and we didn't save a copy when it happened (I will add an example if this happens again in the future). I wonder whether there is a possible mismatch between the expected and real format of the field. Or like to know if there is a better way to obtain KruiseAppsV1alpha1CloneSet from the returned obj.
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
CustomObjectsApi customObjectsApi = new CustomObjectsApi(client);
Object obj = customObjectsApi.getNamespacedCustomObject(
"apps.kruise.io", // group
"v1alpha1", // version
K8sCommon.getNamespaceFromEnv(), // namespace
"clonesets", // plural
cloneset // name
);
Gson gson = new JSON().getGson();
KruiseAppsV1alpha1CloneSet v1cs = gson.fromJson(
gson.toJsonTree(obj).getAsJsonObject(), KruiseAppsV1alpha1CloneSet.class);
I have motivation to use more recent io.kubernetes client-java 14.0.0 and try to build the project with <k8s.client.version>14.0.0</k8s.client.version> in pom.xml. It failed with following test error:
CustomObjectsApiTest.java:[185,30] method listClusterCustomObject in class io.kubernetes.client.openapi.apis.CustomObjectsApi cannot be applied to given types ...
Such error appears to be superficial as no code in the package is calling listClusterCustomObject any more. So please consider removing such tests as well.
你好,请问下openkruise的java client项目是否一直在维护呢?我们平台是用java开发的,目前想接入openkruise,所以想问一下Java client和Golang client的维护情况,谢谢!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.