Commit b5fe8baf authored by 黎博's avatar 黎博

修改获取dubbo port

parent c23bc90d
......@@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jayway.jsonpath.JsonPath;
import com.tencentcloudapi.tcr.v20190924.models.RepoInfo;
import io.fabric8.kubernetes.api.model.ServicePort;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -475,8 +476,27 @@ public class K8sController {
@RequestParam String serviceType,
@RequestParam String serviceName,
@RequestParam String key) {
log.info("收到参数:{}, {}, {}, {}", namespace, serviceType, serviceName, key);
Map<String, Object> serviceMap = k8sService.getPodAndServiceInfo(namespace, serviceType, serviceName);
log.info("获取dubbo接口收到参数:{}, {}, {}, {}", namespace, serviceType, serviceName, key);
List<ServicePort> servicePortList = k8sService.getServiceDetail(namespace, serviceName).getSpec().getPorts();
Map<String, Object> serviceMap = new HashMap<>();
List<Map<String, Object>> portMappingList = new ArrayList<>();
if (servicePortList.size() > 0) {
for (ServicePort servicePort : servicePortList) {
if (servicePort.getNodePort() != null) {
serviceMap.put("port_" + servicePort.getName(), servicePort.getNodePort());
}
Map<String, Object> portMap = new HashMap<>();
portMap.put("name", servicePort.getName());
portMap.put("nodePort", servicePort.getNodePort());
portMap.put("port", servicePort.getPort());
portMap.put("protocol", servicePort.getProtocol());
portMap.put("targetPort", servicePort.getTargetPort());
portMappingList.add(portMap);
}
}
serviceMap.put("portMappings", portMappingList);
serviceMap.put("serviceName", serviceName);
serviceMap.put("namespace", namespace);
log.info("返回结果为:{}", JSON.toJSONString(serviceMap));
return serviceMap.get(key).toString();
}
......
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