user416983
user416983

Reputation: 1024

Kubernetes keeps spawning Pods after deletion

The following is the file used to create the Deployment:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: kloud-php7
  namespace: kloud-hosting
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: kloud-php7
    spec:
      containers:
      - name: kloud-php7
        image: 192.168.1.1:5000/kloud-php7
      - name: kloud-nginx
        image: 192.168.1.1:5000/kloud-nginx
        ports:
        - containerPort: 80

The Deployment and the Pod worked fine, but after deleting the Deployment and a generated ReplicaSet, the I cannot delete the spawn Pods permanently. New Pods will be created if old ones are deleted.

The kubernetes cluster is created with kargo, containing 4 nodes running CentOS 7.3, kubernetes version 1.5.6

Any idea how to solve this problem ?

Upvotes: 4

Views: 11814

Answers (3)

Senthil Selvaraj
Senthil Selvaraj

Reputation: 11

It could be the deamonsets need to be deleted.

For example:

$ kubectl get DaemonSets
NAME                            DESIRED   CURRENT   READY         UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
elasticsearch-operator-sysctl   5         5         5         5            5           <none>          6d

$ kubectl delete daemonsets elasticsearch-operator-sysctl

Now running get pods should not list elasticsearch* pods.

Upvotes: 1

charan kumar
charan kumar

Reputation: 335

This is Because the replication set always enables to recreate the pods as mentioned in the deployment file(suppose say 3 ..kube always make sure that 3 pods up and running)

so here we need to delete replication set first to get rid of pods.

kubectl get rs

and delete the replication set .this will in turn deletes the pods

Upvotes: 1

Janos Lenart
Janos Lenart

Reputation: 27160

This is working as intended. The Deployment creates (and recreates) a ReplicaSet and the ReplicaSet creates (and recreates!) Pods. You need to delete the Deployment, not the Pods or the ReplicaSet:

kubectl delete deploy -n kloud-hosting kloud-php7

Upvotes: 7

Related Questions