Joey Yi Zhao
Joey Yi Zhao

Reputation: 42596

How to delete a pod from EKS cluster?

I deployed a Elasticserach container to EKS cluster but I can't delete it.

$ kubectl get pods
NAME                           READY   STATUS              RESTARTS   AGE
kibana-f775fcb96-cvmkc         1/1     Running             0          81m
sample-es-0                    0/1     ContainerCreating   0          2m6s
sidecar-app-6b4bdbb86d-g5qb6   1/1     Running             0          81m

sample-es-0 is the pod I want to delete. But after run kubectl delete pod sample-es-0, it restarts by itself.

I have delete es deployment:

$ kubectl get deploy
NAME          READY   UP-TO-DATE   AVAILABLE   AGE
kibana        1/1     1            1           28h
sidecar-app   1/1     1            1           29h

and also check there is no es service running:

$ kubectl get service
NAME                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
kibana-entrypoint    ClusterIP   10.100.192.40   <none>        5601/TCP         28h
kubernetes           ClusterIP   10.100.0.1      <none>        443/TCP          6d10h
sidecar-entrypoint   NodePort    10.100.7.177    <none>        8080:32486/TCP   29h

And there is no replicaset for es either:

$ kubectl get replicaset
NAME                     DESIRED   CURRENT   READY   AGE
kibana-595fddf748        0         0         0       28h
kibana-66b96d587f        0         0         0       25h
kibana-69784478f         0         0         0       28h
kibana-6b47b7855f        0         0         0       26h
kibana-6c55cd9478        0         0         0       27h
kibana-6fdcc89695        0         0         0       11h
kibana-74c766ddbf        0         0         0       26h
kibana-756866579f        0         0         0       25h
kibana-b774d7b64         0         0         0       26h
kibana-bf8c496ff         0         0         0       23h
kibana-f775fcb96         1         1         1       170m
sidecar-app-54677877d4   0         0         0       27h
sidecar-app-566f6dd4d5   0         0         0       27h
sidecar-app-5ffdbbcb7c   0         0         0       23h
sidecar-app-67b46f5dfb   0         0         0       27h
sidecar-app-6955cc9bd9   0         0         0       23h
sidecar-app-6b4bdbb86d   1         1         1       137m
sidecar-app-6fdd5f9679   0         0         0       170m
sidecar-app-856978f87b   0         0         0       27h
sidecar-app-85c54787b8   0         0         0       26h
sidecar-app-8678db7cf8   0         0         0       11h
sidecar-app-d95f67768    0         0         0       25h

what other place should I check in order to delete it?

Upvotes: 4

Views: 9545

Answers (2)

Sahadat Hossain
Sahadat Hossain

Reputation: 4379

  • You need to delete the deployment, then it would delete the respected pods. For this use kubectl delete deployment <NAME>
  • Deleting a pod which is under a deployment will restarts it if that deployment is still in the place.

as you answered it was statefulset, but you didn't mentioned it was statefulset, you told deployment. Anyway, in both you need to delete the owner reference

Upvotes: 4

Joey Yi Zhao
Joey Yi Zhao

Reputation: 42596

I found that the reason is the es pod is deployed via StatefulSet. It can be deleted by deleting the StatefulSet. kubectl delete StatefulSet es.

Upvotes: 2

Related Questions