class TopExample {

  private static final Logger logger = LoggerFactory.getLogger(TopExample.class);

  private static final String CPU = "cpu";
  private static final String MEMORY = "memory";

  public static void main(String[] args) {<FILL_FUNCTION_BODY>}
}

    try (KubernetesClient client = new KubernetesClientBuilder().build()) {
      if (!client.supports(NodeMetrics.class)) {
        logger.warn("Metrics API is not enabled in your cluster");
        return;
      }
      logger.info("==== Node Metrics  ====");
      client.top().nodes().metrics().getItems().forEach(nodeMetrics -> logger.info("{}\tCPU: {}{}\tMemory: {}{}",
          nodeMetrics.getMetadata().getName(),
          nodeMetrics.getUsage().get(CPU).getAmount(), nodeMetrics.getUsage().get(CPU).getFormat(),
          nodeMetrics.getUsage().get(MEMORY).getAmount(), nodeMetrics.getUsage().get(MEMORY).getFormat()));

      final String namespace = Optional.ofNullable(client.getNamespace()).orElse("default");
      logger.info("==== Pod Metrics ====");
      client.top().pods().metrics(namespace).getItems()
          .forEach(podMetrics -> podMetrics.getContainers()
              .forEach(containerMetrics -> logger.info("{}\t{}\tCPU: {}{}\tMemory: {}{}",
                  podMetrics.getMetadata().getName(), containerMetrics.getName(),
                  containerMetrics.getUsage().get(CPU).getAmount(), containerMetrics.getUsage().get(CPU).getFormat(),
                  containerMetrics.getUsage().get(MEMORY).getAmount(), containerMetrics.getUsage().get(MEMORY).getFormat())));

      client.pods().inNamespace(namespace).list().getItems().stream().findFirst().map(pod -> {
        logger.info("==== Individual Pod Metrics ({}) ====", pod.getMetadata().getName());
        try {
          return client.top().pods().metrics(namespace, pod.getMetadata().getName());
        } catch (KubernetesClientException ex) {
          if (ex.getCode() == HttpURLConnection.HTTP_NOT_FOUND) {
            logger.info(" - Pod has not reported any metrics yet");
          } else {
            logger.warn(" - Error retrieving Pod metrics: {}", ex.getMessage());
          }
          return null;
        }
      }).ifPresent(podMetrics -> podMetrics.getContainers()
          .forEach(containerMetrics -> logger.info("{}\t{}\tCPU: {}{}\tMemory: {}{}",
              podMetrics.getMetadata().getName(), containerMetrics.getName(),
              containerMetrics.getUsage().get(CPU).getAmount(), containerMetrics.getUsage().get(CPU).getFormat(),
              containerMetrics.getUsage().get(MEMORY).getAmount(), containerMetrics.getUsage().get(MEMORY).getFormat())));

    } catch (KubernetesClientException e) {
      logger.error(e.getMessage(), e);
    }
  
<no_super_class>