Commit 5488b4af authored by 黎博's avatar 黎博

获取pod列表新增host字段

parent 7abcb7dc
...@@ -169,6 +169,7 @@ public class K8sService { ...@@ -169,6 +169,7 @@ public class K8sService {
map.put("portMappings", portMappingList); map.put("portMappings", portMappingList);
} }
} }
// 格式化创建时间
try { try {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
df.setTimeZone(TimeZone.getTimeZone("UTC")); df.setTimeZone(TimeZone.getTimeZone("UTC"));
...@@ -178,6 +179,11 @@ public class K8sService { ...@@ -178,6 +179,11 @@ public class K8sService {
log.info("时间转换异常!"); log.info("时间转换异常!");
map.put("createdAt", podMetadata.getCreationTimestamp()); map.put("createdAt", podMetadata.getCreationTimestamp());
} }
// 从Ingress里获取host
Ingress ingress = kubernetesClient.extensions().ingresses().inNamespace(namespace).withName(serviceName).get();
if (ingress != null) {
map.put("host", ingress.getSpec().getRules().get(0).getHost());
}
map.put("serviceName", serviceName); map.put("serviceName", serviceName);
map.put("podName", podMetadata.getName()); map.put("podName", podMetadata.getName());
map.put("labels", podMetadata.getLabels()); map.put("labels", podMetadata.getLabels());
......
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