enhancements: Terminate pod on container completion

Enhancement Description

  • One-line enhancement description (can be used as a release note):

Allow to configure container to terminate the pod on container completion when no restart should be performed as per restartPolicy.

/sig node

  • Enhancement target (which target equals to which milestone):
    • Alpha release target (x.y): 1.26
    • Beta release target (x.y): 1.27
    • Stable release target (x.y): 1.29
  • Alpha
    • KEP (k/enhancements) update PR(s):
    • Code (k/k) update PR(s):
    • Docs (k/website) update PR(s):

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 3
  • Comments: 16 (13 by maintainers)

Most upvoted comments

Clarifications - copied from slack for history here:

I don’t see the security implication regarding where it get restarted. It is fine if the decision will be to start it exactly where it was running (or somewhere else).

All that is needed is for the container to signal somehow to kubelet to delete the pod. Apparently the simplest way is to exit from the container (maybe with specific exit code, or with error, or maybe any exit will do). Now when we exited, kubelet need to take a decision if to restart the container (as done today) or delete the pod (required feature). to decide between the two we probably need to have some indication in the podSpec indicating that this container is marked to never be restarted and instead the pod need to be deleted when it exists.

I can repeat this in GitHub, but there are so many github issues and PRs on this and related issues, that I am not really sure where it is most relevant.