Reputation: 178
I am constantly creating new clusters for development and I dislike going into "Troubleshooting" every time to reset the cluster.
Is there a quicker way to do this?
Upvotes: 0
Views: 474
Reputation: 74620
Quickest way I can think of is to blat the kubernetes etcd data.
You will need to have "Show system containers" turned on in Docker.
Please note, this is super destructive and not thoroughly tested (other than to see if it runs). There's probably horrible side effects from using it. Docker for Desktop maintains a lot more state on disk than just etcd. There's also an rm -rf
in there which you should never trust someone on the internet telling you to run! But here we go...
This will:
k8s_etcd_etcd-*
container and remove all etcd data from it.k8s_*
.One liner:
docker exec $(docker ps -q --filter 'name=k8s_etcd_etcd-*' -l) rm -rf /var/lib/etcd/member \
&& docker rm -f $(docker ps -q --filter 'name=k8s_*')
or as a script with a bit more output:
#!/bin/bash -uex
etcd_container=$(docker ps -q --filter 'name=k8s_etcd_etcd-*' -l)
docker exec "$etcd_container" rm -rf /var/lib/etcd/member;
all_k8s_containers=$(docker ps -q --filter 'name=k8s_*')
docker rm -f $all_k8s_containers
Upvotes: 3