Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
holmes
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
holmes
Commits
b5fe8baf
Commit
b5fe8baf
authored
Sep 14, 2021
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改获取dubbo port
parent
c23bc90d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
K8sController.java
src/main/java/cn/qg/holmes/controller/k8s/K8sController.java
+22
-2
No files found.
src/main/java/cn/qg/holmes/controller/k8s/K8sController.java
View file @
b5fe8baf
...
...
@@ -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
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment