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

接口优化

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