Skip to content

Instantly share code, notes, and snippets.

@zhangguanzhang
Last active April 25, 2022 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhangguanzhang/5a2998f19972eee9fc258d6d30cbfe04 to your computer and use it in GitHub Desktop.
Save zhangguanzhang/5a2998f19972eee9fc258d6d30cbfe04 to your computer and use it in GitHub Desktop.
# 取无法拉取镜像名
kubectl get po `kubectl get pod -o wide | grep Image | awk '{print $1}'` -o yaml | grep -Po 'image: \K\S+' | sort -u
# docker save -o images.tar.gz \
imgList=""
while read img;do
if docker inspect $img &>/dev/null;then
imgList+="$imgList $img"
fi
done < <( kubectl get po `kubectl get pod -o wide | grep Image | awk '{print $1}'` -o yaml | grep -Po 'image: \K\S+' | sort -u)
docker save $img -o image.tag.gz
while read ctr;do
ResolvConfPath=`docker inspect $ctr --format "{{ .ResolvConfPath }}" `
if ! grep -q use-vc $ResolvConfPath;then
echo 'options use-vc' >> $ResolvConfPath
fi
if ! grep -q single $ResolvConfPath;then
echo 'options single-request-reopen' >> $ResolvConfPath
fi
done < <(docker ps -a --filter label=io.kubernetes.docker.type=container --format '{{.ID}}' )
kubectl api-resources -o name --verbs=list --namespaced | xargs -n 1 kubectl get --show-kind --ignore-not-found -n xxx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment