Facebook

Tuesday, March 24, 2020

Kubernetes, helm, microk8s, Docker: Tips and tricks



1. Usage: Delete all completed pods by namespace(say namespace is "internal").

$: kubectl delete po --namespace internal $(kubectl get po --namespace internal | grep Completed | awk '{if ($1 !="") print $1}')
2. Usage: Delete all pods by namespace(say namespace is "default").

$: kubectl delete po $(kubectl get po --namespace default | awk '!/NAME/'| awk '{if ($1 !="") print $1}')
3. Usage: Delete all releases from helm except few

$:helm delete --purge $(helm list | awk '!/NAME/' | awk '!/mysql/' | awk '!/redis/' | awk '!/php-myadmin/' | awk '{if ($1 !="") print $1}')
4. Usage: Cleans all dangling images. This is useful for removing intermediate images left over from multiple builds

$:alias docker_clean_images='docker rmi $(docker images -a --filter=dangling=true -q)'
5. Usage: Removing stopped containers

$:alias docker_clean_ps='docker rm $(docker ps --filter=status=exited --filter=status=created -q)'
6. Usage: To remove ALL of your cache, make sure all containers are stopped and removed, So

$:docker kill $(docker ps -q)
$:docker_clean_ps
$:docker rmi $(docker images -a -q)

No comments:

Post a Comment