1

I'm trying to delete some old deployments / replicasets I have in my cluster but when I run kubectl delete deployment It'll say the deployment is deleted and the pod from that deployment is Terminating, but then a few seconds later the deployment is magically recreated and the pod comes back. This is the same result for another replicaset I have.

What could be re-creating these deployments / replicasets and how can I stop it so I can permanently delete these deployments/rs?

Edit: Here's some output. This is on a kubernetes cluster in GKE btw:

kubectl get deployments
NAME             READY   UP-TO-DATE   AVAILABLE   AGE
quickstart-kb    1/1     1            1           41m
ubuntu           1/1     1            1           66d

kubectl get pods
NAME                              READY   STATUS    RESTARTS   AGE
ubuntu-677fc9fd77-fgd7k           1/1     Running   0          19d
quickstart-kb-f9b65577f-4fxph     1/1     Running   0          40m

kubectl delete deployment quickstart-kb
deployment.extensions "quickstart-kb" deleted

kubectl get deployments
NAME             READY   UP-TO-DATE   AVAILABLE   AGE
quickstart-kb    0/1     1            0           7s
ubuntu           1/1     1            1           66d

kubectl get pods
NAME                              READY   STATUS    RESTARTS   AGE
quickstart-kb-6cb6cf897d-qcjff    0/1     Running   0          11s
ubuntu-677fc9fd77-fgd7k           1/1     Running   0          19d

kubectl get deployments
NAME             READY   UP-TO-DATE   AVAILABLE   AGE
quickstart-kb    1/1     1            1           4m6s
ubuntu           1/1     1            1           66d

kubectl get pods
NAME                              READY   STATUS    RESTARTS   AGE
quickstart-kb-6cb6cf897d-qcjff    1/1     Running   0          4m13s
ubuntu-677fc9fd77-fgd7k           1/1     Running   0          19d

johnb928
  • 53
  • 1
  • 5

1 Answers1

2

I think your deployment object is created with the deployment of some custom resources (CRD).

When you created the CRD, the CRD controller created the deployment object. So, even if you delete the deployment object, the CRD controller re-creates it.

Delete the CRD object itself, to delete the deployment and other objects (if any) that were created with it.

From the name, it seems like Kibana CRD object:

apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana

Use the following command to delete the Kibana object:

$ kubectl delete Kibana quickstart-kb
Kamol Hasan
  • 12,218
  • 1
  • 37
  • 46
  • Thank you!!! Yes this was a kibana deployment and I was able to remove it via the command you gave. This is my first time coming across CRD's, is this a common way for certain apps to be deployed? I find it interesting that I couldn't see crd's when I run "kubectl get all". – johnb928 Aug 10 '20 at 18:03
  • Yes, if you use operator managed applications, it is common. Use, `kubectl get crd` to list CRDs. And `kubectl get ...` to list object of certain CRD type. – Kamol Hasan Aug 10 '20 at 18:08
  • Yep, and when I view a CRD, and I look at the "kind:", that's the field that lets me run kubectl get right? Which is why kubectl delete Kibana worked? – johnb928 Aug 10 '20 at 18:14
  • Yeah, you will find the kind in `spec.names.kind` the custom resource definition. – Kamol Hasan Aug 10 '20 at 18:21