Difference between revisions of "K8s cleanup"
Jump to navigation
Jump to search
(Created page with "``` kubectl get pv | grep Released | awk '$1 {print$1}' | while read vol; do kubectl delete pv/${vol}; done ```") |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | Two directories you want to look at in Microk8s | ||
+ | |||
+ | /var/snap/microk8s/common/run | ||
+ | |||
+ | /var/snap/microk8s/common/var | ||
+ | |||
``` | ``` | ||
kubectl get pv | grep Released | awk '$1 {print$1}' | while read vol; do kubectl delete pv/${vol}; done | kubectl get pv | grep Released | awk '$1 {print$1}' | while read vol; do kubectl delete pv/${vol}; done | ||
+ | ``` | ||
+ | |||
+ | ``` | ||
+ | for i in $(kubectl get pv --no-headers | awk '{print $1}'); do node=$(kubectl get pv $i -o yaml | grep hostPathProvisionerIdentity | xargs); echo "$i $node"; done | ||
+ | ``` | ||
+ | |||
+ | https://stackoverflow.com/questions/58871139/how-to-remove-docker-images-added-to-microk8s-image-cache | ||
+ | ``` | ||
+ | microk8s ctr images rm $(microk8s ctr images ls name~='localhost:32000' | awk {'print $1'}) | ||
+ | ``` | ||
+ | |||
+ | |||
+ | ``` | ||
+ | for ns in $(kubectl get ns --field-selector status.phase=Terminating -o jsonpath='{.items[*].metadata.name}') | ||
+ | do | ||
+ | kubectl get ns $ns -ojson | jq '.spec.finalizers = []' | kubectl replace --raw "/api/v1/namespaces/$ns/finalize" -f - | ||
+ | done | ||
+ | |||
+ | for ns in $(kubectl get ns --field-selector status.phase=Terminating -o jsonpath='{.items[*].metadata.name}') | ||
+ | do | ||
+ | kubectl get ns $ns -ojson | jq '.metadata.finalizers = []' | kubectl replace --raw "/api/v1/namespaces/$ns/finalize" -f - | ||
+ | done | ||
+ | ``` | ||
+ | |||
+ | ``` | ||
+ | kubectl get all,cm,secret,ing -A | ||
``` | ``` |
Latest revision as of 16:43, 16 July 2023
Two directories you want to look at in Microk8s
/var/snap/microk8s/common/run
/var/snap/microk8s/common/var
kubectl get pv | grep Released | awk '$1 {print$1}' | while read vol; do kubectl delete pv/${vol}; done
for i in $(kubectl get pv --no-headers | awk '{print $1}'); do node=$(kubectl get pv $i -o yaml | grep hostPathProvisionerIdentity | xargs); echo "$i $node"; done
microk8s ctr images rm $(microk8s ctr images ls name~='localhost:32000' | awk {'print $1'})
for ns in $(kubectl get ns --field-selector status.phase=Terminating -o jsonpath='{.items[*].metadata.name}') do kubectl get ns $ns -ojson | jq '.spec.finalizers = []' | kubectl replace --raw "/api/v1/namespaces/$ns/finalize" -f - done for ns in $(kubectl get ns --field-selector status.phase=Terminating -o jsonpath='{.items[*].metadata.name}') do kubectl get ns $ns -ojson | jq '.metadata.finalizers = []' | kubectl replace --raw "/api/v1/namespaces/$ns/finalize" -f - done
kubectl get all,cm,secret,ing -A