```python
import subprocess,threading,re
from setting import *
auth = {'kuccl':'ngnix', 'kuccl2':'redis','yum':'registry.cn-shenzhen.aliyuncs.com/jay23/centos_yum:v1.0'}
namespace='default'
staticDir='/tmp/test/' 
ip='172.0.1.16'
###静态发布
def deployStatic(staticDir,ip):
    result={}
    CMD='rsync -e ssh    -avpz --delete  {0} root@{1}:/tmp/test/'.format(staticDir,ip)
    result = subprocess.Popen(CMD,shell=True,stderr=subprocess.PIPE,stdout=subprocess.PIPE)
    result.wait()
    out,err = result.communicate()
    print(out,err)
##镜像发布
def deployVersion(deployName,imageVesion,namespace):
    result={}
    CMD='ssh 172.0.1.16 "kubectl set image  deploy/{0}  kuccl2={1}  -n {2}"'.format(deployName,imageVesion,namespace)
    result = subprocess.Popen(CMD,shell=True,stderr=subprocess.PIPE,stdout=subprocess.PIPE)
    result.wait()
    out,err = result.communicate()
    print(out,err)
 def systemDeployVersion():
     for  deployname,imageVesion in auth.items(): 
          deployVersion(deployName,imageVesion,namespace)

  



def pipline():
    print('版本检查')
    print('镜像构建')
    print('配置更新')
    print('静态发布')
    print('镜像发布')
    systemDeployVersion()

if __name__ == '__main__':
    '''程序入口'''
    pipline()

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐