Commit 17e38865 authored by Quang-Nhat HOANG-XUAN's avatar Quang-Nhat HOANG-XUAN Committed by GitHub

Merge pull request #75 from DistributedSystemsGroup/bugfix-kube-ci

Bugfix kube ci
parents 5fb5f6ce 3fc6b71b
......@@ -21,12 +21,12 @@ import time
import yaml
import docker
from utils.DockerContainerParameter import DockerContainerParameter
from utils.docker_container_parameter import DockerContainerParameter
class ZoeBackendDeploy():
def __init__(self, dockerUrl, dockerComposePath):
self.cli = docker.DockerClient(base_url=dockerUrl)
def __init__(self, dockerUrl, dockerComposePath, dockerVersion):
self.cli = docker.DockerClient(base_url=dockerUrl, version=dockerVersion)
self.zoe_api = ''
self.zoe_master = ''
self.zoe_opts = []
......@@ -164,6 +164,8 @@ class ZoeBackendDeploy():
# start zoe_api
api_c = self.cli.containers.get(self.zoe_api)
api_c.start()
time.sleep(5)
api_c = self.cli.containers.get(self.zoe_api)
print('Started latest ' + self.zoe_api + ' container...')
if not api_c.attrs['State']['Running']:
retcode = -1
......@@ -173,6 +175,8 @@ class ZoeBackendDeploy():
# start zoe_master
master_c = self.cli.containers.get(self.zoe_master)
master_c.start()
time.sleep(5)
master_c = self.cli.containers.get(self.zoe_master)
print('Started latest ' + self.zoe_master + ' container...')
if not master_c.attrs['State']['Running']:
retcode = 0
......
......@@ -21,12 +21,12 @@ import docker
class ZoeFrontendDeploy():
def __init__(self, dockerUrl, apache2):
def __init__(self, dockerUrl, apache2, dockerVersion):
self.src = 'prod.tar'
self.srcBackup = 'backup.tar'
self.dst = '/var/www/'
self.dstBackup = '/var/www/prod'
self.cli = docker.DockerClient(base_url=dockerUrl)
self.cli = docker.DockerClient(base_url=dockerUrl, version=dockerVersion)
self.apache2 = apache2
return
......
version: '2'
services:
zoe-api:
image: hxquangnhat/zoe:k8s-0.2
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /media/sdb/kubernetes/data/config:/opt/zoe/kube.conf
command: python3 zoe-api.py --debug --backend Kubernetes --deployment-name prod --dbuser postgres --dbhost 192.168.12.2 --dbport 5432 --dbname postgres --dbpass postgres --master-url tcp://zoe-master:4850 --auth-type text --proxy-type none --proxy-path zoe.fsdna.on.kpmg.de --listen-port 5001
ports:
- "5001:5001"
zoe-master:
image: hxquangnhat/zoe:k8s-0.2
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /mnt/zoe-workspaces:/mnt/zoe-workspaces
- /media/sdb/kubernetes/data/config:/opt/zoe/kube.conf
command: python3 zoe-master.py --debug --backend Kubernetes --deployment-name prod --dbuser postgres --dbhost 192.168.12.2 --dbport 5432 --dbname postgres --dbpass postgres --auth-type text --proxy-type none --proxy-path zoe.fsdna.on.kpmg.de --listen-port 5001
ports:
- "4850:4850"
depends_on:
- zoe-api
version: '2'
services:
zoe-api-test:
image: hxquangnhat/zoe:k8s-0.2
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /media/sdb/kubernetes/data/config:/opt/zoe/kube.conf
command: python3 zoe-api.py --debug --backend Kubernetes --deployment-name test --dbuser postgres --dbhost 192.168.12.2 --dbport 4321 --dbname postgres --dbpass postgres --overlay-network-name my-net --master-url tcp://zoe-master-test:4850 --auth-type text --proxy-type none --proxy-path zoe.fsdna.on.kpmg.de --listen-port 5100
ports:
- "5100:5100"
zoe-master-test:
image: hxquangnhat/zoe:k8s-0.2
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /mnt/zoe-workspaces:/mnt/zoe-workspaces
- /media/sdb/kubernetes/data/config:/opt/zoe/kube.conf
command: python3 zoe-master.py --debug --backend Kubernetes --deployment-name test --dbuser postgres --dbhost 192.168.12.2 --dbport 4321 --dbname postgres --dbpass postgres --overlay-network-name my-net --auth-type text --proxy-type none --proxy-path zoe.fsdna.on.kpmg.de --listen-port 5100
depends_on:
- zoe-api-test
......@@ -25,11 +25,11 @@ from deploy.backenddeploy import ZoeBackendDeploy
class ZoeDeploy():
def __init__(self, dockerUrl, dockerComposePath, image):
def __init__(self, dockerUrl, dockerComposePath, image, dockerVersion):
self.currentImage = image
self.typeDeploy = 1 if 'prod' in dockerComposePath else 0
self.backend = ZoeBackendDeploy(dockerUrl, dockerComposePath)
self.frontend = ZoeFrontendDeploy(dockerUrl, 'apache2')
self.backend = ZoeBackendDeploy(dockerUrl, dockerComposePath, dockerVersion)
self.frontend = ZoeFrontendDeploy(dockerUrl, 'apache2', dockerVersion)
def deploy(self):
try:
......@@ -51,8 +51,8 @@ class ZoeDeploy():
return retBE and retFE
class ZoeImage():
def __init__(self, dockerUrl, tag):
self.cli = docker.DockerClient(base_url=dockerUrl)
def __init__(self, dockerUrl, tag, dockerVersion):
self.cli = docker.DockerClient(base_url=dockerUrl, version=dockerVersion)
self.tag = tag
def build(self):
......@@ -60,7 +60,8 @@ class ZoeImage():
ret = 1
try:
self.cli.images.build(path='.', tag=self.tag, rm=True)
except Exception:
except Exception as ex:
print(ex)
ret = 0
pass
return ret
......@@ -70,7 +71,8 @@ class ZoeImage():
ret = 1
try:
self.cli.images.push(self.tag, stream=True)
except Exception:
except Exception as ex:
print(ex)
ret = 0
pass
return ret
......@@ -80,17 +82,17 @@ if __name__ == '__main__':
sys.exit(1)
else:
if sys.argv[1] == '0':
deployer = ZoeDeploy(sys.argv[2], sys.argv[3], sys.argv[4])
deployer = ZoeDeploy(sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5])
ret = deployer.deploy()
if ret == 0:
sys.exit(1)
elif sys.argv[1] == '1':
imghandler = ZoeImage(sys.argv[2], sys.argv[3])
imghandler = ZoeImage(sys.argv[2], sys.argv[3], sys.argv[4])
ret = imghandler.build()
if ret == 0:
sys.exit(1)
elif sys.argv[1] == '2':
imghandler = ZoeImage(sys.argv[2], sys.argv[3])
imghandler = ZoeImage(sys.argv[2], sys.argv[3], sys.argv[4])
ret = imghandler.push()
if ret == 0:
sys.exit(1)
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