Skip to content

Instantly share code, notes, and snippets.

@fuomag9
Last active March 18, 2021 12:25
Show Gist options
  • Save fuomag9/3ff2da547173d4b6251fe8dc1f3935fc to your computer and use it in GitHub Desktop.
Save fuomag9/3ff2da547173d4b6251fe8dc1f3935fc to your computer and use it in GitHub Desktop.
Delete/cleanup all containerd kubernetes images on microk8s
import subprocess
a = subprocess.getoutput('microk8s.ctr i ls')
a = a.split("\n")
b = [x.split(" ")[0] for x in a]
del b[0]
ii = str(input(f"Do you want to delete {len(b)} images?"))
if ii == "yes" or ii=="y":
for x in b:
print(subprocess.getoutput(f'microk8s.ctr i rm {x}')+" has been deleted")
else:
print("Aborted")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment