Cannot stop 10 containers after Kubernetes minikub

2019-06-27 10:26发布

问题:

docker ps

CONTAINER ID        IMAGE                                                  COMMAND                  CREATED             STATUS              PORTS               NAMES
7523fd2c20c7        gcr.io/google_containers/k8s-dns-sidecar-amd64         "/sidecar --v=2 --..."   18 hours ago        Up 18 hours                             k8s_sidecar_kube-dns-86f6f55dd5-qwc6z_kube-system_c1333ffc-e4d6-11e7-bccf-0021ccbf0996_0
9bd438011406        gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64   "/dnsmasq-nanny -v..."   18 hours ago        Up 18 hours                             k8s_dnsmasq_kube-dns-86f6f55dd5-qwc6z_kube-system_c1333ffc-e4d6-11e7-bccf-0021ccbf0996_0
5c35e00a5a27        gcr.io/google_containers/k8s-dns-kube-dns-amd64        "/kube-dns --domai..."   18 hours ago        Up 18 hours                             k8s_kubedns_kube-dns-86f6f55dd5-qwc6z_kube-system_c1333ffc-e4d6-11e7-bccf-0021ccbf0996_0
77ef463642b7        gcr.io/google_containers/pause-amd64:3.0               "/pause"                 18 hours ago        Up 18 hours                             k8s_POD_kube-dns-86f6f55dd5-qwc6z_kube-system_c1333ffc-e4d6-11e7-bccf-0021ccbf0996_0
39f618666205        gcr.io/google_containers/kubernetes-dashboard-amd64    "/dashboard --inse..."   18 hours ago        Up 18 hours                             k8s_kubernetes-dashboard_kubernetes-dashboard-vgpjl_kube-system_c1176a44-e4d6-11e7-bccf-0021ccbf0996_0
023b7b554a8c        gcr.io/google_containers/pause-amd64:3.0               "/pause"                 18 hours ago        Up 18 hours                             k8s_POD_kubernetes-dashboard-vgpjl_kube-system_c1176a44-e4d6-11e7-bccf-0021ccbf0996_0
1c3bdb7bdeb1        gcr.io/google-containers/kube-addon-manager            "/opt/kube-addons.sh"    18 hours ago        Up 18 hours                             k8s_kube-addon-manager_kube-addon-manager-tpad_kube-system_7b19c3ba446df5355649563d32723e4f_0
8a00feefa754        gcr.io/google_containers/pause-amd64:3.0               "/pause"                 18 hours ago        Up 18 hours                             k8s_POD_kube-addon-manager-tpad_kube-system_7b19c3ba446df5355649563d32723e4f_0
b657eab5f6f5        gcr.io/k8s-minikube/storage-provisioner                "/storage-provisioner"   18 hours ago        Up 18 hours                             k8s_storage-provisioner_storage-provisioner_kube-system_c0a8b187-e4d6-11e7-bccf-0021ccbf0996_0
67be5cc1dd0d        gcr.io/google_containers/pause-amd64:3.0               "/pause"                 18 hours ago        Up 18 hours                             k8s_POD_storage-provisioner_kube-system_c0a8b187-e4d6-11e7-bccf-0021ccbf0996_0

I just did the Kubernetes minikube tutorial at https://github.com/kubernetes/minikube, and I cannot stop or remove these containers, they always get recreated.

$ kubectl get deployment
No resource found.

$ minikube status
minikube: Running  
cluster: Running  
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100

Output of kubectl get pods --all-namespaces

NAMESPACE     NAME                          READY     STATUS    RESTARTS   AGE
kube-system   kube-addon-manager-minikube   1/1       Running   5          19h
kube-system   kube-dns-86f6f55dd5-6kjsn     3/3       Running   15         19h
kube-system   kubernetes-dashboard-68vph    1/1       Running   5          19h
kube-system   storage-provisioner           1/1       Running   5          19h

UPDATE:

I completely removed all packages called 'kube*', removed docker, remove virtualbox, removed /var/lib/docker, reinstalled docker. And the containers are back! How on earth do you get rid of them?

回答1:

What containers do you want to delete and why? The containers printed in your docker ps output are Kubernetes containers. You basically would destroy minikube by deleting these containers.

In general Kubernetes manages these containers for you. Kubernetes interprets a deleted container as a failure and restarts it. To delete a container you have to delete the pod (or the ReplicaSet, ReplicationController or Deployment depending on your deployed applications).


If these containers actually appear on your host system, then you maybe installed Kubernetes accidentally on your host system (with another tutorial). In this case you have to look for a process called kubelet which creates these containers.

For example if you use systemd:

systemctl status kublet   # see if its actually running
systemctl stop kubelet    # stop it
systemctl disable kubelet # make sure it doesn't start after next reboot


回答2:

If you don't want to run kubernetes then minikube isn't needed and you can stop it and delete it.

minikube stop
minikube delete

Or, if you wan't it running, for some reason, just remove the environment variable DOCKER_HOST that eval $(minikube docker-env) set up for you. It points the docker client to the docker engine in minikube instead of your local machine.

unset DOCKER_HOST

Or, start a new terminal. It won't have the environment variable set.