zoukankan      html  css  js  c++  java
  • k8s环境镜像同步脚本

    #!/bin/bash
    src='env-name1'
    dest='env-name2'
    echo ${src} ${dest}
    dir='/opt/shell/k8s_setimage'
    cd ${dir}/list/
    su - ${src} -c ${dir}/get_images.sh >${src}.list
    su - ${dest} -c ${dir}/get_images.sh >${dest}.list
    wc -l ${src}.list
    wc -l ${dest}.list
    cat ${src}.list|grep -vE "deploy-kie-server|courier-example|eureka-server"|while read line
    do
    ns=`echo $line|awk -F @ '{print $1}'`
    dpm=`echo $line|awk -F @ '{print $2}'|sed 's/-prod$/-record/g'`
    cname=`echo $line|awk -F @ '{print $3}'|sed 's/-prod$/-record/g'`
    image=`echo $line|awk -F @ '{print $4}'|sed 's/-vpc//g'`
    src_ver=`echo $line|awk -F : '{print $NF}'`
    if grep -q "@${dpm}@" ${dest}.list; then
    dest_ver=`grep "@${dpm}@" ${dest}.list|awk -F : '{print $NF}'`
    if [ ${src_ver} != ${dest_ver} ]; then
    echo ${ns} ${dpm} ${src_ver} ${dest_ver}
    su - ${dest} -c "kubectl -n ${ns} set image deployment/${dpm} ${cname}=${image}"
    fi
    else
    echo =====${ns} ${dpm} not in ${dest}
    fi
    done
    cat ${dest}.list|while read line
    do
    ns=`echo $line|awk -F @ '{print $1}'`
    dpm=`echo $line|awk -F @ '{print $2}'|sed 's/-hwbeta$/-prod/g'`
    if grep -q "@${dpm}@" ${src}.list; then
    :
    else
    echo +++++${ns} ${dpm} not in ${src}
    fi
    done

  • 相关阅读:
    hdu4578线段树维护平方和,立方和(加,乘,赋值)或者珂朵莉树
    珂朵莉树(ODT老司机树)
    Codeforces Round #524 (Div. 2)D
    HDU1402 FFT高精度乘法模板题
    中国剩余定理poj1006
    POJ
    Install and Config MySQL 8 on Ubuntu
    Protobuf Examples
    Learning Thrift
    Flask Quickstart
  • 原文地址:https://www.cnblogs.com/wudongyu/p/15011107.html
Copyright © 2011-2022 走看看