2

First time Kubernetes user here.

I deployed a service using kubectl -n my_namespace apply -f new_service.yaml

It failed, with the pod showing Warning -Back-off restarting failed container

I am now trying to delete the failed objects and redeploy a fixed version. However, I have tried to delete the service, pod, deployment, and replicaset, but they all keep recreating themselves.

I looked at this thread but don't believe it applies since my deployment list:

apiVersion: apps/v1
kind: Deployment

Any input appreciated!

Xela
  • 71
  • 8
  • 2
    do `kubectl -n my_namespace delete -f new_service.yaml` and repeate for deployment. focus on deleting deployment and service. The pods, replica sets will get deleted – P.... Apr 08 '22 at 21:57
  • also, are you using tools like helm? for creating objects? – P.... Apr 08 '22 at 22:00
  • Well, yeah, the point of a replicaset is to make sure replicas are runnng. I'd start by setting the replica count to 0.. – passer-by Apr 08 '22 at 22:01
  • @P.... ahh thank you so much, that seemed to do the trick. Yes, we use Helm and Argo, but I don't have much experience with them yet. – Xela Apr 08 '22 at 22:08
  • @P.... Could you post an answer? It would be more visible to the community. – mozello Apr 11 '22 at 13:28

1 Answers1

4

Posting this as Community wiki for better visibility. Feel free to expand it.


In a Kubernetes cluster:

  • if you delete Pods, but they are recreated again
    there is a Kubernetes Deployment / StatefulSet / DaemonSet / job that recreates them
    delete a Deployment / StatefulSet / DaemonSet to delete those pods, check k8s jobs
  • if you delete a ReplicaSet, but it is recreated again
    there is a Kubernetes Deployment that recreates it
    delete a Deployment to delete this replicaset
  • if you delete a Deployments / Services, etc., but they are recreated again
    there is a deployment tool like ArgoCD / FluxCD / other tool that recreates them
    configure ArgoCD / FluxCD / other deployment tool to delete them
  • also check if Helm is used, run helm list --all-namespaces to list installed releases.

Thanks to @P....for comments.

mozello
  • 1,083
  • 3
  • 8
  • Strangely enough this still isn't enough to delete my deployments. We do have Helm, but `helm ls` doesn't show any deployments that should be relevant. Is there a way to see what exactly created the deployment? Perhaps this? `manager: kube-controller-manager` – Herman Mar 21 '23 at 15:19
  • Ah almost immediately after posting this I found a helm-CD-pipeline that was the culprit. – Herman Mar 21 '23 at 15:24