Commit d00d90da authored by xuezj's avatar xuezj

修复更新、删除服务失败问题

parent 2da84211
...@@ -7,6 +7,7 @@ module.exports = { ...@@ -7,6 +7,7 @@ module.exports = {
protocal: 'https://', protocal: 'https://',
clusterPoint: 'ccs.api.qcloud.com', // 访问集群以及服务的域名 clusterPoint: 'ccs.api.qcloud.com', // 访问集群以及服务的域名
containerPoint: 'ccr.api.qcloud.com', // 访问镜像仓库的域名 containerPoint: 'ccr.api.qcloud.com', // 访问镜像仓库的域名
imageDomain: 'ccr.ccs.tencentyun.com',
path: '/v2/index.php', path: '/v2/index.php',
domain: '.lkbang.com', domain: '.lkbang.com',
......
const path = require('path') const path = require('path')
const Client = require('kubernetes-client').Client const Client = require('kubernetes-client').Client
const config = require('kubernetes-client').config const config = require('kubernetes-client').config
const logger = require('koa-log4').getLogger()
// const client = new Client({ config: config.fromKubeconfig(), version: '1.9' }) // const client = new Client({ config: config.fromKubeconfig(), version: '1.9' })
...@@ -41,18 +42,22 @@ const getManifest = (namespace, servicename, doamin) => ({ ...@@ -41,18 +42,22 @@ const getManifest = (namespace, servicename, doamin) => ({
}) })
const ingressGet = async (namespace, servicename) => client.apis.extensions.v1beta1.namespaces(namespace) const ingressGet = async (namespace, servicename) => client.apis.extensions.v1beta1.namespaces(namespace)
.ingresses(servicename).get() .ingresses(servicename).get()
const ingressCreate = async (namespace, servicename, doamin) => { const ingressCreate = async (namespace, servicename, doamin) => {
const Manifest = getManifest(namespace, servicename, doamin) const Manifest = getManifest(namespace, servicename, doamin)
logger.info('创建ingress', Manifest)
await client.apis.extensions.v1beta1.namespace(namespace).ingresses await client.apis.extensions.v1beta1.namespace(namespace).ingresses
.post({ body: Manifest }) .post({ body: Manifest })
} }
const ingressUpdate = async (namespace, servicename, host) => { const ingressUpdate = async (namespace, servicename, host) => {
const Manifest = getManifest(namespace, servicename) const Manifest = getManifest(namespace, servicename)
Manifest.spec.rules[0].host = host Manifest.spec.rules[0].host = host
logger.info('更新ingress', Manifest)
await client.apis.extensions.v1beta1.namespace(namespace).ingresses(servicename) await client.apis.extensions.v1beta1.namespace(namespace).ingresses(servicename)
.patch({ body: Manifest }) .patch({ body: Manifest })
} }
const ingressDelete = async (namespace, servicename) => { const ingressDelete = async (namespace, servicename) => {
logger.info('删除ingress', namespace, servicename)
await client.apis.extensions.v1beta1.namespaces(namespace).ingresses(servicename).delete() await client.apis.extensions.v1beta1.namespaces(namespace).ingresses(servicename).delete()
} }
module.exports = { module.exports = {
......
...@@ -7,6 +7,7 @@ class Cluster extends Client { ...@@ -7,6 +7,7 @@ class Cluster extends Client {
constructor() { constructor() {
super(); super();
this.endpoint = domainConfig.clusterPoint this.endpoint = domainConfig.clusterPoint
this.imageDomain = domainConfig.imageDomain
} }
namespace_get() { namespace_get() {
...@@ -54,7 +55,9 @@ class Cluster extends Client { ...@@ -54,7 +55,9 @@ class Cluster extends Client {
service_modifyImage(serviceName, image, namespace) { service_modifyImage(serviceName, image, namespace) {
return this.post('ModifyClusterServiceImage', { return this.post('ModifyClusterServiceImage', {
serviceName, namespace, image, clusterId: this.clusterId, serviceName, namespace,
image: this.imageDomain + '/' + image,
clusterId: this.clusterId,
}) })
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment