I'm trying to write bash script, which will automatically read all file names in current and custom directories, then apply new created docker image' names to finded yml files via kubectl, then read from two arrays image names and full registry names:
declare -a IMG_ARRAY=`docker images | awk '/dev2/ && /latest/' | awk '{print $1}' | sed ':a;N;$!ba;s/\n/ /g'`
declare -a IMG_NAME=`docker images | awk '/dev2/ && /latest/' | awk '{print $1}' | awk -F'/' '{print $3}' | cut -f1 -d"." | sed ':a;N;$!ba;s/\n/ /g'`
IFS=' ' read -r -a array <<< "$IMG_NAME"
for element in "${array[@]}"
do
kubectl set image deployment/$IMG_NAME $IMG_NAME=$IMG_ARRAY --record
kubectl rollout status deployment/$IMG_NAME
done
Both arrays has same number of indexes. My loop should take first indexes from IMG_NAME and put into kubectl commands for every array index. For now it is taking whole array....
docker images
as a separate code block.docker images
without your post-processing. I want to see the output lines, not what you have combined into variablesIMG_NAME
andIMG_ARRAY