4

New to kubernetes. I was following a tutorial on kubernetes the other day. I forgot what I was doing. Running docker ps shows many containers of 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

I also ran kubectl with --namespace provided. When I only execute kubectl get pods, it says no resource found.

$ 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

I also tried stopping the containers using docker stop. It stopped but few seconds later, the containers started again.

I also ran minikube delete but it only deleted minikube. The command docker ps still showed the containers.

I'd like to start from beginning again.

mchawre
  • 10,744
  • 4
  • 35
  • 57
devwannabe
  • 3,160
  • 8
  • 42
  • 79

4 Answers4

4

Don't try to delete pause containers.

k8s.gcr.io/pause:3.1   "/pause"

You can bring multiple containers in a k8s pod and they share same network namespace.

The pause containers are meant to be a way to share network namespace.

That's how the k8s pod is created.

For more info, please go through this.

halfer
  • 19,824
  • 17
  • 99
  • 186
mchawre
  • 10,744
  • 4
  • 35
  • 57
1

If you want to reset your cluster, you can first list all namespaces using kubectl get namespaces, then delete them using kubectl delete namespaces namespace_name.

However, you can't delete the namespaces default, kube-system, and kube-public as those are protected by the cluster. What you can do is remove all Pods from the default and kube-public namespace using kubectl delete --all pods --namespace=default; kubectl delete --all pods --namespace=kube-public. You shouldn't touch the kube-system namespace as it contains resources that are mandatory for the cluster to function.

Alassane Ndiaye
  • 4,427
  • 1
  • 10
  • 19
  • How can I clear the container related to k8s? I have executed the above instructions but still cannot clear the container displayed by docker ps. – Linminxiang May 28 '21 at 04:55
0

You can try deleting the files using the below commands:

kubectl delete -f <file location>

The file which you installed using:

kubectl apply -f <file location>

you can remove all the tags associated with it using:

istioctl tag remove <profile>

Note: You can refer manifests/profiles for referring the profiles

0

My situation is similar with you. Forgot what I did, then finding out many *k8s* containers running in docker. Which once deleted, will be started again automatically.

Uncheck Docker Desktop -> Settings -> Kubernetes -> Enable Kubernetes works for me. Hope that helps. enter image description here

mCY
  • 2,731
  • 7
  • 25
  • 43