java
java copied to clipboard
CustomObjectsApi.getNamespacedCustomObject does not return metadata in the latest version of the client
trafficstars
Describe the bug
We use CustomObjectsApi to deal with the CRUD operations for istio related resources. Since upgrading the k8s client version to 20.0.1, the CustomObjectsApi.getNamespacedCustomObject does not return metadata as part of the response. This used to work in the older version of the client 1.12.
Client Version 20.0.1
Kubernetes Version 1.29
Java Version Java 21
To Reproduce Steps to reproduce the behavior:
public class CustomObjectResourceVersion {
public static void main(String[] args) {
try {
ApiClient client = Config.defaultClient();
io.kubernetes.client.openapi.Configuration.setDefaultApiClient(client);
CustomObjectsApi customObjectsApi = new CustomObjectsApi(client);
String group = "networking.istio.io";
String version = "v1beta1";
String namespace = "default";
String plural = "virtualservices";
String name = "vs-name";
Map<String, Object> customObject = (Map<String, Object>) customObjectsApi.getNamespacedCustomObject(
group,
version,
namespace,
plural,
name
);
Gson gson = new Gson();
String vsJsonString = gson.toJson(customObject);
VirtualService existingVirtualService = gson.fromJson(vsJsonString, VirtualService.class);
String resourceVersion = existingVirtualService.getMetadata().getResourceVersion();
} catch(Exception e) {
e.printStackTrace();
}
}
Expected behavior It should return the metadata.
Output of raw JSON
{\\\"group\\\":\\\"networking.istio.io\\\",\\\"version\\\":\\\"v1beta1\\\",\\\"namespace\\\":\\\"namespace-name\\\",\\\"plural\\\":\\\"virtualservices\\\",\\\"name\\\":\\\"example-virtualservice-name\\\"} \"}