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
83aa284d
Commit
83aa284d
authored
Apr 19, 2022
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
k8s controller全面优化
parent
6d85852e
Changes
30
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
1856 additions
and
398 deletions
+1856
-398
K8sController.java
src/main/java/cn/qg/holmes/controller/k8s/K8sController.java
+98
-339
K8sService.java
src/main/java/cn/qg/holmes/service/k8s/K8sService.java
+3
-59
TkeService.java
src/main/java/cn/qg/holmes/service/k8s/TkeService.java
+755
-0
DateUtils.java
src/main/java/cn/qg/holmes/utils/DateUtils.java
+17
-0
FileUtils.java
src/main/java/cn/qg/holmes/utils/FileUtils.java
+28
-0
TkeUtils.java
src/main/java/cn/qg/holmes/utils/TkeUtils.java
+75
-0
kube-config.yml
src/main/resources/tke/kube-config.yml
+0
-0
Ingress.yml
src/main/resources/tke/template/Ingress.yml
+17
-0
Java-Deployment.yml
src/main/resources/tke/template/Java-Deployment.yml
+91
-0
Java-Service.yml
src/main/resources/tke/template/Java-Service.yml
+20
-0
Kafka-Deployment.yml
src/main/resources/tke/template/Kafka-Deployment.yml
+50
-0
Kafka-Pvc.yml
src/main/resources/tke/template/Kafka-Pvc.yml
+11
-0
Kafka-Service.yml
src/main/resources/tke/template/Kafka-Service.yml
+17
-0
Mongodb-Deployment.yml
src/main/resources/tke/template/Mongodb-Deployment.yml
+79
-0
Mongodb-Pvc.yml
src/main/resources/tke/template/Mongodb-Pvc.yml
+12
-0
Mongodb-Service.yml
src/main/resources/tke/template/Mongodb-Service.yml
+16
-0
Mysql-Deployment.yml
src/main/resources/tke/template/Mysql-Deployment.yml
+85
-0
Mysql-Pvc.yml
src/main/resources/tke/template/Mysql-Pvc.yml
+12
-0
Mysql-Service.yml
src/main/resources/tke/template/Mysql-Service.yml
+14
-0
Rabbitmq-Deployment.yml
src/main/resources/tke/template/Rabbitmq-Deployment.yml
+68
-0
Rabbitmq-Pvc.yml
src/main/resources/tke/template/Rabbitmq-Pvc.yml
+12
-0
Rabbitmq-Service.yml
src/main/resources/tke/template/Rabbitmq-Service.yml
+19
-0
Redis-Deployment.yml
src/main/resources/tke/template/Redis-Deployment.yml
+140
-0
Redis-Service.yml
src/main/resources/tke/template/Redis-Service.yml
+23
-0
UI-Node-Deployment.yml
src/main/resources/tke/template/UI-Node-Deployment.yml
+80
-0
UI-Node-Service.yml
src/main/resources/tke/template/UI-Node-Service.yml
+14
-0
Zookeeper-Deployment.yml
src/main/resources/tke/template/Zookeeper-Deployment.yml
+73
-0
Zookeeper-Pvc.yml
src/main/resources/tke/template/Zookeeper-Pvc.yml
+12
-0
Zookeeper-Service.yml
src/main/resources/tke/template/Zookeeper-Service.yml
+15
-0
tke-cluster-ca.crt
src/main/resources/tke/tke-cluster-ca.crt
+0
-0
No files found.
src/main/java/cn/qg/holmes/controller/k8s/K8sController.java
View file @
83aa284d
This diff is collapsed.
Click to expand it.
src/main/java/cn/qg/holmes/service/k8s/K8sService.java
View file @
83aa284d
...
...
@@ -44,10 +44,10 @@ public class K8sService {
public
K8sService
()
{
try
{
String
configYAML
=
String
.
join
(
"\n"
,
readConfigFile
(
"kube-config.yml"
));
String
configYAML
=
String
.
join
(
"\n"
,
readConfigFile
(
"
tke/
kube-config.yml"
));
Config
config
=
Config
.
fromKubeconfig
(
configYAML
);
kubernetesClient
=
new
DefaultKubernetesClient
(
config
);
String
configCrt
=
String
.
join
(
"\n"
,
readConfigFile
(
"tke-cluster-ca.crt"
));
String
configCrt
=
String
.
join
(
"\n"
,
readConfigFile
(
"tke
/tke
-cluster-ca.crt"
));
config
.
setCaCertData
(
configCrt
);
log
.
info
(
"k8s连接初始化成功!"
);
}
catch
(
Exception
e
)
{
...
...
@@ -718,7 +718,7 @@ public class K8sService {
.
withPath
(
"/actuator/health/readiness"
)
.
withPort
(
httpPort
)
.
build
();
s
Probe
livenessProbe
=
new
ProbeBuilder
()
.
withHttpGet
(
httpGetAction
)
.
withInitialDelaySeconds
(
600
)
...
...
@@ -2735,62 +2735,6 @@ s
return
kubernetesClient
.
apps
().
deployments
().
inNamespace
(
namespace
).
withName
(
serviceName
).
get
();
}
/**
* 获取环境的所有k8s变量
*
* @param namespace 环境
*/
public
Map
<
String
,
Object
>
getListEnvVars
(
String
namespace
)
{
Map
<
String
,
Object
>
envMap
=
new
TreeMap
<>();
List
<
Pod
>
podList
=
kubernetesClient
.
pods
().
inNamespace
(
namespace
).
list
().
getItems
();
List
<
Service
>
serviceList
=
kubernetesClient
.
services
().
inNamespace
(
namespace
).
list
().
getItems
();
// 遍历Pod列表
for
(
Pod
pod
:
podList
)
{
if
(!
pod
.
getStatus
().
getPhase
().
equals
(
"Failed"
))
{
String
serviceName
=
pod
.
getMetadata
().
getLabels
().
get
(
"qcloud-app"
);
serviceName
=
serviceName
.
replace
(
"-"
,
"_"
).
toUpperCase
();
envMap
.
put
(
serviceName
+
"_SERVICE_HOST"
,
pod
.
getStatus
().
getHostIP
());
// MYSQL需要额外加个参数
if
(
serviceName
.
equals
(
"MYSQL"
))
{
envMap
.
put
(
"DB_SERVICE_HOST"
,
pod
.
getStatus
().
getHostIP
());
}
}
}
// 遍历Service列表
for
(
Service
service
:
serviceList
)
{
String
serviceName
=
service
.
getMetadata
().
getName
().
toUpperCase
().
replaceAll
(
"-"
,
"_"
);
List
<
ServicePort
>
servicePortList
=
service
.
getSpec
().
getPorts
();
if
(
service
.
getMetadata
().
getLabels
().
get
(
"type"
).
equals
(
"base"
))
{
if
(
servicePortList
.
get
(
0
).
getPort
()
!=
null
)
{
envMap
.
put
(
serviceName
+
"_SERVICE_PORT"
,
servicePortList
.
get
(
0
).
getNodePort
());
// MYSQL需要额外加个参数
if
(
serviceName
.
equals
(
"MYSQL"
))
{
envMap
.
put
(
"DB_SERVICE_PORT"
,
servicePortList
.
get
(
0
).
getNodePort
());
}
}
for
(
ServicePort
servicePort
:
servicePortList
)
{
envMap
.
put
(
serviceName
+
"_SERVICE_PORT_"
+
servicePort
.
getPort
(),
servicePort
.
getNodePort
());
// MYSQL需要额外加个参数
if
(
serviceName
.
equals
(
"MYSQL"
))
{
envMap
.
put
(
"DB_SERVICE_PORT_"
+
servicePort
.
getPort
(),
servicePort
.
getNodePort
());
}
}
}
else
{
if
(
servicePortList
.
get
(
0
).
getNodePort
()
!=
null
)
{
envMap
.
put
(
serviceName
+
"_SERVICE_PORT"
,
servicePortList
.
get
(
0
).
getNodePort
());
}
for
(
ServicePort
servicePort
:
servicePortList
)
{
if
(
service
.
getSpec
().
getType
().
equals
(
"NodePort"
))
{
envMap
.
put
(
serviceName
+
"_SERVICE_PORT_"
+
servicePort
.
getPort
(),
servicePort
.
getNodePort
());
}
else
if
(
service
.
getSpec
().
getType
().
equals
(
"ClusterIP"
))
{
envMap
.
put
(
serviceName
+
"_SERVICE_PORT_"
+
servicePort
.
getName
(),
servicePort
.
getPort
());
}
}
}
}
return
envMap
;
}
/**
* 删除namespace列表缓存
*/
...
...
src/main/java/cn/qg/holmes/service/k8s/TkeService.java
0 → 100644
View file @
83aa284d
This diff is collapsed.
Click to expand it.
src/main/java/cn/qg/holmes/utils/DateUtils.java
View file @
83aa284d
...
...
@@ -3,10 +3,12 @@ package cn.qg.holmes.utils;
import
org.apache.commons.lang3.time.FastDateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.*
;
import
java.time.format.DateTimeFormatter
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.TimeZone
;
/**
* 日期格式化工具类
...
...
@@ -34,6 +36,21 @@ public class DateUtils {
.
parse
(
date
);
}
/**
* 将带T和Z的字符串日期格式化
* @param tzDate
* @param pattern
* @return
* @throws ParseException
*/
public
static
String
convertTZStr
(
String
tzDate
,
String
pattern
)
throws
ParseException
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss'Z'"
);
simpleDateFormat
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"UTC"
));
return
FastDateFormat
.
getInstance
(
pattern
)
.
format
(
simpleDateFormat
.
parse
(
tzDate
));
}
public
static
long
betweenDays
(
Date
dateBefore
,
Date
dateAfter
)
{
return
Duration
.
between
(
toLocalDate
(
dateBefore
).
atStartOfDay
(),
toLocalDate
(
dateAfter
).
atStartOfDay
())
.
toDays
();
...
...
src/main/java/cn/qg/holmes/utils/FileUtils.java
0 → 100644
View file @
83aa284d
package
cn
.
qg
.
holmes
.
utils
;
import
org.springframework.core.io.ClassPathResource
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
FileUtils
{
/**
* 从resources目录下读取文件内容
* @param file 配置文件名
*/
public
static
String
readFileFromClassPathResource
(
String
file
)
throws
IOException
{
String
str
=
""
;
ClassPathResource
resource
=
new
ClassPathResource
(
file
);
InputStream
in
=
resource
.
getInputStream
();
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
in
));
List
<
String
>
result
=
new
ArrayList
<>();
while
((
str
=
br
.
readLine
())
!=
null
)
{
result
.
add
(
str
);
}
return
String
.
join
(
"\n"
,
result
);
}
}
src/main/java/cn/qg/holmes/utils/TkeUtils.java
0 → 100644
View file @
83aa284d
package
cn
.
qg
.
holmes
.
utils
;
import
cn.qg.holmes.entity.k8s.DockerProject
;
import
cn.qg.holmes.entity.k8s.ServiceCreateVo
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Objects
;
public
class
TkeUtils
{
/**
* 替换业务yaml文件
* @param sourceString
* @param serviceCreateVo
* @param dockerProject
* @return
*/
public
static
String
replaceBusinessYaml
(
String
sourceString
,
ServiceCreateVo
serviceCreateVo
,
DockerProject
dockerProject
)
{
if
(!
Objects
.
isNull
(
serviceCreateVo
))
{
sourceString
=
sourceString
.
replaceAll
(
"\\{\\{serviceName}}"
,
serviceCreateVo
.
getServiceName
());
sourceString
=
sourceString
.
replaceAll
(
"\\{\\{namespace}}"
,
serviceCreateVo
.
getNamespace
());
sourceString
=
sourceString
.
replaceAll
(
"\\{\\{mock}}"
,
String
.
valueOf
(
serviceCreateVo
.
getMock
()));
sourceString
=
sourceString
.
replaceAll
(
"\\{\\{debug}}"
,
String
.
valueOf
(
serviceCreateVo
.
getDebug
()));
sourceString
=
sourceString
.
replaceAll
(
"\\{\\{label}}"
,
serviceCreateVo
.
getLabel
());
sourceString
=
sourceString
.
replaceAll
(
"\\{\\{image}}"
,
serviceCreateVo
.
getImage
());
sourceString
=
sourceString
.
replaceAll
(
"\\{\\{domain}}"
,
serviceCreateVo
.
getDomain
());
sourceString
=
sourceString
.
replaceAll
(
"\\{\\{type}}"
,
serviceCreateVo
.
getType
());
}
if
(!
Objects
.
isNull
(
dockerProject
))
{
sourceString
=
sourceString
.
replaceAll
(
"\\{\\{resources.cpuRequest}}"
,
dockerProject
.
getCpuRequest
());
sourceString
=
sourceString
.
replaceAll
(
"\\{\\{resources.memRequest}}"
,
dockerProject
.
getMemRequest
());
sourceString
=
sourceString
.
replaceAll
(
"\\{\\{resources.cpuLimit}}"
,
dockerProject
.
getCpuLimit
());
sourceString
=
sourceString
.
replaceAll
(
"\\{\\{resources.memLimit}}"
,
dockerProject
.
getMemLimit
());
}
return
sourceString
;
}
/**
* 替换基础服务yaml文件
* @param sourceString
* @param serviceCreateVo
* @return
*/
public
static
String
replaceBasicYaml
(
String
sourceString
,
ServiceCreateVo
serviceCreateVo
)
{
String
namespace
=
serviceCreateVo
.
getNamespace
();
String
image
=
serviceCreateVo
.
getImage
();
if
(!
StringUtils
.
isEmpty
(
namespace
))
{
sourceString
=
sourceString
.
replaceAll
(
"\\{\\{namespace}}"
,
namespace
);
}
if
(!
StringUtils
.
isEmpty
(
image
))
{
sourceString
=
sourceString
.
replaceAll
(
"\\{\\{image}}"
,
image
);
}
return
sourceString
;
}
/**
* 字符串数组转Map
* @param strArray 字符串数组
* @return
*/
public
static
Map
<
String
,
String
>
StringArrayToMap
(
String
[]
strArray
)
{
// 字符串数组长度必须大于0且为偶数个
if
(
strArray
.
length
==
0
||
strArray
.
length
%
2
!=
0
)
{
return
null
;
}
Map
<
String
,
String
>
resultMap
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
strArray
.
length
;
i
=
i
+
2
)
{
resultMap
.
put
(
strArray
[
i
],
strArray
[
i
+
1
]);
}
return
resultMap
;
}
}
src/main/resources/kube-config.yml
→
src/main/resources/
tke/
kube-config.yml
View file @
83aa284d
File moved
src/main/resources/tke/template/Ingress.yml
0 → 100644
View file @
83aa284d
apiVersion
:
extensions/v1beta1
kind
:
Ingress
metadata
:
annotations
:
kubernetes.io/ingress.class
:
traefik
name
:
{{
serviceName
}}
namespace
:
{{
namespace
}}
spec
:
rules
:
-
host
:
{{
domain
}}
-{{namespace}}.xrtan.com
http
:
paths
:
-
backend
:
serviceName
:
{{
serviceName
}}
servicePort
:
80
path
:
/
pathType
:
ImplementationSpecific
\ No newline at end of file
src/main/resources/tke/template/Java-Deployment.yml
0 → 100644
View file @
83aa284d
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
name
:
{{
serviceName
}}
namespace
:
{{
namespace
}}
labels
:
type
:
{{
label
}}
qcloud-app
:
{{
serviceName
}}
spec
:
replicas
:
1
revisionHistoryLimit
:
1
selector
:
matchLabels
:
qcloud-app
:
{{
serviceName
}}
strategy
:
type
:
Recreate
template
:
metadata
:
labels
:
qcloud-app
:
{{
serviceName
}}
type
:
{{
label
}}
mock
:
{{
mock
}}
spec
:
terminationGracePeriodSeconds
:
0
containers
:
-
name
:
{{
serviceName
}}
image
:
ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy
:
IfNotPresent
# command: [ "/bin/bash", "-ce", "tail -f /dev/null" ]
# args: [ "while true; do sleep 30; done;" ]
volumeMounts
:
-
mountPath
:
/home/logs
name
:
filelog
env
:
-
name
:
NAMESPACE
value
:
{{
namespace
}}
-
name
:
SYSTEM_NAME
value
:
{{
serviceName
}}
-
name
:
HOSTS
value
:
192.168.4.50=>eos.quantgroups.com&172.17.1.7=>apollo-dev.quantgroups.com&172.20.3.11=>sentry.quantgroups.com&
-
name
:
DEBUG
value
:
{{
debug
}}
-
name
:
MOCK
value
:
{{
mock
}}
# - name: DUBBO_PORT_TO_BIND
# value: '80'
# - name: DUBBO_PORT_TO_REGISTRY
# value: '80'
-
name
:
DUBBO_IP_TO_REGISTRY
valueFrom
:
fieldRef
:
fieldPath
:
status.hostIP
resources
:
requests
:
cpu
:
{{
resources.cpuRequest
}}
m
memory
:
{{
resources.memRequest
}}
Mi
limits
:
cpu
:
{{
resources.cpuLimit
}}
m
memory
:
{{
resources.memLimit
}}
Mi
livenessProbe
:
exec
:
command
:
-
/home/quant_group/readyCheck.sh
# 启动延时,容器延时启动健康检查的时间
initialDelaySeconds
:
600
# 间隔时间,进行健康检查的时间间隔
periodSeconds
:
60
# 响应超时,每次健康检查响应的最大超时时间
timeoutSeconds
:
5
# 健康阈值,表示后端容器从失败到成功的连续健康检查成功次数
successThreshold
:
1
# 不健康阈值
failureThreshold
:
3
readinessProbe
:
exec
:
command
:
-
/home/quant_group/readyCheck.sh
initialDelaySeconds
:
15
timeoutSeconds
:
3
periodSeconds
:
10
successThreshold
:
1
failureThreshold
:
3
volumes
:
-
name
:
filelog
hostPath
:
path
:
/var/log/containers2/{{namespace}}/{{serviceName}}
restartPolicy
:
Always
dnsPolicy
:
ClusterFirst
imagePullSecrets
:
-
name
:
qcloudregistrykey
-
name
:
tencenthubkey
\ No newline at end of file
src/main/resources/tke/template/Java-Service.yml
0 → 100644
View file @
83aa284d
apiVersion
:
v1
kind
:
Service
metadata
:
labels
:
type
:
java
qcloud-app
:
{{
serviceName
}}
name
:
{{
serviceName
}}
namespace
:
{{
namespace
}}
spec
:
# 默认为ClusterIP
type
:
ClusterIP
ports
:
-
name
:
'
80'
port
:
80
-
name
:
'
5005'
port
:
5005
-
name
:
'
20880'
port
:
20880
selector
:
qcloud-app
:
{{
serviceName
}}
\ No newline at end of file
src/main/resources/tke/template/Kafka-Deployment.yml
0 → 100644
View file @
83aa284d
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
labels
:
type
:
base
qcloud-app
:
kafka
name
:
kafka
namespace
:
{{
namespace
}}
spec
:
replicas
:
1
selector
:
matchLabels
:
qcloud-app
:
kafka
template
:
metadata
:
labels
:
qcloud-app
:
kafka
type
:
base
spec
:
containers
:
-
name
:
kafka
image
:
ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy
:
IfNotPresent
ports
:
-
containerPort
:
9092
livenessProbe
:
tcpSocket
:
port
:
9092
env
:
-
name
:
KAFKA_ZOOKEEPER_CONNECT
value
:
{{
ZOOKEEPER_HOST
}}
:{{ZOOKEEPER_PORT}}/kafka
-
name
:
KAFKA_BROKER_ID
value
:
"
1"
-
name
:
KAFKA_ADVERTISED_LISTENERS
value
:
PLAINTEXT://172.17.5.5:{{KAFKA_SERVICE_PORT}}
-
name
:
KAFKA_LISTENERS
value
:
"
PLAINTEXT://0.0.0.0:9092"
-
name
:
KAFKA_ADVERTISED_PORT
value
:
"
30901"
-
name
:
KAFKA_ADVERTISED_HOST_NAME
valueFrom
:
fieldRef
:
fieldPath
:
status.hostIP
volumeMounts
:
-
name
:
datadir
mountPath
:
/var/lib/kafka
volumes
:
-
name
:
datadir
persistentVolumeClaim
:
claimName
:
kafka-{{namespace}}
\ No newline at end of file
src/main/resources/tke/template/Kafka-Pvc.yml
0 → 100644
View file @
83aa284d
apiVersion
:
v1
kind
:
PersistentVolumeClaim
metadata
:
name
:
kafka-{{namespace}}
namespace
:
{{
namespace
}}
spec
:
accessModes
:
-
ReadWriteOnce
resources
:
requests
:
storage
:
10Gi
\ No newline at end of file
src/main/resources/tke/template/Kafka-Service.yml
0 → 100644
View file @
83aa284d
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
kafka-{{namespace}}
namespace
:
{{
namespace
}}
labels
:
type
:
base
qcloud-app
:
kafka
spec
:
type
:
NodePort
ports
:
-
port
:
9092
name
:
kafka-9092-9092
targetPort
:
9092
protocol
:
TCP
selector
:
qcloud-app
:
kafka
\ No newline at end of file
src/main/resources/tke/template/Mongodb-Deployment.yml
0 → 100644
View file @
83aa284d
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
labels
:
qcloud-app
:
mongodb
type
:
base
name
:
mongodb
namespace
:
{{
namespace
}}
spec
:
replicas
:
1
revisionHistoryLimit
:
1
selector
:
matchLabels
:
qcloud-app
:
mongodb
strategy
:
type
:
Recreate
template
:
metadata
:
labels
:
qcloud-app
:
mongodb
type
:
base
spec
:
containers
:
-
env
:
-
name
:
MONGO_INITDB_ROOT_USERNAME
value
:
qa
-
name
:
MONGO_INITDB_ROOT_PASSWORD
value
:
qatest
image
:
ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy
:
Always
livenessProbe
:
exec
:
command
:
-
mongo
-
-uqa
-
-pqatest
-
admin
failureThreshold
:
3
initialDelaySeconds
:
100
periodSeconds
:
10
successThreshold
:
1
timeoutSeconds
:
1
name
:
mongodb
readinessProbe
:
exec
:
command
:
-
mongo
-
-uqa
-
-pqatest
-
admin
failureThreshold
:
3
initialDelaySeconds
:
5
periodSeconds
:
5
successThreshold
:
1
timeoutSeconds
:
1
resources
:
requests
:
cpu
:
256m
memory
:
256Mi
limits
:
cpu
:
512m
memory
:
512Mi
terminationMessagePath
:
/dev/termination-log
terminationMessagePolicy
:
File
volumeMounts
:
-
mountPath
:
/var/lib/mongo
name
:
mongodb
dnsPolicy
:
ClusterFirst
imagePullSecrets
:
-
name
:
qcloudregistrykey
-
name
:
tencenthubkey
restartPolicy
:
Always
schedulerName
:
default-scheduler
securityContext
:
{}
terminationGracePeriodSeconds
:
30
volumes
:
-
name
:
mongodb
persistentVolumeClaim
:
claimName
:
mongodb-{{namespace}}
\ No newline at end of file
src/main/resources/tke/template/Mongodb-Pvc.yml
0 → 100644
View file @
83aa284d
kind
:
PersistentVolumeClaim
apiVersion
:
v1
metadata
:
name
:
mongodb-{{namespace}}
namespace
:
{{
namespace
}}
spec
:
# storageClassName: cbs-3
accessModes
:
-
ReadWriteOnce
resources
:
requests
:
storage
:
10Gi
\ No newline at end of file
src/main/resources/tke/template/Mongodb-Service.yml
0 → 100644
View file @
83aa284d
apiVersion
:
v1
kind
:
Service
metadata
:
labels
:
qcloud-app
:
mongodb
type
:
base
name
:
mongodb
namespace
:
{{
namespace
}}
spec
:
ports
:
-
port
:
27017
selector
:
qcloud-app
:
mongodb
type
:
NodePort
status
:
loadBalancer
:
{}
src/main/resources/tke/template/Mysql-Deployment.yml
0 → 100644
View file @
83aa284d
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
labels
:
qcloud-app
:
mysql
type
:
base
name
:
mysql
namespace
:
{{
namespace
}}
spec
:
replicas
:
1
revisionHistoryLimit
:
1
selector
:
matchLabels
:
qcloud-app
:
mysql
strategy
:
type
:
Recreate
template
:
metadata
:
labels
:
qcloud-app
:
mysql
type
:
base
spec
:
containers
:
-
env
:
-
name
:
MYSQL_DATABASE
value
:
db
-
name
:
MYSQL_PASSWORD
value
:
qatest
-
name
:
MYSQL_ROOT_PASSWORD
value
:
Quantgroup2017
-
name
:
MYSQL_USER
value
:
qa
image
:
ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy
:
Always
livenessProbe
:
exec
:
command
:
-
mysql
-
-uqa
-
-pqatest
-
-e
-
SELECT
1
failureThreshold
:
3
initialDelaySeconds
:
100
periodSeconds
:
10
successThreshold
:
1
timeoutSeconds
:
1
name
:
mysql
readinessProbe
:
exec
:
command
:
-
mysql
-
-uqa
-
-pqatest
-
-e
-
SELECT
1
failureThreshold
:
3
initialDelaySeconds
:
5
periodSeconds
:
5
successThreshold
:
1
timeoutSeconds
:
1
resources
:
requests
:
cpu
:
200m
memory
:
200Mi
limits
:
cpu
:
2048m
memory
:
2Gi
terminationMessagePath
:
/dev/termination-log
terminationMessagePolicy
:
File
volumeMounts
:
-
mountPath
:
/var/lib/mysql
name
:
mysql
dnsPolicy
:
ClusterFirst
imagePullSecrets
:
-
name
:
qcloudregistrykey
-
name
:
tencenthubkey
restartPolicy
:
Always
schedulerName
:
default-scheduler
securityContext
:
{}
terminationGracePeriodSeconds
:
30
volumes
:
-
name
:
mysql
persistentVolumeClaim
:
claimName
:
mysql-{{namespace}}
\ No newline at end of file
src/main/resources/tke/template/Mysql-Pvc.yml
0 → 100644
View file @
83aa284d
apiVersion
:
v1
kind
:
PersistentVolumeClaim
metadata
:
name
:
mysql-{{namespace}}
namespace
:
{{
namespace
}}
spec
:
# storageClassName: cbs-3
accessModes
:
-
ReadWriteOnce
resources
:
requests
:
storage
:
50Gi
\ No newline at end of file
src/main/resources/tke/template/Mysql-Service.yml
0 → 100644
View file @
83aa284d
apiVersion
:
v1
kind
:
Service
metadata
:
labels
:
type
:
base
qcloud-app
:
mysql
name
:
mysql
namespace
:
{{
namespace
}}
spec
:
type
:
NodePort
ports
:
-
port
:
3306
selector
:
qcloud-app
:
mysql
\ No newline at end of file
src/main/resources/tke/template/Rabbitmq-Deployment.yml
0 → 100644
View file @
83aa284d
apiVersion
:
apps/v1beta1
kind
:
Deployment
metadata
:
labels
:
type
:
base
qcloud-app
:
rabbitmq
name
:
rabbitmq
namespace
:
{{
namespace
}}
spec
:
replicas
:
1
revisionHistoryLimit
:
1
selector
:
matchLabels
:
qcloud-app
:
rabbitmq
strategy
:
type
:
Recreate
template
:
metadata
:
labels
:
qcloud-app
:
rabbitmq
type
:
base
spec
:
# hostname固定,容器重置后数据持久化才能正常
hostname
:
rabbitmq-{{namespace}}
containers
:
-
image
:
ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy
:
IfNotPresent
name
:
rabbitmq
resources
:
requests
:
cpu
:
100m
memory
:
100Mi
limits
:
cpu
:
500m
memory
:
500Mi
env
:
-
name
:
RABBITMQ_DEFAULT_USER
value
:
qa
-
name
:
RABBITMQ_DEFAULT_PASS
value
:
qatest
livenessProbe
:
exec
:
command
:
-
/opt/readyCheck.sh
initialDelaySeconds
:
100
successThreshold
:
1
readinessProbe
:
exec
:
command
:
-
/opt/readyCheck.sh
initialDelaySeconds
:
30
timeoutSeconds
:
2
periodSeconds
:
5
successThreshold
:
1
# 数据持久化
volumeMounts
:
-
name
:
rabbitmq
mountPath
:
"
/var/lib/rabbitmq"
volumes
:
-
name
:
rabbitmq
persistentVolumeClaim
:
claimName
:
rabbitmq-{{namespace}}
imagePullSecrets
:
-
name
:
qcloudregistrykey
-
name
:
tencenthubkey
restartPolicy
:
Always
terminationGracePeriodSeconds
:
30
status
:
{}
\ No newline at end of file
src/main/resources/tke/template/Rabbitmq-Pvc.yml
0 → 100644
View file @
83aa284d
kind
:
PersistentVolumeClaim
apiVersion
:
v1
metadata
:
name
:
rabbitmq-{{namespace}}
namespace
:
{{
namespace
}}
spec
:
# storageClassName: cbs-3
accessModes
:
-
ReadWriteOnce
resources
:
requests
:
storage
:
20Gi
\ No newline at end of file
src/main/resources/tke/template/Rabbitmq-Service.yml
0 → 100644
View file @
83aa284d
apiVersion
:
v1
kind
:
Service
metadata
:
labels
:
type
:
base
qcloud-app
:
rabbitmq
name
:
rabbitmq
namespace
:
{{
namespace
}}
spec
:
type
:
NodePort
# 保留客户端源 IP 地址, 方便调试连接
# externalTrafficPolicy: Local
ports
:
-
name
:
tcp-5672-5672
port
:
5672
-
name
:
tcp-15672-15672
port
:
15672
selector
:
qcloud-app
:
rabbitmq
src/main/resources/tke/template/Redis-Deployment.yml
0 → 100644
View file @
83aa284d
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
labels
:
type
:
base
qcloud-app
:
redis
name
:
redis
namespace
:
{{
namespace
}}
spec
:
replicas
:
1
revisionHistoryLimit
:
1
selector
:
matchLabels
:
qcloud-app
:
redis
strategy
:
type
:
Recreate
template
:
metadata
:
labels
:
type
:
base
qcloud-app
:
redis
spec
:
containers
:
-
image
:
ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy
:
IfNotPresent
name
:
redis-6379
command
:
[
"
redis-server"
,
"
--port"
,
"
6379"
]
resources
:
requests
:
cpu
:
100m
memory
:
400Mi
limits
:
cpu
:
1000m
memory
:
4000Mi
livenessProbe
:
exec
:
command
:
[
"
redis-cli"
,
"
-p"
,
"
6379"
,
"
info"
]
initialDelaySeconds
:
100
successThreshold
:
1
readinessProbe
:
exec
:
command
:
[
"
redis-cli"
,
"
-p"
,
"
6379"
,
"
info"
]
initialDelaySeconds
:
5
timeoutSeconds
:
1
periodSeconds
:
5
-
image
:
ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy
:
IfNotPresent
name
:
redis-6380
command
:
[
"
redis-server"
,
"
--port"
,
"
6380"
]
resources
:
requests
:
cpu
:
100m
memory
:
200Mi
limits
:
cpu
:
512m
memory
:
1024Mi
livenessProbe
:
exec
:
command
:
[
"
redis-cli"
,
"
-p"
,
"
6380"
,
"
info"
]
initialDelaySeconds
:
100
successThreshold
:
1
readinessProbe
:
exec
:
command
:
[
"
redis-cli"
,
"
-p"
,
"
6380"
,
"
info"
]
initialDelaySeconds
:
5
timeoutSeconds
:
1
periodSeconds
:
5
-
image
:
ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy
:
IfNotPresent
name
:
redis-6381
command
:
[
"
redis-server"
,
"
--port"
,
"
6381"
]
resources
:
requests
:
cpu
:
100m
memory
:
100Mi
limits
:
cpu
:
200m
memory
:
200Mi
livenessProbe
:
exec
:
command
:
[
"
redis-cli"
,
"
-p"
,
"
6381"
,
"
info"
]
initialDelaySeconds
:
100
successThreshold
:
1
readinessProbe
:
exec
:
command
:
[
"
redis-cli"
,
"
-p"
,
"
6381"
,
"
info"
]
initialDelaySeconds
:
5
timeoutSeconds
:
1
periodSeconds
:
5
-
image
:
ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy
:
IfNotPresent
name
:
redis-6382
command
:
[
"
redis-server"
,
"
--port"
,
"
6382"
]
resources
:
requests
:
cpu
:
100m
memory
:
100Mi
limits
:
cpu
:
200m
memory
:
200Mi
livenessProbe
:
exec
:
command
:
[
"
redis-cli"
,
"
-p"
,
"
6382"
,
"
info"
]
initialDelaySeconds
:
100
successThreshold
:
1
readinessProbe
:
exec
:
command
:
[
"
redis-cli"
,
"
-p"
,
"
6382"
,
"
info"
]
initialDelaySeconds
:
5
timeoutSeconds
:
1
periodSeconds
:
5
-
image
:
ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy
:
IfNotPresent
name
:
redis-6383
command
:
[
"
redis-server"
,
"
--port"
,
"
6383"
]
resources
:
requests
:
cpu
:
100m
memory
:
100Mi
limits
:
cpu
:
200m
memory
:
200Mi
livenessProbe
:
exec
:
command
:
[
"
redis-cli"
,
"
-p"
,
"
6383"
,
"
info"
]
initialDelaySeconds
:
100
successThreshold
:
1
readinessProbe
:
exec
:
command
:
[
"
redis-cli"
,
"
-p"
,
"
6383"
,
"
info"
]
initialDelaySeconds
:
5
timeoutSeconds
:
1
periodSeconds
:
5
dnsPolicy
:
ClusterFirst
imagePullSecrets
:
-
name
:
qcloudregistrykey
-
name
:
tencenthubkey
restartPolicy
:
Always
terminationGracePeriodSeconds
:
30
status
:
{}
\ No newline at end of file
src/main/resources/tke/template/Redis-Service.yml
0 → 100644
View file @
83aa284d
apiVersion
:
v1
kind
:
Service
metadata
:
labels
:
type
:
base
qcloud-app
:
redis
name
:
redis
namespace
:
{{
namespace
}}
spec
:
type
:
NodePort
ports
:
-
name
:
'
6379'
port
:
6379
-
name
:
'
6380'
port
:
6380
-
name
:
'
6381'
port
:
6381
-
name
:
'
6382'
port
:
6382
-
name
:
'
6383'
port
:
6383
selector
:
qcloud-app
:
redis
\ No newline at end of file
src/main/resources/tke/template/UI-Node-Deployment.yml
0 → 100644
View file @
83aa284d
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
name
:
{{
serviceName
}}
namespace
:
{{
namespace
}}
labels
:
type
:
{{
label
}}
qcloud-app
:
{{
serviceName
}}
spec
:
replicas
:
1
revisionHistoryLimit
:
1
selector
:
matchLabels
:
qcloud-app
:
{{
serviceName
}}
strategy
:
type
:
Recreate
template
:
metadata
:
labels
:
qcloud-app
:
{{
serviceName
}}
type
:
{{
label
}}
spec
:
terminationGracePeriodSeconds
:
0
containers
:
-
name
:
{{
serviceName
}}
image
:
ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy
:
IfNotPresent
volumeMounts
:
-
mountPath
:
/home/logs
name
:
filelog
env
:
-
name
:
NAMESPACE
value
:
{{
namespace
}}
-
name
:
SYSTEM_NAME
value
:
{{
serviceName
}}
-
name
:
DEBUG
value
:
{{
debug
}}
-
name
:
HOSTS
value
:
192.168.4.50=>eos.quantgroups.com&172.17.1.7=>apollo-dev.quantgroups.com&172.20.3.11=>sentry.quantgroups.com&
-
name
:
NODE_ENV
value
:
test
resources
:
requests
:
cpu
:
{{
resources.cpuRequest
}}
m
memory
:
{{
resources.memRequest
}}
Mi
limits
:
cpu
:
{{
resources.cpuLimit
}}
m
memory
:
{{
resources.memLimit
}}
Mi
livenessProbe
:
exec
:
command
:
-
/home/quant_group/readyCheck.sh
# 启动延时,容器延时启动健康检查的时间
initialDelaySeconds
:
600
# 间隔时间,进行健康检查的时间间隔
periodSeconds
:
60
# 响应超时,每次健康检查响应的最大超时时间
timeoutSeconds
:
5
# 健康阈值,表示后端容器从失败到成功的连续健康检查成功次数
successThreshold
:
1
# 不健康阈值
failureThreshold
:
3
readinessProbe
:
exec
:
command
:
-
/home/quant_group/readyCheck.sh
initialDelaySeconds
:
15
timeoutSeconds
:
3
periodSeconds
:
10
successThreshold
:
1
failureThreshold
:
3
volumes
:
-
name
:
filelog
hostPath
:
path
:
/var/log/containers2/{{namespace}}/{{serviceName}}
restartPolicy
:
Always
dnsPolicy
:
ClusterFirst
imagePullSecrets
:
-
name
:
qcloudregistrykey
-
name
:
tencenthubkey
src/main/resources/tke/template/UI-Node-Service.yml
0 → 100644
View file @
83aa284d
apiVersion
:
v1
kind
:
Service
metadata
:
labels
:
type
:
{{
label
}}
qcloud-app
:
{{
serviceName
}}
name
:
{{
serviceName
}}
namespace
:
{{
namespace
}}
spec
:
type
:
ClusterIP
ports
:
-
port
:
80
selector
:
qcloud-app
:
{{
serviceName
}}
\ No newline at end of file
src/main/resources/tke/template/Zookeeper-Deployment.yml
0 → 100644
View file @
83aa284d
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
labels
:
qcloud-app
:
zookeeper
type
:
base
name
:
zookeeper
namespace
:
{{
namespace
}}
spec
:
replicas
:
1
revisionHistoryLimit
:
1
selector
:
matchLabels
:
qcloud-app
:
zookeeper
strategy
:
type
:
Recreate
template
:
metadata
:
labels
:
qcloud-app
:
zookeeper
type
:
base
name
:
zookeeper
namespace
:
{{
namespace
}}
spec
:
containers
:
-
env
:
-
name
:
ZOO_USER
value
:
zookeeper
image
:
ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy
:
Always
livenessProbe
:
exec
:
command
:
-
/zookeeper-3.4.13/readyCheck.sh
failureThreshold
:
3
initialDelaySeconds
:
100
periodSeconds
:
10
successThreshold
:
1
timeoutSeconds
:
1
name
:
zookeeper
readinessProbe
:
exec
:
command
:
-
/zookeeper-3.4.13/readyCheck.sh
failureThreshold
:
3
initialDelaySeconds
:
5
periodSeconds
:
5
successThreshold
:
1
timeoutSeconds
:
1
resources
:
requests
:
cpu
:
100m
memory
:
300Mi
limits
:
cpu
:
200m
memory
:
600Mi
terminationMessagePath
:
/dev/termination-log
terminationMessagePolicy
:
File
volumeMounts
:
-
mountPath
:
/var/lib/zookeeper
name
:
zookeeper
dnsPolicy
:
ClusterFirst
imagePullSecrets
:
-
name
:
qcloudregistrykey
-
name
:
tencenthubkey
restartPolicy
:
Always
schedulerName
:
default-scheduler
securityContext
:
{}
terminationGracePeriodSeconds
:
30
volumes
:
-
name
:
zookeeper
persistentVolumeClaim
:
claimName
:
zookeeper-{{namespace}}
\ No newline at end of file
src/main/resources/tke/template/Zookeeper-Pvc.yml
0 → 100644
View file @
83aa284d
kind
:
PersistentVolumeClaim
apiVersion
:
v1
metadata
:
name
:
zookeeper-{{namespace}}
namespace
:
{{
namespace
}}
spec
:
# storageClassName: cbs-3
accessModes
:
-
ReadWriteOnce
resources
:
requests
:
storage
:
10Gi
\ No newline at end of file
src/main/resources/tke/template/Zookeeper-Service.yml
0 → 100644
View file @
83aa284d
apiVersion
:
v1
kind
:
Service
metadata
:
labels
:
type
:
base
qcloud-app
:
zookeeper
name
:
zookeeper
namespace
:
{{
namespace
}}
spec
:
type
:
NodePort
ports
:
-
name
:
'
2181'
port
:
2181
selector
:
qcloud-app
:
zookeeper
\ No newline at end of file
src/main/resources/tke-cluster-ca.crt
→
src/main/resources/tke
/tke
-cluster-ca.crt
View file @
83aa284d
File moved
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