Last active
September 21, 2023 20:49
-
-
Save jparrill/982d6de97f1f1418eb563fc9943f2e7f to your computer and use it in GitHub Desktop.
Mirror all the missing images which are in `ImagePullBackOff` state in the cluster.
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
#!/bin/bash | |
function identifyImages() { | |
export KUBECONFIG=/root/.kcli/clusters/hub-ipv6/auth/kubeconfig | |
> imagesToMirror.txt | |
IFS=$'\n' | |
for image in $(oc get pod -A -o yaml | grep "Back-off pulling image"); do | |
extractedImage=$(echo "$image" | grep -o '"[^"]*"') | |
finalImage=$(echo "$extractedImage" | cut -d '"' -f 2) | |
echo $finalImage >> $filename | |
done | |
} | |
filename="imagesToMirror.txt" | |
identifyImages | |
if [ ! -f "$filename" ]; then | |
echo "The file '$filename' does not exists" | |
exit 1 | |
fi | |
while IFS= read -r line; do | |
echo "-----> Image: $line" | |
skopeo copy --all docker://${line} docker://${REGISTRY}/${line#*/} | |
echo "-----> Copied!" | |
done < "$filename" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script needs only the KUBECONFIG of the Disconnected openshift cluster and the skopeo tool.
It will mirror all the missing images that the cluster is trying to raise up and it couldn't.