Created
May 25, 2017 13:53
-
-
Save wozniakjan/6a2b2c81c56fd51a77f7093de801475b to your computer and use it in GitHub Desktop.
migrate dc to deployment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
readonly tempdir="/tmp/templates" | |
mkdir -p "$tempdir" | |
oc project logging | |
readonly dcs=( $(oc get dc | awk 'NR > 1 {print($1)}') ) | |
for dc in ${dcs[@]}; do | |
oc get dc "$dc" -o yaml | | |
sed 's/^apiVersion: v1/apiVersion: extensions\/v1beta1/' | | |
sed 's/DeploymentConfig/Deployment/' | | |
awk '/strategy:/{l=0}/.*/{if(l){print(" "$0)}else{print($0)}} / selector:/{print " matchLabels:";l=1}' | | |
sed 's/type: Rolling/type: RollingUpdate/' | | |
awk '/rollingParams:/{rp=1} /type:/{rp=0} /.*/{if(rp==0){print($0)}}' > "$tempdir/$dc".yaml | |
done | |
for dc in ${dcs[@]}; do | |
echo "scale down $dc" | |
oc scale deploymentconfig "$dc" --replicas=0 | |
done | |
for dc in ${dcs[@]}; do | |
oc delete dc "$dc" | |
done | |
readonly rcs=( $(oc get replicationcontroller | awk 'NR > 1 {print($1)}') ) | |
for rc in ${rcs[@]}; do | |
oc delete replicationcontroller "$rc" | |
done | |
for dc in /tmp/templates; do | |
oc create -f "$dc" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment