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

接口优化

parent e41624e6
...@@ -2289,12 +2289,14 @@ public class K8sService { ...@@ -2289,12 +2289,14 @@ 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) {
String serviceName = pod.getMetadata().getLabels().get("qcloud-app"); if (!pod.getStatus().getPhase().equals("Failed")) {
serviceName = serviceName.replace("-", "_").toUpperCase(); String serviceName = pod.getMetadata().getLabels().get("qcloud-app");
envMap.put(serviceName + "_SERVICE_HOST", pod.getStatus().getHostIP()); serviceName = serviceName.replace("-", "_").toUpperCase();
// MYSQL需要额外加个参数 envMap.put(serviceName + "_SERVICE_HOST", pod.getStatus().getHostIP());
if (serviceName.equals("MYSQL")) { // MYSQL需要额外加个参数
envMap.put("DB_SERVICE_HOST", pod.getStatus().getHostIP()); if (serviceName.equals("MYSQL")) {
envMap.put("DB_SERVICE_HOST", pod.getStatus().getHostIP());
}
} }
} }
// 遍历Service列表 // 遍历Service列表
...@@ -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