Kubernetes scale down specific pods Kubernetes scale down specific pods kubernetes kubernetes

Kubernetes scale down specific pods


This isn't currently possible. When you scale down the number of replicas, the system will choose one to remove; there isn't a way to "hint" at which one you'd like it to remove.

One thing you can do is you can change the labels on running pods which can affect their membership in the replication controller. This can be used to quarantine pods that you want to debug (so that they won't be part of a service or removed by a scaling event) but might also be possible to use for your use case.


i've been looking for a solution to this myself, and i also can't find one out of the box.however, there might be a workaround (would love it if you could test and confirm)

steps:
1. delete replication controller
2. delete X desired pods
3. recreate replication controller of size X


As mention above, the workaround for this action should be something like this:

alias k=kubectl

k delete pod <pods_name> && k scale --replicas=<current_replicas - 1> deploy/<name_of_deployment>

Make sure you don't have an active hpa resource that is related to the deployment.