Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tke-eos
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
tke-eos
Commits
3847df41
Commit
3847df41
authored
May 20, 2019
by
智勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
base pvc
parent
972107c1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
221 additions
and
48 deletions
+221
-48
service.js
app/service.js
+1
-1
service.js
kubeService/service.js
+3
-1
index.js
yamls/index.js
+7
-1
mysql.pvc.yaml
yamls/mysql.pvc.yaml
+5
-7
rabbitmq.pvc.yaml
yamls/rabbitmq.pvc.yaml
+28
-38
redis.pvc.yaml
yamls/redis.pvc.yaml
+90
-0
zookeeper.pvc.yaml
yamls/zookeeper.pvc.yaml
+87
-0
No files found.
app/service.js
View file @
3847df41
...
...
@@ -50,7 +50,7 @@ const createService = async (ctx) => {
type
,
serviceName
,
namespace
,
image
,
system_name
,
domain
,
label
,
}
=
ctx
.
request
.
body
logger
.
info
(
'
创建服务
'
,
ctx
.
request
.
body
)
if
(
serviceName
===
'
mysql
'
)
{
if
(
label
===
'
base
'
)
{
await
serviceCreate
(
namespace
,
serviceName
,
image
,
label
)
ctx
.
body
=
ctx
.
ok
(
'
创建成功
'
)
return
...
...
kubeService/service.js
View file @
3847df41
...
...
@@ -21,6 +21,8 @@ const serviceCreate = async (namespace, serviceName, image) => {
app
:
serviceName
,
image
,
}
const
pvcName
=
`
${
serviceName
}
-
${
namespace
}
`
const
yamlManifest
=
yamls
[
serviceName
].
replace
(
/{{
([
A-Za-z0-9_
\.]
+
)
}}/g
,
function
()
{
if
(
_
.
get
(
data
,
arguments
[
1
],
null
)
===
null
)
{
throw
new
Error
(
`缺少模板所需变量:
${
arguments
[
1
]}
`
)
...
...
@@ -45,7 +47,7 @@ const serviceCreate = async (namespace, serviceName, image) => {
case
'
PersistentVolumeClaim
'
:
pvc
=
await
client
.
api
.
v1
.
namespaces
(
namespace
).
persistentvolumeclaims
.
get
()
pvc
=
pvc
.
body
.
items
.
filter
(
item
=>
item
.
metadata
.
name
===
service
Name
)
pvc
=
pvc
.
body
.
items
.
filter
(
item
=>
item
.
metadata
.
name
===
pvc
Name
)
if
(
!
pvc
.
length
)
{
await
client
.
api
.
v1
.
namespaces
(
namespace
).
persistentvolumeclaims
.
post
({
body
:
jsonObj
})
}
...
...
yamls/index.js
View file @
3847df41
const
fs
=
require
(
'
fs
'
)
const
mysql
=
fs
.
readFileSync
(
'
yamls/mysql.yaml
'
,
'
utf8
'
)
const
mysql
=
fs
.
readFileSync
(
'
yamls/mysql.pvc.yaml
'
,
'
utf8
'
)
const
redis
=
fs
.
readFileSync
(
'
yamls/redis.pvc.yaml
'
,
'
utf8
'
)
const
rabbitmq
=
fs
.
readFileSync
(
'
yamls/rabbitmq.pvc.yaml
'
,
'
utf8
'
)
const
zookeeper
=
fs
.
readFileSync
(
'
yamls/zookeeper.pvc.yaml
'
,
'
utf8
'
)
module
.
exports
=
{
mysql
,
redis
,
rabbitmq
,
zookeeper
,
}
yamls/mysql.yaml
→
yamls/mysql.
pvc.
yaml
View file @
3847df41
kind
:
PersistentVolumeClaim
apiVersion
:
v1
metadata
:
name
:
{{
app
}}
name
:
{{
app
}}
-{{namespace}}
namespace
:
{{
namespace
}}
spec
:
storageClassName
:
cbs
...
...
@@ -55,12 +55,12 @@ spec:
-
name
:
MYSQL_USER
value
:
qa
volumeMounts
:
-
mountPath
:
"
/
data
/mysql"
name
:
mysql
-
mountPath
:
"
/
var/lib
/mysql"
name
:
{{
app
}}
volumes
:
-
name
:
mysql
-
name
:
{{
app
}}
persistentVolumeClaim
:
claimName
:
mysql
claimName
:
{{
app
}}
-{{namespace}}
imagePullSecrets
:
-
name
:
qcloudregistrykey
-
name
:
tencenthubkey
...
...
@@ -81,9 +81,7 @@ spec:
type
:
NodePort
ports
:
-
name
:
'
3306'
nodePort
:
0
port
:
3306
protocol
:
TCP
targetPort
:
3306
selector
:
qcloud-app
:
{{
app
}}
yamls/rabbitmq.pvc.yaml
View file @
3847df41
kind
:
PersistentVolumeClaim
apiVersion
:
v1
metadata
:
name
:
pvc-rabbitmq-test1-db
namespace
:
test1
name
:
{{
app
}}
-{{namespace}}
namespace
:
{{
namespace
}}
spec
:
storageClassName
:
cbs
accessModes
:
...
...
@@ -13,32 +12,32 @@ spec:
storage
:
10Gi
---
apiVersion
:
extensions/v1beta1
apiVersion
:
apps/v1beta1
kind
:
Deployment
metadata
:
labels
:
qcloud-app
:
rabbitmq
name
:
rabbitmq
namespace
:
test1
type
:
base
qcloud-app
:
{{
app
}}
name
:
{{
app
}}
namespace
:
{{
namespace
}}
spec
:
replicas
:
1
revisionHistoryLimit
:
1
selector
:
matchLabels
:
qcloud-app
:
rabbitmq
qcloud-app
:
{{
app
}}
strategy
:
type
:
Recreate
template
:
metadata
:
labels
:
qcloud-app
:
rabbitmq
qcloud-app
:
{{
app
}}
spec
:
# hostname固定,容器重置后数据持久化才能正常
hostname
:
rabbitmq-test1
containers
:
-
image
:
ccr.ccs.tencentyun.com/
qa-base/rabbitmq:3.6
imagePullPolicy
:
IfNotPresent
name
:
rabbitmq
-
image
:
ccr.ccs.tencentyun.com/
{{image}}
imagePullPolicy
:
Always
name
:
{{
app
}}
resources
:
requests
:
memory
:
100Mi
...
...
@@ -46,19 +45,18 @@ spec:
limits
:
memory
:
500Mi
cpu
:
500m
env
:
-
name
:
RABBITMQ_DEFAULT_USER
value
:
qa
-
name
:
RABBITMQ_DEFAULT_PASS
value
:
qatest
# 数据持久化
volumeMounts
:
-
name
:
db
mountPath
:
"
/var/lib/rabbitmq"
-
mountPath
:
"
/var/lib/rabbitmq"
name
:
{{
app
}}
env
:
-
name
:
RABBITMQ_DEFAULT_USER
value
:
qa
-
name
:
RABBITMQ_DEFAULT_PASS
value
:
qatest
volumes
:
-
name
:
db
persistentVolumeClaim
:
claimName
:
pvc-rabbitmq-test1-db
-
name
:
{{
app
}}
persistentVolumeClaim
:
claimName
:
{{
app
}}
-{{namespace}}
imagePullSecrets
:
-
name
:
qcloudregistrykey
-
name
:
tencenthubkey
...
...
@@ -72,25 +70,17 @@ kind: Service
metadata
:
labels
:
type
:
base
qcloud-app
:
rabbitmq
name
:
rabbitmq
namespace
:
test1
qcloud-app
:
{{
app
}}
name
:
{{
app
}}
namespace
:
{{
namespace
}}
spec
:
type
:
NodePort
# 保留客户端源 IP 地址, 方便调试连接
externalTrafficPolicy
:
Local
selector
:
qcloud-app
:
rabbitmq
ports
:
-
name
:
tcp-5672-5672
nodePort
:
0
port
:
5672
protocol
:
TCP
targetPort
:
5672
-
name
:
tcp-15672-15672
nodePort
:
0
port
:
15672
protocol
:
TCP
targetPort
:
15672
selector
:
qcloud-app
:
{{
app
}}
yamls/redis.pvc.yaml
0 → 100644
View file @
3847df41
kind
:
PersistentVolumeClaim
apiVersion
:
v1
metadata
:
name
:
{{
app
}}
-{{namespace}}
namespace
:
{{
namespace
}}
spec
:
storageClassName
:
cbs
accessModes
:
-
ReadWriteOnce
resources
:
requests
:
storage
:
10Gi
---
apiVersion
:
apps/v1beta1
kind
:
Deployment
metadata
:
labels
:
type
:
base
qcloud-app
:
{{
app
}}
name
:
{{
app
}}
namespace
:
{{
namespace
}}
spec
:
replicas
:
1
revisionHistoryLimit
:
1
selector
:
matchLabels
:
qcloud-app
:
{{
app
}}
strategy
:
type
:
Recreate
template
:
metadata
:
labels
:
qcloud-app
:
{{
app
}}
spec
:
containers
:
-
image
:
ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy
:
Always
name
:
{{
app
}}
resources
:
requests
:
memory
:
40Mi
cpu
:
100m
limits
:
memory
:
500Mi
cpu
:
500m
volumeMounts
:
-
mountPath
:
"
/data"
name
:
{{
app
}}
volumes
:
-
name
:
{{
app
}}
persistentVolumeClaim
:
claimName
:
{{
app
}}
-{{namespace}}
imagePullSecrets
:
-
name
:
qcloudregistrykey
-
name
:
tencenthubkey
restartPolicy
:
Always
terminationGracePeriodSeconds
:
30
status
:
{}
---
apiVersion
:
v1
kind
:
Service
metadata
:
labels
:
type
:
base
qcloud-app
:
{{
app
}}
name
:
{{
app
}}
namespace
:
{{
namespace
}}
spec
:
type
:
NodePort
ports
:
-
name
:
'
6379'
port
:
6379
targetPort
:
6379
-
name
:
'
6380'
port
:
6380
targetPort
:
6380
-
name
:
'
6381'
port
:
6381
targetPort
:
6381
-
name
:
'
6382'
port
:
6382
targetPort
:
6382
-
name
:
'
6383'
port
:
6383
targetPort
:
6383
selector
:
qcloud-app
:
{{
app
}}
yamls/zookeeper.pvc.yaml
0 → 100644
View file @
3847df41
kind
:
PersistentVolumeClaim
apiVersion
:
v1
metadata
:
name
:
{{
app
}}
-{{namespace}}
namespace
:
{{
namespace
}}
spec
:
storageClassName
:
cbs
accessModes
:
-
ReadWriteOnce
resources
:
requests
:
storage
:
10Gi
---
apiVersion
:
apps/v1beta1
kind
:
Deployment
metadata
:
labels
:
type
:
base
qcloud-app
:
{{
app
}}
name
:
{{
app
}}
namespace
:
{{
namespace
}}
spec
:
replicas
:
1
revisionHistoryLimit
:
1
selector
:
matchLabels
:
qcloud-app
:
{{
app
}}
strategy
:
type
:
Recreate
template
:
metadata
:
labels
:
qcloud-app
:
{{
app
}}
spec
:
containers
:
-
image
:
ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy
:
Always
name
:
{{
app
}}
resources
:
requests
:
memory
:
100Mi
cpu
:
100m
limits
:
memory
:
500Mi
cpu
:
500m
volumeMounts
:
-
mountPath
:
"
/var/lib/zookeeper"
name
:
{{
app
}}
env
:
-
name
:
ZOO_USER
value
:
zookeeper
# - name: ZOO_PORT
# value: 2181
volumes
:
-
name
:
{{
app
}}
persistentVolumeClaim
:
claimName
:
{{
app
}}
-{{namespace}}
imagePullSecrets
:
-
name
:
qcloudregistrykey
-
name
:
tencenthubkey
restartPolicy
:
Always
terminationGracePeriodSeconds
:
30
status
:
{}
---
apiVersion
:
v1
kind
:
Service
metadata
:
labels
:
type
:
base
qcloud-app
:
{{
app
}}
name
:
{{
app
}}
namespace
:
{{
namespace
}}
spec
:
type
:
NodePort
ports
:
-
name
:
tcp-2181
port
:
2181
targetPort
:
2181
-
name
:
tcp-9090
port
:
9090
targetPort
:
9090
selector
:
qcloud-app
:
{{
app
}}
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