Kubernetes keeps spawning Pods after deletion

kubernetes

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 ?

Best Answer

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
Related Topic