kubernetes-client / java

Official Java client library for kubernetes
http://kubernetes.io/
Apache License 2.0
3.6k stars 1.92k forks source link

Error while listing services in kubernetes version 1.30.1 #3784

Open prateekkohli21 opened 2 weeks ago

prateekkohli21 commented 2 weeks ago

Describe the bug I am getting below error while listing services in kubernetes version 1.30.1 and client version 20.0.1

Exception : java.lang.IllegalArgumentException: The field ipMode in the JSON string is not defined in the V1LoadBalancerIngress properties. JSON: {\"ip\":\"10.217.127.235\",\"ipMode\":\"VIP\"}","extra_data":{"licensehandler":{"log_plane":"em-containerlogs"}},"metadata":{"properties":{"ul_id":"com.licensehandler.kubernetes.manager","pod_name":"abc-7fd8c957cd-vxdpd"}}}

Client Version e.g. 20.0.1

Kubernetes Version e.g. 1.30.1

Java Version e.g. Java 11

To Reproduce Steps to reproduce the behavior:

trying to list services using below code: V1ServiceList serviceList = coreV1Api.listNamespacedService(namespace).execute();

    if(serviceList != null) {
        List<V1Service> filteredServices = serviceList.getItems().stream()
                .filter(service -> hasMatchingServiceAnnotations(service, annotations))
                .collect(Collectors.toList());

Expected behavior Although the compatibility matrix shows "-" in this scenario, but still is there any way we can handle such incompatibility scenarios?

KubeConfig If applicable, add a KubeConfig file with secrets redacted.

Server (please complete the following information):

Additional context

The issue arises because ipMode is not recognized as a defined property in the V1LoadBalancerIngress model in your client version (20.0.1). When the Kubernetes API includes ipMode in its response (like {"ip": "10.217.127.235", "ipMode": "VIP"}), the Java client library throws an exception due to the unexpected field. Are similar issues expected when we use client version which mentions "-" in the compatibility matrix?

brendandburns commented 2 weeks ago

Yes, that is expected. 20.x was built with the 1.29 API spec. Though it will mostly work, there are places where there may be incompatabilities because fields were added or removed, this is such a case.

Please try the 21.x release which was built with the 1.30 API Spec.