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
c9338b4e
Commit
c9338b4e
authored
Apr 09, 2019
by
xuezj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加wanIp
parent
e46e9bd9
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
128 additions
and
54 deletions
+128
-54
service.js
app/service.js
+18
-11
package-lock.json
package-lock.json
+40
-9
package.json
package.json
+1
-0
lruCache.service.js
services/lruCache.service.js
+3
-0
tke.clusterService.js
services/tke.clusterService.js
+4
-0
mongo.sts.yaml
yamls/mongo.sts.yaml
+0
-0
mysql.sts.yaml
yamls/mysql.sts.yaml
+0
-34
mysql.yaml
yamls/mysql.yaml
+62
-0
No files found.
app/service.js
View file @
c9338b4e
const
Router
=
require
(
'
koa-router
'
)
const
yaml
=
require
(
'
js-yaml
'
)
const
_
=
require
(
'
lodash
'
)
const
logger
=
require
(
'
koa-log4
'
).
getLogger
()
const
templates
=
require
(
'
../serviceTemplate
'
)
const
lruCache
=
require
(
'
../services/lruCache.service
'
)
const
{
ingressCreate
,
ingressDelete
}
=
require
(
'
../kubeService/ingress
'
)
const
router
=
new
Router
()
module
.
exports
=
router
router
.
get
(
'
/
'
,
async
(
ctx
)
=>
{
// 取节点列表的第一个作为服务的访问ip
const
cacheKey
=
'
k8s.nodes.first
'
let
c
=
lruCache
.
get
(
cacheKey
)
let
wanIp
=
lruCache
.
get
(
cacheKey
)
if
(
!
c
)
{
const
res
=
await
ctx
.
cluster
.
node_list
()
wanIp
=
_
.
get
(
res
,
'
nodes[0].wanIp
'
,
''
)
lruCache
.
set
(
cacheKey
,
wanIp
)
}
const
data
=
await
ctx
.
cluster
.
service_list
(
ctx
.
query
.
namespace
)
const
getDetail
=
async
(
item
)
=>
{
const
detaildata
=
await
ctx
.
cluster
.
service_get
(
item
.
serviceName
,
ctx
.
query
.
namespace
)
return
detaildata
let
resData
=
await
ctx
.
cluster
.
service_get
(
item
.
serviceName
,
ctx
.
query
.
namespace
)
item
.
portMappings
=
resData
.
service
.
portMappings
item
.
image
=
resData
.
service
.
containers
[
0
].
image
item
.
wanIp
=
wanIp
return
}
const
task
=
[]
for
(
let
i
=
0
;
i
<
data
.
services
.
length
;
i
+=
1
)
{
...
...
@@ -20,15 +35,7 @@ router.get('/', async (ctx) => {
task
.
push
(
getDetail
(
data
.
services
[
i
]))
}
}
const
result
=
await
Promise
.
all
(
task
)
for
(
let
i
=
0
;
i
<
data
.
services
.
length
;
i
+=
1
)
{
for
(
let
j
=
0
;
j
<
result
.
length
;
j
+=
1
)
{
if
(
data
.
services
[
i
].
serviceName
===
result
[
j
].
service
.
serviceName
)
{
data
.
services
[
i
].
portMappings
=
result
[
j
].
service
.
portMappings
data
.
services
[
i
].
image
=
result
[
j
].
service
.
containers
[
0
].
image
}
}
}
await
Promise
.
all
(
task
)
ctx
.
body
=
ctx
.
ok
(
data
)
})
...
...
package-lock.json
View file @
c9338b4e
...
...
@@ -670,6 +670,24 @@
"lru-cache"
:
"^4.0.1"
,
"shebang-command"
:
"^1.2.0"
,
"which"
:
"^1.2.9"
},
"dependencies"
:
{
"lru-cache"
:
{
"version"
:
"4.1.5"
,
"resolved"
:
"http://npmprivate.quantgroups.com/lru-cache/-/lru-cache-4.1.5.tgz"
,
"integrity"
:
"sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g=="
,
"dev"
:
true
,
"requires"
:
{
"pseudomap"
:
"^1.0.2"
,
"yallist"
:
"^2.1.2"
}
},
"yallist"
:
{
"version"
:
"2.1.2"
,
"resolved"
:
"http://npmprivate.quantgroups.com/yallist/-/yallist-2.1.2.tgz"
,
"integrity"
:
"sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI="
,
"dev"
:
true
}
}
},
"crypto-random-string"
:
{
...
...
@@ -2955,12 +2973,11 @@
"integrity"
:
"sha1-b54wtHCE2XGnyCD/FabFFnt0wm8="
},
"lru-cache"
:
{
"version"
:
"
4.1.5
"
,
"resolved"
:
"http://
registry.npm.taobao.org/lru-cache/download/lru-cache-4.1.5
.tgz"
,
"integrity"
:
"sha
1-i75Q6oW+1ZvJ4z3KuCNe6bz0Q80
="
,
"version"
:
"
5.1.1
"
,
"resolved"
:
"http://
npmprivate.quantgroups.com/lru-cache/-/lru-cache-5.1.1
.tgz"
,
"integrity"
:
"sha
512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w=
="
,
"requires"
:
{
"pseudomap"
:
"^1.0.2"
,
"yallist"
:
"^2.1.2"
"yallist"
:
"^3.0.2"
}
},
"make-dir"
:
{
...
...
@@ -3402,6 +3419,15 @@
"url-to-options"
:
"^1.0.1"
}
},
"lru-cache"
:
{
"version"
:
"4.1.5"
,
"resolved"
:
"http://npmprivate.quantgroups.com/lru-cache/-/lru-cache-4.1.5.tgz"
,
"integrity"
:
"sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g=="
,
"requires"
:
{
"pseudomap"
:
"^1.0.2"
,
"yallist"
:
"^2.1.2"
}
},
"prepend-http"
:
{
"version"
:
"2.0.0"
,
"resolved"
:
"http://npmprivate.quantgroups.com/prepend-http/-/prepend-http-2.0.0.tgz"
,
...
...
@@ -3414,6 +3440,11 @@
"requires"
:
{
"prepend-http"
:
"^2.0.0"
}
},
"yallist"
:
{
"version"
:
"2.1.2"
,
"resolved"
:
"http://npmprivate.quantgroups.com/yallist/-/yallist-2.1.2.tgz"
,
"integrity"
:
"sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI="
}
}
},
...
...
@@ -3652,7 +3683,7 @@
},
"pseudomap"
:
{
"version"
:
"1.0.2"
,
"resolved"
:
"http://
registry.npm.taobao.org/pseudomap/download
/pseudomap-1.0.2.tgz"
,
"resolved"
:
"http://
npmprivate.quantgroups.com/pseudomap/-
/pseudomap-1.0.2.tgz"
,
"integrity"
:
"sha1-8FKijacOYYkX7wqKw0wa5aaChrM="
},
"psl"
:
{
...
...
@@ -4827,9 +4858,9 @@
"dev"
:
true
},
"yallist"
:
{
"version"
:
"
2.1.2
"
,
"resolved"
:
"http://
registry.npm.taobao.org/yallist/download/yallist-2.1.2
.tgz"
,
"integrity"
:
"sha
1-HBH5IY8HYImkfdUS+TxmmaaoHVI
="
"version"
:
"
3.0.3
"
,
"resolved"
:
"http://
npmprivate.quantgroups.com/yallist/-/yallist-3.0.3
.tgz"
,
"integrity"
:
"sha
512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A=
="
},
"ylru"
:
{
"version"
:
"1.2.1"
,
...
...
package.json
View file @
c9338b4e
...
...
@@ -12,6 +12,7 @@
"
kubernetes-client
"
:
"
^6.3.2
"
,
"
lodash
"
:
"
^4.17.11
"
,
"
log4js
"
:
"
^4.0.2
"
,
"
lru-cache
"
:
"
^5.1.1
"
,
"
request
"
:
"
^2.88.0
"
},
"devDependencies"
:
{
...
...
services/lruCache.service.js
0 → 100644
View file @
c9338b4e
const
LRU
=
require
(
'
lru-cache
'
)
const
cache
=
new
LRU
(
50
)
module
.
exports
=
cache
services/tke.clusterService.js
View file @
c9338b4e
...
...
@@ -90,6 +90,10 @@ class Cluster extends Client {
rules
.
clusterId
=
this
.
clusterId
return
this
.
post
(
'
MosifyIngress
'
,
rules
)
}
node_list
(
limit
=
1
)
{
return
this
.
post
(
'
DescribeClusterInstances
'
,
{
limit
,
clusterId
:
this
.
clusterId
})
}
}
exports
.
create
=
function
()
{
...
...
yamls/mongo.yaml
→
yamls/mongo.
sts.
yaml
View file @
c9338b4e
File moved
yamls/mysql.sts.yaml
deleted
100644 → 0
View file @
e46e9bd9
---
apiVersion
:
extensions/v1beta1
kind
:
Deployment
metadata
:
labels
:
app
:
redis
type
:
base
name
:
redis
spec
:
replicas
:
1
revisionHistoryLimit
:
3
strategy
:
{}
template
:
metadata
:
labels
:
app
:
redis
tier
:
common
spec
:
containers
:
-
image
:
192.168.4.4/common/redis:multiport
name
:
redis
# resources:
# limits:
# memory: 256Mi
# requests:
# memory: 64Mi
ports
:
-
containerPort
:
6379
-
containerPort
:
6380
-
containerPort
:
6381
-
containerPort
:
6382
-
containerPort
:
6383
restartPolicy
:
Always
status
:
{}
yamls/mysql.yaml
0 → 100644
View file @
c9338b4e
apiVersion
:
extensions/v1beta1
kind
:
Deployment
metadata
:
labels
:
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
:
400Mi
cpu
:
100m
limits
:
memory
:
1024Mi
cpu
:
500m
securityContext
:
privileged
:
false
terminationMessagePath
:
/dev/termination-log
dnsPolicy
:
ClusterFirst
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
:
3306
nodePort
:
0
port
:
3306
protocol
:
TCP
targetPort
:
3306
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