2016-10-03 43 views
0

有没有办法删除以前的部署使用CLI?删除部署/复制控制器openshift cli来

当我成功运行oc import-image $APPLICATION新的部署出现了RC和几个运行后我打的RC max和将不得不手动删除以前的部署。

是否有类似oc delete rc $APPLICATION-$(($DEPLOYMENT_NUMBER - 1))脚本?

回答

0

我结束了使用下面的代码来创建一个(冲)解决方案。

# DEPLOYMENT_COUNT will be the number of deployments 
DEPLOYMENT_COUNT=`oc get rc | wc -l` 
DEPLOYMENT_COUNT=$((DEPLOYMENT_COUNT - 1)) 
for ((i=1; i<$DEPLOYMENT_COUNT + 1; i++)) 
do 
    #CURR_POD_LINE=`oc get rc | tail -$i | head -n1` 
    DEPLOYMENT_ID=`oc get rc | tail -$i | head -n1 | awk '{print $1}'` 
    DESIRED_PODS_COUNT=`oc get rc | tail -$i | head -n1 | awk '{print $5}'` 

    # IF number of desired pods is 0, then delete the deployment 
    if [ $DESIRED_PODS_COUNT -eq 0 ] 
     then 
     #DELETE 
     oc delete rc $DEPLOYMENT_ID 
    fi 
    echo $DEPLOYMENT_ID 
    echo $DESIRED_PODS_COUNT 
done