Commit 216e2f89 authored by 黎博's avatar 黎博

接口优化

parent e41624e6
...@@ -2289,6 +2289,7 @@ public class K8sService { ...@@ -2289,6 +2289,7 @@ public class K8sService {
List<Service> serviceList = kubernetesClient.services().inNamespace(namespace).list().getItems(); List<Service> serviceList = kubernetesClient.services().inNamespace(namespace).list().getItems();
// 遍历Pod列表 // 遍历Pod列表
for (Pod pod: podList) { for (Pod pod: podList) {
if (!pod.getStatus().getPhase().equals("Failed")) {
String serviceName = pod.getMetadata().getLabels().get("qcloud-app"); String serviceName = pod.getMetadata().getLabels().get("qcloud-app");
serviceName = serviceName.replace("-", "_").toUpperCase(); serviceName = serviceName.replace("-", "_").toUpperCase();
envMap.put(serviceName + "_SERVICE_HOST", pod.getStatus().getHostIP()); envMap.put(serviceName + "_SERVICE_HOST", pod.getStatus().getHostIP());
...@@ -2297,6 +2298,7 @@ public class K8sService { ...@@ -2297,6 +2298,7 @@ public class K8sService {
envMap.put("DB_SERVICE_HOST", pod.getStatus().getHostIP()); envMap.put("DB_SERVICE_HOST", pod.getStatus().getHostIP());
} }
} }
}
// 遍历Service列表 // 遍历Service列表
for (Service service: serviceList) { for (Service service: serviceList) {
String serviceName = service.getMetadata().getName().toUpperCase().replaceAll("-", "_"); String serviceName = service.getMetadata().getName().toUpperCase().replaceAll("-", "_");
...@@ -2334,9 +2336,9 @@ public class K8sService { ...@@ -2334,9 +2336,9 @@ public class K8sService {
public void podTest() { public void podTest() {
Map<String, String> labels = new HashMap<>(); Map<String, String> labels = new HashMap<>();
labels.put("qcloud-app", "mysql"); labels.put("qcloud-app", "cherry-ui");
labels.put("type", "base"); labels.put("type", "ui");
List<Pod> podList = kubernetesClient.pods().inNamespace("vcc").withLabels(labels).list().getItems(); List<Pod> podList = kubernetesClient.pods().inNamespace("fe").withLabels(labels).list().getItems();
String host = null; String host = null;
for (Pod pod: podList) { for (Pod pod: podList) {
if (pod.getStatus().getHostIP() != null) { if (pod.getStatus().getHostIP() != null) {
......
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