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
43645596
Commit
43645596
authored
Jul 07, 2021
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增方法
parent
e6a3713d
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
595 additions
and
5 deletions
+595
-5
pom.xml
pom.xml
+5
-0
DbSyncController.java
...java/cn/qg/holmes/controller/effect/DbSyncController.java
+0
-1
K8sController.java
src/main/java/cn/qg/holmes/controller/k8s/K8sController.java
+45
-4
DockerProject.java
src/main/java/cn/qg/holmes/entity/k8s/DockerProject.java
+42
-0
ServiceCreateVo.java
src/main/java/cn/qg/holmes/entity/k8s/ServiceCreateVo.java
+20
-0
ImageService.java
src/main/java/cn/qg/holmes/service/k8s/ImageService.java
+58
-0
TkeService.java
src/main/java/cn/qg/holmes/service/k8s/TkeService.java
+425
-0
No files found.
pom.xml
View file @
43645596
...
...
@@ -155,6 +155,11 @@
<version>
5.4.1
</version>
</dependency>
<dependency>
<groupId>
com.tencentcloudapi
</groupId>
<artifactId>
tencentcloud-sdk-java
</artifactId>
<version>
3.1.305
</version>
</dependency>
</dependencies>
...
...
src/main/java/cn/qg/holmes/controller/effect/DbSyncController.java
View file @
43645596
...
...
@@ -2,7 +2,6 @@ package cn.qg.holmes.controller.effect;
import
cn.qg.holmes.common.JsonResult
;
import
cn.qg.holmes.service.effect.DatabaseSyncService
;
import
cn.qg.holmes.utils.K8sService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
src/main/java/cn/qg/holmes/controller/k8s/K8sController.java
View file @
43645596
package
cn
.
qg
.
holmes
.
controller
.
k8s
;
import
cn.qg.holmes.common.JsonResult
;
import
cn.qg.holmes.utils.K8sService
;
import
cn.qg.holmes.service.k8s.ImageService
;
import
cn.qg.holmes.service.k8s.TkeService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -14,7 +15,10 @@ import java.util.Map;
public
class
K8sController
{
@Autowired
K8sService
k8sService
;
TkeService
tkeService
;
@Autowired
ImageService
imageService
;
/**
* 获取namespace列表
...
...
@@ -22,7 +26,7 @@ public class K8sController {
*/
@GetMapping
(
"/namespace"
)
public
JsonResult
getNamespaceList
()
{
return
JsonResult
.
buildSuccessResult
(
k8s
Service
.
getNamespaceList
());
return
JsonResult
.
buildSuccessResult
(
tke
Service
.
getNamespaceList
());
}
/**
...
...
@@ -32,7 +36,44 @@ public class K8sController {
*/
@GetMapping
(
"/pod/list"
)
public
JsonResult
getServiceList
(
@RequestParam
String
namespace
)
{
List
<
Map
<
String
,
Object
>>
podList
=
k8s
Service
.
getPodList
(
namespace
);
List
<
Map
<
String
,
Object
>>
podList
=
tke
Service
.
getPodList
(
namespace
);
return
JsonResult
.
buildSuccessResult
(
podList
);
}
/**
* 根据服务名称获取镜像列表
* @param serviceName 服务名称
* @return
*/
@GetMapping
(
"/image/list"
)
public
JsonResult
getImageListByServiceName
(
@RequestParam
String
serviceName
)
{
return
JsonResult
.
buildSuccessResult
(
imageService
.
getImageListByService
(
serviceName
));
}
@PostMapping
(
"/pod/create"
)
public
JsonResult
createPod
()
{
return
null
;
}
/**
* 重置pod
* @param namespace 环境
* @param podName podName
* @return
*/
@PostMapping
(
"/pod/redeploy"
)
public
JsonResult
resetPodByName
(
String
namespace
,
String
podName
)
{
return
JsonResult
.
buildSuccessResult
(
tkeService
.
resetPod
(
namespace
,
podName
));
}
/**
* 删除pod
* @param namespace 环境
* @param serviceName 服务名称
* @return
*/
@PostMapping
(
"/pod/delete"
)
public
JsonResult
deletePodByName
(
String
namespace
,
String
serviceName
)
{
return
JsonResult
.
buildSuccessResult
(
tkeService
.
deleteService
(
namespace
,
serviceName
));
}
}
src/main/java/cn/qg/holmes/entity/k8s/DockerProject.java
0 → 100644
View file @
43645596
package
cn
.
qg
.
holmes
.
entity
.
k8s
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
import
java.util.Date
;
@Data
@TableName
(
"docker_project"
)
public
class
DockerProject
{
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
private
String
projectName
;
private
String
projectType
;
private
String
gitPath
;
private
String
gitPathGroup
;
private
String
hostName
;
private
String
logPath
;
private
String
configPath
;
private
String
desc
;
private
String
owner
;
private
String
buildCommand
;
private
String
startCommand
;
private
String
stopCommand
;
private
String
deployToDocker
;
private
Integer
isActive
;
private
String
database
;
private
String
ddl
;
private
String
wiki
;
private
String
api
;
private
String
memLimit
;
private
String
menRequest
;
private
String
cpuLimit
;
private
String
cpuRequest
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
createTime
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
updateTime
;
}
src/main/java/cn/qg/holmes/entity/k8s/ServiceCreateVo.java
0 → 100644
View file @
43645596
package
cn
.
qg
.
holmes
.
entity
.
k8s
;
import
lombok.Data
;
/**
* 创建服务接口请求实体类
*/
@Data
public
class
ServiceCreateVo
{
private
Integer
debug
;
private
Integer
mock
;
private
String
domain
;
private
String
image
;
private
String
label
;
private
String
namespace
;
private
String
serviceName
;
private
String
type
;
private
Integer
wechat
;
private
String
cluster
;
}
src/main/java/cn/qg/holmes/service/k8s/ImageService.java
0 → 100644
View file @
43645596
package
cn
.
qg
.
holmes
.
service
.
k8s
;
import
com.tencentcloudapi.common.Credential
;
import
com.tencentcloudapi.common.profile.ClientProfile
;
import
com.tencentcloudapi.tcr.v20190924.TcrClient
;
import
com.tencentcloudapi.tcr.v20190924.models.DescribeImagePersonalRequest
;
import
com.tencentcloudapi.tcr.v20190924.models.DescribeImagePersonalResponse
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
/**
* 镜像仓库相关服务
* @author libo 2021
*/
@Slf4j
@Component
public
class
ImageService
{
private
TcrClient
tcrClient
;
public
ImageService
()
{
try
{
Credential
credential
=
new
Credential
(
"AKID4rY7wwNphsUcaFsy1pRtKhQvDj4CA3Ac"
,
"YBduRnjgVRGzmagZJbss3Vo58wWCyhgc"
);
ClientProfile
clientProfile
=
new
ClientProfile
();
clientProfile
.
setSignMethod
(
"HmacSHA256"
);
tcrClient
=
new
TcrClient
(
credential
,
"ap-beijing"
,
clientProfile
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
/**
* 根据服务名获取镜像列表
* @param serviceName 服务名
* @return
*/
public
String
getImageListByService
(
String
serviceName
)
{
try
{
String
repoName
=
"qa-test/"
+
serviceName
;
DescribeImagePersonalRequest
request
=
new
DescribeImagePersonalRequest
();
request
.
setRepoName
(
repoName
);
DescribeImagePersonalResponse
response
=
tcrClient
.
DescribeImagePersonal
(
request
);
return
DescribeImagePersonalResponse
.
toJsonString
(
response
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
public
static
void
main
(
String
[]
args
)
{
ImageService
imageService
=
new
ImageService
();
System
.
out
.
println
(
imageService
.
getImageListByService
(
"kdsp"
));
}
}
src/main/java/cn/qg/holmes/
utils/K8s
Service.java
→
src/main/java/cn/qg/holmes/
service/k8s/Tke
Service.java
View file @
43645596
This diff is collapsed.
Click to expand it.
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