Commit a120f478 authored by 黎博's avatar 黎博

/k8s/listEnvVars特殊处理kafka

parent 664afe93
...@@ -9,6 +9,7 @@ import io.fabric8.kubernetes.client.Config; ...@@ -9,6 +9,7 @@ import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.DefaultKubernetesClient; import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.KubernetesClient;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -79,7 +80,13 @@ public class K8sService { ...@@ -79,7 +80,13 @@ public class K8sService {
} }
// 遍历Service列表 // 遍历Service列表
for (Service service: serviceList) { for (Service service: serviceList) {
String serviceName = service.getMetadata().getName().toUpperCase().replaceAll("-", "_"); String serviceName = service.getMetadata().getName();
// kafka Service Name 需要特殊处理一下
if (StringUtils.equals(serviceName, "kafka-" + namespace)) {
serviceName = "kafka";
}
// 转换成大写,并将-替换成下划线
serviceName = serviceName.toUpperCase().replaceAll("-", "_");
List<ServicePort> servicePortList = service.getSpec().getPorts(); List<ServicePort> servicePortList = service.getSpec().getPorts();
if (service.getMetadata().getLabels().get("type").equals("base")) { if (service.getMetadata().getLabels().get("type").equals("base")) {
if (servicePortList.get(0).getPort() != null) { if (servicePortList.get(0).getPort() != 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