How to delete pods by replicaSet?

0168

To delete pods managed by a ReplicaSet in Kubernetes, you typically delete the ReplicaSet itself, which will in turn delete all the pods it manages. Here’s how to do it:

  1. Delete the ReplicaSet:
    kubectl delete replicaset <replicaset-name>

This command will delete the specified ReplicaSet and all the pods associated with it.

If you want to delete specific pods within a ReplicaSet without deleting the ReplicaSet itself, you can do so by listing the pods and then deleting them individually or by label:

  1. List pods managed by the ReplicaSet:

    kubectl get pods -l app=<app-label>
  2. Delete specific pods:

    kubectl delete pod <pod-name>
  3. Delete all pods managed by the ReplicaSet using a label:

    kubectl delete pods -l app=<app-label>

Make sure to replace <replicaset-name>, <pod-name>, and <app-label> with the appropriate values for your use case.

0 Comments

no data
Be the first to share your comment!