Skip to content

Instantly share code, notes, and snippets.

@furqanbaqai
Forked from Kevinrob/clean.md
Created June 12, 2020 06:03
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 furqanbaqai/6d9f390806ac93c3f0a94828b69cf6d8 to your computer and use it in GitHub Desktop.
Save furqanbaqai/6d9f390806ac93c3f0a94828b69cf6d8 to your computer and use it in GitHub Desktop.
Clean up microk8s registry
registry=localhost:32000
repositories=$(curl ${registry}/v2/_catalog)
for repo in $(echo "${repositories}" | jq -r '.repositories[]'); do
  echo $repo
  tags=$(curl -sSL "http://${registry}/v2/${repo}/tags/list" | jq -r '.tags[]')
  for tag in $tags; do
    echo $tag
    curl -v -sSL -X DELETE "http://${registry}/v2/${repo}/manifests/$(
      curl -sSL -I \
          -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
          "http://${registry}/v2/${repo}/manifests/$tag" \
      | awk '$1 == "Docker-Content-Digest:" { print $2 }' \
      | tr -d $'\r' \
    )"
  done
done

kubectl get pods --namespace="container-registry"
kubectl exec -it --namespace="container-registry" registry-... bash
bin/registry garbage-collect /etc/docker/registry/config.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment