From a2efb40ccc67f19beab763d0ac736b81a03edb4e Mon Sep 17 00:00:00 2001 From: Thomas Runyon <thomas.runyon.2.ctr@us.af.mil> Date: Thu, 29 Apr 2021 06:41:26 -0400 Subject: [PATCH] Add script to identify if newer images are available in iron bank --- scripts/latest.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 scripts/latest.sh diff --git a/scripts/latest.sh b/scripts/latest.sh new file mode 100755 index 0000000000..585af7b518 --- /dev/null +++ b/scripts/latest.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# This script looks at all the deployed images from iron bank and identifies if the +# currently deployed version is the latest in IronBank. Could be used as part of CI +# or as general awareness for development + +# Needs crane( https://github.com/google/go-containerregistry/tree/main/cmd/crane ) +# to be configured before hand via + +# crane auth login -p ${REGISTRY1_CREDENTIALS} -u ${REGISTRY1_USER} registry1.dso.mil + +images=`kubectl get pods -A -o jsonpath="{..image}" | tr -s '[[:space:]]' '\n' | sort | uniq -c | grep "registry1" | awk '{ print $2 }'` + + +for i in $images +do + image=`echo "$i" | awk '{split($0,a,":"); print a[1] }'` + tag=`echo "$i" | awk '{split($0,a,":"); print a[2] }'` + + upstream_tag=`crane ls $image | grep -v "latest" | sort -r | head -n1` + + if [[ "$tag" != "$upstream_tag" ]] + then + echo "Update for $image: $tag ----> $upstream_tag" + fi +done \ No newline at end of file -- GitLab