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
f2382c1f
Commit
f2382c1f
authored
Apr 21, 2022
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增服务指向接口
parent
1a176db3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
K8sController.java
src/main/java/cn/qg/holmes/controller/k8s/K8sController.java
+12
-0
TkeService.java
src/main/java/cn/qg/holmes/service/k8s/TkeService.java
+15
-0
No files found.
src/main/java/cn/qg/holmes/controller/k8s/K8sController.java
View file @
f2382c1f
...
...
@@ -522,4 +522,16 @@ public class K8sController {
tkeService
.
clearRubbish
(
env
);
return
JsonResult
.
buildSuccessResult
(
true
);
}
/**
* 修改service指向
* @param namespace 环境
* @param sourceServiceName 源Service
* @param targetServiceName 目标Service
* @return
*/
@PostMapping
(
"/service/redirect"
)
public
JsonResult
modifyServiceDirect
(
String
namespace
,
String
sourceServiceName
,
String
targetServiceName
)
{
return
JsonResult
.
buildSuccessResult
(
tkeService
.
modifyServicePointing
(
namespace
,
sourceServiceName
,
targetServiceName
));
}
}
src/main/java/cn/qg/holmes/service/k8s/TkeService.java
View file @
f2382c1f
...
...
@@ -844,4 +844,19 @@ public class TkeService {
return
resultMap
;
}
/**
* 修改服务指向
* @param namespace
* @param sourceServiceName
* @param targetServiceName
* @return
*/
public
boolean
modifyServicePointing
(
String
namespace
,
String
sourceServiceName
,
String
targetServiceName
)
{
Service
service
=
kubernetesClient
.
services
().
inNamespace
(
namespace
).
withName
(
sourceServiceName
).
get
();
service
.
getSpec
().
setClusterIP
(
null
);
service
.
getSpec
().
getPorts
().
forEach
(
servicePort
->
servicePort
.
setTargetPort
(
null
));
service
.
getSpec
().
getSelector
().
put
(
"qcloud-app"
,
targetServiceName
);
return
kubernetesClient
.
services
().
inNamespace
(
namespace
).
createOrReplace
(
service
)
!=
null
;
}
}
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