I am using kubernetes version: 1.25.8. I have a yaml to create a deployment with 2 pods of nginx. When I apply the yaml (kubecl apply), it creates below resources: 1 Deployment 1 ReplicaSet 2 Pods.
When I delete the yaml (kubectl delete) , deployment is deleted but replicaSet and pods are still there.
Note: I also tried spec.revisionHistoryLimit but it works only when I update the deployment with some change (for example nginx version) but on deployment deletion, replicaSets and pods are still there.
This behaviour is causing problem, lets say if I delete and re-create deployment four times with different nginx versions. There are 4 replicas set and each one is creating 2 pods (total 8) with different versions.