xuekailun 4 月之前
父節點
當前提交
49e886801e
共有 2 個文件被更改,包括 9 次插入5 次删除
  1. 3 2
      gateway/gateway_config.py
  2. 6 3
      gateway/gateway_update.py

+ 3 - 2
gateway/gateway_config.py

@@ -7,13 +7,14 @@ logging.basicConfig(level=logging.INFO,
 
 server_group_id_list = ["sgp-l2k0p33e470vfmj538"]
 apps = 'piaoquan-gateway'
-repository = 'registry-vpc.cn-hangzhou.aliyuncs.com/stuuudy/{}'.format(apps)
-registry = 'registry-vpc.cn-hangzhou.aliyuncs.com/stuuudy/{}:{}'.format(apps, version)
+repository = 'registry-vpc.cn-hangzhou.aliyuncs.com/stuuudy/{}'
+registry = 'registry-vpc.cn-hangzhou.aliyuncs.com/stuuudy/{}:{}'
 
 # 修改负载均衡权限
 alb_client_params = {
     'access_key_id': 'LTAI5tASD5yEZLeC8ffmNebY',
     'access_key_secret': '1PtsFRdp8viJmI78lEhNZR8MezWZBq',
+    'endpoint': 'alb-vpc.cn-hangzhou.aliyuncs.com',
     'region_id': 'cn-hangzhou'
 }
 # 购买机器权限

+ 6 - 3
gateway/gateway_update.py

@@ -16,6 +16,7 @@ import utils
 # 从配置文件中获取应用程序名称和容器仓库地址
 apps = gateway_config.apps
 repository = gateway_config.repository
+registry = gateway_config.registry
 version = sys.argv[1]  # 从命令行参数获取版本号
 
 
@@ -64,7 +65,7 @@ def update(instance_id):
         docker_config = gateway_config.docker_config
         client.login(username=docker_config['username'], password=docker_config['password'],
                      registry=docker_config['registry'])
-        client.containers.run(repository, detach=True, cap_add='SYS_PTRACE', network_mode='host', name=apps,
+        client.containers.run(registry.format(apps, version), detach=True, cap_add='SYS_PTRACE', network_mode='host', name=apps,
                               volumes={'/datalog/': {'bind': '/datalog/', 'mode': 'rw'}})
         print("开始健康检查")
         checkHealth(ipadd)
@@ -89,7 +90,7 @@ def pull_image():
     client = docker.DockerClient(base_url=cd_url, timeout=30)
 
     try:
-        client.images.pull(repository, tag=version)
+        client.images.pull(repository.format(apps), tag=version)  #
         print(ipaddr, "pull images success ")
         return True
     except Exception as e:
@@ -105,7 +106,9 @@ if __name__ == '__main__':
 
     # 初始化 ALB 客户端
     alb_client = utils.connect_alb_client(gateway_config.alb_client_params['access_key_id'],
-                                          gateway_config.alb_client_params['access_key_secret'])
+                                          gateway_config.alb_client_params['access_key_secret'],
+                                          endpoint=gateway_config.alb_client_params['endpoint']
+                                          )
 
     success_count = 0
     threads = []