Skip to content

Example code is out of date. #2786

@Ananya2001-an

Description

@Ananya2001-an

Describe the bug
I tried running the example for listPodForAllNamespaces in my local maven project but it's giving me compilation error. The null values being passed as arguments to the method seems to be the problem. I am not sure if the example provided is wrong or something else seems to the issue here? The same thing happened with other methods as well...

package com.example;

import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.Configuration;
import io.kubernetes.client.openapi.apis.CoreV1Api;
import io.kubernetes.client.openapi.models.V1Pod;
import io.kubernetes.client.openapi.models.V1PodList;
import io.kubernetes.client.util.Config;
import java.io.IOException;

/**
 * A simple example of how to use the Java API
 *
 * <p>Easiest way to run this: mvn exec:java
 * -Dexec.mainClass="io.kubernetes.client.examples.Example"
 *
 * <p>From inside $REPO_DIR/examples
 */
public class KubernetesClientDemo {
  public static void main(String[] args) throws IOException, ApiException {
    ApiClient client = Config.defaultClient();
    Configuration.setDefaultApiClient(client);

    CoreV1Api api = new CoreV1Api();
    V1PodList list =
        api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null, null, null);
    for (V1Pod item : list.getItems()) {
      System.out.println(item.getMetadata().getName());
    }
  }
}

Screenshot 2023-09-08 175233

Client Version
e.g. 18.0.1

Kubernetes Version
minikube

Java Version
e.g. Java 11

Expected behavior
Should have listed all the pods.

Server (please complete the following information):

  • OS: [e.g. WSL]

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions