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
dfdbb32f
Commit
dfdbb32f
authored
Sep 30, 2021
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复jenkins打包mock和debug问题
parent
f9c3ef57
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
+25
-2
K8sController.java
src/main/java/cn/qg/holmes/controller/k8s/K8sController.java
+15
-2
K8sService.java
src/main/java/cn/qg/holmes/service/k8s/K8sService.java
+10
-0
No files found.
src/main/java/cn/qg/holmes/controller/k8s/K8sController.java
View file @
dfdbb32f
...
...
@@ -12,8 +12,7 @@ import com.alibaba.fastjson.JSON;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.tencentcloudapi.tcr.v20190924.models.RepoInfo
;
import
com.tencentcloudapi.tcr.v20190924.models.TagInfo
;
import
io.fabric8.kubernetes.api.model.Namespace
;
import
io.fabric8.kubernetes.api.model.ServicePort
;
import
io.fabric8.kubernetes.api.model.*
;
import
io.fabric8.kubernetes.api.model.apps.Deployment
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -268,6 +267,20 @@ public class K8sController {
// 创建Deployment
if
(
k8sService
.
queryIfDeploymentExistByName
(
namespace
,
serviceName
))
{
Deployment
deployment
=
k8sService
.
getDeployment
(
namespace
,
serviceName
);
List
<
Container
>
containers
=
deployment
.
getSpec
().
getTemplate
().
getSpec
().
getContainers
();
if
(
containers
!=
null
&&
containers
.
size
()
>
0
)
{
List
<
EnvVar
>
envVarList
=
containers
.
get
(
0
).
getEnv
();
// 根据原来的debug和mock值,来设置debug和mock
for
(
EnvVar
envVar:
envVarList
)
{
if
(
envVar
.
getName
().
equals
(
"DEBUG"
))
{
serviceCreateVo
.
setDebug
(
Integer
.
valueOf
(
envVar
.
getValue
()));
}
if
(
envVar
.
getName
().
equals
(
"MOCK"
))
{
serviceCreateVo
.
setMock
(
Integer
.
valueOf
((
envVar
.
getValue
())));
}
}
}
log
.
info
(
"{}环境{}服务的Deployment已存在,首先删除该Deployment."
,
namespace
,
serviceName
);
k8sService
.
deleteDeployment
(
namespace
,
serviceName
);
}
...
...
src/main/java/cn/qg/holmes/service/k8s/K8sService.java
View file @
dfdbb32f
...
...
@@ -2315,6 +2315,16 @@ public class K8sService {
return
kubernetesClient
.
services
().
inNamespace
(
namespace
).
withName
(
serviceName
).
delete
();
}
/**
* 获取Deployment
* @param namespace
* @param serviceName
* @return
*/
public
Deployment
getDeployment
(
String
namespace
,
String
serviceName
)
{
return
kubernetesClient
.
apps
().
deployments
().
inNamespace
(
namespace
).
withName
(
serviceName
).
get
();
}
public
void
podTest
()
{
Map
<
String
,
String
>
labels
=
new
HashMap
<>();
labels
.
put
(
"qcloud-app"
,
"mysql"
);
...
...
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