use of io.kubernetes.client.custom.ContainerMetrics in project java by kubernetes-client.
the class MetricsExample method main.
public static void main(String[] args) throws IOException, ApiException {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
Metrics metrics = new Metrics(client);
NodeMetricsList list = metrics.getNodeMetrics();
for (NodeMetrics item : list.getItems()) {
System.out.println(item.getMetadata().getName());
System.out.println("------------------------------");
for (String key : item.getUsage().keySet()) {
System.out.println("\t" + key);
System.out.println("\t" + item.getUsage().get(key));
}
System.out.println();
}
for (PodMetrics item : metrics.getPodMetrics("default").getItems()) {
System.out.println(item.getMetadata().getName());
System.out.println("------------------------------");
if (item.getContainers() == null) {
continue;
}
for (ContainerMetrics container : item.getContainers()) {
System.out.println(container.getName());
System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
for (String key : container.getUsage().keySet()) {
System.out.println("\t" + key);
System.out.println("\t" + container.getUsage().get(key));
}
System.out.println();
}
}
}
Aggregations