Commit cde64549 authored by 黎博's avatar 黎博

获取pod列表新增Pending状态判断

parent 1eaee48b
...@@ -141,7 +141,7 @@ public class K8sService { ...@@ -141,7 +141,7 @@ public class K8sService {
List<Pod> podList = kubernetesClient.pods().inNamespace(namespace).list().getItems(); List<Pod> podList = kubernetesClient.pods().inNamespace(namespace).list().getItems();
List<Map<String, Object>> result = new ArrayList<>(); List<Map<String, Object>> result = new ArrayList<>();
for (Pod pod : podList) { for (Pod pod : podList) {
if (pod.getStatus().getPhase().equals("Running")) { if (pod.getStatus().getPhase().equals("Running") || pod.getStatus().getPhase().equals("Pending")) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
// 端口映射 // 端口映射
List<Map<String, Object>> portMappingList = new ArrayList<>(); List<Map<String, Object>> portMappingList = new ArrayList<>();
...@@ -1971,8 +1971,13 @@ public class K8sService { ...@@ -1971,8 +1971,13 @@ public class K8sService {
} }
public void podTest() { public void podTest() {
Pod pod = kubernetesClient.pods().inNamespace("k8s").withName("notify-56fc55776b-5qshb").get(); List<Pod> podList = kubernetesClient.pods().inNamespace("k8s").list().getItems();
System.out.println(JSON.toJSONString(pod.getStatus().getContainerStatuses().get(0))); for (Pod pod: podList) {
System.out.println(pod.getMetadata().getName());
System.out.println(pod.getMetadata());
System.out.println(JSON.toJSON(pod.getSpec()));
System.out.println(JSON.toJSON(pod.getStatus()));
}
} }
public static void main(String[] args) { public static void main(String[] args) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment