回答问题

Kubernetes 新手。前几天我在关注关于 Kubernetes 的教程。我忘了我在做什么。运行 docker ps 会显示许多 k8s* 容器。

$ docker ps
CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS               NAMES
3ce38bbf370b        f3591b2cb223           "/api-server --kubec…"   3 hours ago         Up 3 hours                              k8s_compose_compose-api-57ff65b8c7-cc6qf_docker_460bc96e-dcfe-11e9-9213-025000000001_6
222239366ae5        eb516548c180           "/coredns -conf /etc…"   3 hours ago         Up 3 hours                              k8s_coredns_coredns-fb8b8dccf-7vp79_kube-system_35ecd610-dcfe-11e9-9213-025000000001_6
0e4a5a5c23bd        eb516548c180           "/coredns -conf /etc…"   3 hours ago         Up 3 hours                              k8s_coredns_coredns-fb8b8dccf-h7tvr_kube-system_35edfd50-dcfe-11e9-9213-025000000001_6
332d3d26c082        9946f563237c           "kube-apiserver --ad…"   3 hours ago         Up 3 hours                              k8s_kube-apiserver_kube-apiserver-docker-desktop_kube-system_7c4f3d43558e9fadf2d2b323b2e78235_4
5778a63798ab        k8s.gcr.io/pause:3.1   "/pause"                 3 hours ago         Up 3 hours                              k8s_POD_kube-apiserver-docker-desktop_kube-system_7c4f3d43558e9fadf2d2b323b2e78235_3
a0a26d6a2d08        2c4adeb21b4f           "etcd --advertise-cl…"   3 hours ago         Up 3 hours                              k8s_etcd_etcd-docker-desktop_kube-system_3773efb8e009876ddfa2c10173dba95e_3
e6038e717c64        ac2ce44462bc           "kube-controller-man…"   3 hours ago         Up 3 hours                              k8s_kube-controller-manager_kube-controller-manager-docker-desktop_kube-system_9c58c6d32bd3a2d42b8b10905b8e8f54_4
10e962e90703        004666307c5b           "/usr/local/bin/kube…"   3 hours ago         Up 3 hours                              k8s_kube-proxy_kube-proxy-pq4f7_kube-system_35ac91f0-dcfe-11e9-9213-025000000001_4
21b4a7aa37d0        953364a3ae7a           "kube-scheduler --bi…"   3 hours ago         Up 3 hours                              k8s_kube-scheduler_kube-scheduler-docker-desktop_kube-system_124f5bab49bf26c80b1c1be19641c3e8_4
d9447c41bc55        k8s.gcr.io/pause:3.1   "/pause"                 3 hours ago         Up 3 hours                              k8s_POD_kube-proxy-pq4f7_kube-system_35ac91f0-dcfe-11e9-9213-025000000001_4
65248416150d        k8s.gcr.io/pause:3.1   "/pause"                 3 hours ago         Up 3 hours                              k8s_POD_kube-controller-manager-docker-desktop_kube-system_9c58c6d32bd3a2d42b8b10905b8e8f54_3
4afff5745b79        k8s.gcr.io/pause:3.1   "/pause"                 3 hours ago         Up 3 hours                              k8s_POD_kube-scheduler-docker-desktop_kube-system_124f5bab49bf26c80b1c1be19641c3e8_3
d6db038ea9b3        k8s.gcr.io/pause:3.1   "/pause"                 3 hours ago         Up 3 hours                              k8s_POD_etcd-docker-desktop_kube-system_3773efb8e009876ddfa2c10173dba95e_3
9ca30180ab45        k8s.gcr.io/pause:3.1   "/pause"                 3 hours ago         Up 3 hours                              k8s_POD_compose-api-57ff65b8c7-cc6qf_docker_460bc96e-dcfe-11e9-9213-025000000001_4
338d226f12d9        a8c3d87a58e7           "/compose-controller…"   3 hours ago         Up 3 hours                              k8s_compose_compose-6c67d745f6-9v5k5_docker_461b37ab-dcfe-11e9-9213-025000000001_3
6e23ff5c4b86        k8s.gcr.io/pause:3.1   "/pause"                 3 hours ago         Up 3 hours                              k8s_POD_coredns-fb8b8dccf-7vp79_kube-system_35ecd610-dcfe-11e9-9213-025000000001_5
258ced5c1498        k8s.gcr.io/pause:3.1   "/pause"                 3 hours ago         Up 3 hours                              k8s_POD_coredns-fb8b8dccf-h7tvr_kube-system_35edfd50-dcfe-11e9-9213-025000000001_4
0ee3d792d79e        k8s.gcr.io/pause:3.1   "/pause"                 3 hours ago         Up 3 hours                              k8s_POD_compose-6c67d745f6-9v5k5_docker_461b37ab-dcfe-11e9-9213-025000000001_4

我还使用提供的 --namespace 运行 kubectl。当我只执行 kubectl get pods 时,它说没有找到资源。

$ kubectl get pods --namespace kube-system
NAME                               READY   STATUS    RESTARTS   AGE
coredns-5644d7b6d9-frlhd           1/1     Running   1          9m30s
coredns-5644d7b6d9-xmdtg           1/1     Running   1          9m30s
etcd-minikube                      1/1     Running   1          8m29s
kube-addon-manager-minikube        1/1     Running   1          8m23s
kube-apiserver-minikube            1/1     Running   1          8m42s
kube-controller-manager-minikube   1/1     Running   1          8m22s
kube-proxy-48kxn                   1/1     Running   1          9m30s
kube-scheduler-minikube            1/1     Running   1          8m32s
storage-provisioner                1/1     Running   1          9m27s

我还尝试使用docker stop停止容器。它停止了,但几秒钟后,容器再次启动。

我也运行了 minikube delete 但它只删除了 minikube。命令 docker ps 仍然显示容器。

我想从头再来。

Answers

如果要重置集群,可以先使用kubectl get namespaces列出所有命名空间,然后使用kubectl delete namespaces namespace_name删除它们。

但是,您不能删除命名空间defaultkube-systemkube-public,因为它们受集群保护。您可以做的是使用kubectl delete --all pods --namespace=default; kubectl delete --all pods --namespace=kube-publicdefaultkube-public命名空间中删除所有 Pod。您不应接触kube-system命名空间,因为它包含集群运行所必需的资源。

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐