k8s镜像构建镜像推送


```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()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值