Can CustomObjectsApi support all kind of kubernetesObject?
We have many project use k8s-sdk controll the cluster, I am writing a self-sdk for our projects, I want to use CustomObjectsApi to process all kind of kubernetesObject, I found it hard code "/apis/{group}/{version}/", some "/api/{group}/{version}" not suitable for use,
I will hack it by "if group is empty use api, else use apis"
is that right, any other point that may happen?
Here is the link to CustomObjectsApi. Maybe i can give a patch to make it more compatible...
https://github.com/kubernetes-client/java/blob/master/kubernetes/src/main/java/io/kubernetes/client/openapi/apis/CustomObjectsApi.java#L80
"/api/{group}/{version}"
the "/api" prefix only applies to those oldest legacy API such as pod, node. custom resources will be automatically registered under "/apis". you can also use "DynamicKuberentesClient" to build a path agnostic client
@yue9944882 Thank you for help. I can't found a method like "listClusterCustomObjectCall" in DynamicKubernetesApi.
My basic business is "render a yaml, load the yaml, create some kubeObjects, watch the status, delete the kubeObjects"
Here is my code using informer to watch status
CustomObjectsApi customObjectsApi = new CustomObjectsApi(client);
GroupVersionResource groupVersionResource = ModelMapper.getGroupVersionResourceByClass(getApiType());
SharedIndexInformer<T> informer = factory.sharedIndexInformerFor((CallGeneratorParams params) -> {
return customObjectsApi.listClusterCustomObjectCall(groupVersionResource.getGroup(), groupVersionResource.getVersion(),
groupVersionResource.getResource(), null, null, null, null, null, null, params.resourceVersion, null, params.timeoutSeconds,
params.watch, null);
}, getApiType(), getListType());
informer.addEventHandler(new ResourceEventHandler<T>() {...});
DynamicKubernetesApi features a private call that does what you want:
https://github.com/kubernetes-client/java/blob/master/util/src/main/java/io/kubernetes/client/util/generic/GenericKubernetesApi.java#L627
@yue9944882 we should consider making that public so that people can watch dynamic objects?
hey, I am use customObject too.
And I found that patchNamespacedCustomObject is only support json.
public okhttp3.Call patchNamespacedCustomObjectCall {
...
final String[] localVarContentTypes = {
"application/json-patch+json", "application/merge-patch+json"
};
final String localVarContentType =
localVarApiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
...
}
public String selectHeaderContentType(String[] contentTypes) {
if (contentTypes.length == 0 || contentTypes[0].equals("*/*")) {
return "application/json";
}
for (String contentType : contentTypes) {
if (isJsonMime(contentType)) {
return contentType;
}
}
return contentTypes[0];
}
selectHeaderContentType will return directly at the first parmeter. right?
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue as fresh with
/remove-lifecycle stale - Close this issue with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue as fresh with
/remove-lifecycle rotten - Close this issue with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Reopen this issue with
/reopen - Mark this issue as fresh with
/remove-lifecycle rotten - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/close not-planned
@k8s-triage-robot: Closing this issue, marking it as "Not Planned".
In response to this:
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied- After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied- After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closedYou can:
- Reopen this issue with
/reopen- Mark this issue as fresh with
/remove-lifecycle rotten- Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/close not-planned
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.