0
  1. When a pod is in a restart loop is it eligible for being removed during scaling down before it restarts successfully? (without stateful sets)

  2. Also what happens if a pod container exits with a non-zero exit code when scaling that pod down? Will it be restarted and shutdown again or just removed? (with or without stateful sets)

  3. Can I ensure that a pod is always gracefully shutdown without using stateful sets (because I want lifetime-unique UIDs instead of distinct reusable ordinal ids)?

Vlad
  • 3,001
  • 1
  • 22
  • 52
  • Why do you want "graceful" shutdown. If you are using pods, there should be no state, therefore any shutdown is graceful, at least that's the theory of replica set... – Aron Jul 13 '22 at 05:39
  • 1
    But there *is* a state, it just doesn't require disk. Our app design becomes much simpler when we rely on restart policy and graceful shutdown instead of putting heartbeats everywhere. – Vlad Jul 13 '22 at 06:57
  • what about using a separate pod to watch for events on pods which match a certain label? Have that pod handle the garbage collection? https://kubernetes.io/docs/reference/using-api/api-concepts/#efficient-detection-of-changes and https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#list-and-watch-filtering – Aron Jul 13 '22 at 08:12

1 Answers1

0

Can I ensure that a pod is always gracefully shutdown without using stateful sets (because I want lifetime-unique UIDs instead of distinct reusable ordinal ids)? Pods which are part of Job or Cronjob resources will run until all of the containers in the pod complete. However, the Linkerd proxy container runs continuously until it receives a TERM signal. Since Kubernetes does not give the proxy a means to know when the Cronjob has completed, by default, Job and Cronjob pods which have been meshed will continue to run even once the main container has completed. it means we can stop graecfull shutdown

You can achieve this in three steps:

Add a label to all pods except the one you want to delete. Because the labels of the pods still satisfy the selector of the Replica Set, so no new pods will be created.

Update the Replica Set: adding the new label to the selector and decreasing the replicas of the Replica Set atomically. The pod you want to delete won't be selected by the Replica Set because it doesn't have the new label.

Delete the selected pod.

Fore more information refer to these documents.